BUF_MEM_NEW(3ossl)

πŸ“¦ version 3.5.0, in opensuse-leap 16.0

πŸ’… BUF_MEM_NEW β€” simple character array structure

Okay so bestie, welcome to the 3ossl page for OpenSSL's buffer crew πŸŽ€ This is the whole simple character array structure situation, and honestly it's giving "small but mighty" β€” let's get into it ✨


🌸 SYNOPSIS

#include <openssl/buffer.h>

BUF_MEM *BUF_MEM_new(void);

BUF_MEM *BUF_MEM_new_ex(unsigned long flags);

void BUF_MEM_free(BUF_MEM *a);

int BUF_MEM_grow(BUF_MEM *str, int len);
size_t BUF_MEM_grow_clean(BUF_MEM *str, size_t len);

void BUF_reverse(unsigned char *out, const unsigned char *in, size_t size);

Copy that exactly, bestie β€” no ✨creative✨ typos, iykyk 😭


πŸ¦‹ DESCRIPTION

The buffer library handles simple character arrays. Buffers are used for various purposes in the library, most notably memory BIOs. Basically they're the little containers doing a lot of the behind-the-scenes work πŸ‘‘

  • BUF_MEM_new() β€” allocates a new buffer of zero size. Fresh out the box, no bytes, no drama πŸ’…
  • BUF_MEM_new_ex() β€” allocates a buffer with the specified flags. The flag BUF_MEM_FLAG_SECURE specifies that the data pointer should be allocated on the secure heap; go peek at CRYPTO_secure_malloc(3) for the deets πŸ”
  • BUF_MEM_free() β€” frees up an already existing buffer. The data is zeroed before freeing up in case the buffer contains sensitive data, so it's not out here leaking your secrets πŸ™ˆ And if the argument is NULL, nothing is done β€” it just politely minds its business 🫢
  • BUF_MEM_grow() β€” changes the size of an already existing buffer to len. Any data already in the buffer is preserved if it increases in size. Growth without the loss, we love to see it 🌱
  • BUF_MEM_grow_clean() β€” similar to BUF_MEM_grow() but it sets any free'd or additionally-allocated memory to zero. Clean girl aesthetic, literally 🧼✨
  • BUF_reverse() β€” reverses size bytes at in into out. If in is NULL, the array is reversed in-place. Flip it and reverse it πŸ”„

πŸŽ€ RETURN VALUES

  • BUF_MEM_new() returns the buffer or NULL on error 😭
  • BUF_MEM_free() has no return value. It's a void icon, it gives nothing back and that's fine πŸ’…
  • BUF_MEM_grow() and BUF_MEM_grow_clean() return zero on error or the new size (i.e., len). So 0 = bad vibes, len = slay βœ…

πŸ”₯ SEE ALSO

Go read those next, bestie, it's giving required reading πŸ“šπŸ’œ


πŸ‘‘ HISTORY

The BUF_MEM_new_ex() function was added in OpenSSL 1.1.0. So it's been around a minute β€” vintage, but make it secure πŸ•°οΈβœ¨


Copyright 2000-2024 The OpenSSL Project Authors. All Rights Reserved.

Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.

fr fr read the license, bestie β€” technically binding and everything 🫢

And that's the whole page, no cap πŸ’– Signing off from manual 3ossl, version 3.5.0, dated 2026-09-25 β€” BUF_MEM_NEW out, mwah πŸ’‹πŸŒΈ

πŸ“¦ where this page comes from