BUF_MEM_NEW(3ossl)

πŸ“¦
version 15.1 Β· 2 versions
, in freebsd 15.1

πŸŽ€ hi bestie, this is BUF_MEM_NEW(3ossl) πŸŽ€

okay so this is the OpenSSL manpage for the little buffer functions β€” the "simple character array structure" squad. it's short, it's sweet, and honestly it's giving "small but mighty." let's get into it πŸ’…


✨ NAME ✨

BUF_MEM_new, BUF_MEM_new_ex, BUF_MEM_free, BUF_MEM_grow, BUF_MEM_grow_clean, BUF_reverse β€” the whole squad that handles a simple character array structure 🫢


🌸 SYNOPSIS 🌸

like, the receipts, verbatim:

#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 is out here handling simple character arrays, periodt. buffers get used for all kinds of things inside the library β€” most notably memory BIOs. that's the main character usage, iykyk.

  • BUF_MEM_new() β€” allocates a brand new buffer of zero size. cute, empty, ready to be filled with possibilities ✨
  • BUF_MEM_new_ex() β€” allocates a buffer with the flags you specify. the flag BUF_MEM_FLAG_SECURE says the data pointer should be allocated on the secure heap β€” go check CRYPTO_secure_malloc(3) for the tea on that 🧚
  • BUF_MEM_free() β€” frees up a buffer you already made. and bestie, listen: the data gets zeroed before freeing, just in case it's holding sensitive stuff. safety first πŸ’– and if the argument is NULL, it literally does nothing β€” no drama, no crash, we love a chill function πŸ™ˆ
  • BUF_MEM_grow() β€” changes the size of an existing buffer to len. if it's growing, any data already in there is preserved. your stuff stays safe, no cap πŸ”₯
  • BUF_MEM_grow_clean() β€” same vibe as BUF_MEM_grow() BUT it sets any freed or additionally-allocated memory to zero. so it's the tidy one πŸŽ€
  • BUF_reverse() β€” reverses size bytes at in into out. and if in is NULL, it just reverses the array in-place instead. iconic behavior honestly πŸ‘‘

⭐ RETURN VALUES ⭐

  • BUF_MEM_new() returns the buffer, or NULL on error 😭
  • BUF_MEM_free() has no return value β€” it's a void situation, she 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) if it worked πŸŽ‰

🌈 SEE ALSO 🌈

bio(7), CRYPTO_secure_malloc(3) β€” go read those next bestie, they're linked for a reason 🫢


πŸ’œ HISTORY πŸ’œ

the BUF_MEM_new_ex() function was added in OpenSSL 1.1.0. a little baby addition, we stan a growth arc 🌱


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 before you go copying stuff β€” it's not a suggestion πŸ’€

and that's the whole page, bestie πŸ’– this was BUF_MEM_NEW(3ossl) from OpenSSL version 3.5.6, dated 2026-04-07 β€” go forth and buffer responsibly, mwah πŸ“βœ¨

πŸ“¦ where this page comes from