BUF_MEM_NEW(3SSL)

πŸ’– BUF_MEM_NEW(3SSL) πŸ’–

okay bestie, sit down, hydrate, because we're talking about the OpenSSL buffer library manual page. yes, that BUF_MEM_NEW(3SSL) one. this is the girlies' guide to simple character array structures and honestly? it's giving foundational. πŸ¦‹

The whole squad: BUF_MEM_new, BUF_MEM_new_ex, BUF_MEM_free, BUF_MEM_grow, BUF_MEM_grow_clean, and BUF_reverse. six icons, one page. periodt.


✨ SYNOPSIS ✨

like, exactly how you type it, no improvising:

#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);

🌸 DESCRIPTION 🌸

so the buffer library handles simple character arrays. that's the whole vibe. buffers get used all over the place in the library, and most notably for memory BIOs. iykyk.

  • BUF_MEM_new() β€” allocates a brand new buffer, and it's zero size bestie. starts from nothing, main character energy.
  • BUF_MEM_new_ex() β€” allocates a buffer with the flags you hand it. the flag BUF_MEM_FLAG_SECURE says the data pointer should be allocated on the secure heap β€” go peek at CRYPTO_secure_malloc(3) if you wanna know more. πŸ’…
  • BUF_MEM_free() β€” frees up a buffer that already exists. and here's the tea: the data gets zeroed before freeing, just in case the buffer is holding sensitive data. so thoughtful. if the argument is NULL, literally nothing happens. no drama, no crash, we love that for us. 🫢
  • BUF_MEM_grow() β€” changes the size of an already existing buffer to len. any data already chillin' in the buffer is preserved if it grows in size. no data left behind. πŸ’–
  • BUF_MEM_grow_clean() β€” same energy as 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. and if in is NULL, the array gets reversed in-place. no extra copy needed, she's efficient. ⭐

πŸ‘‘ RETURN VALUES πŸ‘‘

  • BUF_MEM_new() returns the buffer, or NULL on error. 😭
  • BUF_MEM_free() has no return value. it just does its thing and leaves.
  • BUF_MEM_grow() and BUF_MEM_grow_clean() return zero on error, or the new size (that means len) on success. bestie, always check for that zero, fr fr.

πŸ”₯ SEE ALSO πŸ”₯

go read those next, they're part of the lore.


πŸŽ€ HISTORY πŸŽ€

BUF_MEM_new_ex() showed up in OpenSSL 1.1.0. a legend was born. ✨


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>.


and that's the whole page, no cap. this was OpenSSL 4.0.3, dated 2026-09-29, and it's been BUF_MEM_NEW(3SSL) the entire time. slay, go allocate responsibly πŸ’…πŸŒΈπŸ’–
πŸ“¦ where this page comes from