BUF_MEM_NEW(3ossl)
π 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 flagBUF_MEM_FLAG_SECUREsays the data pointer should be allocated on the secure heap β go checkCRYPTO_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 isNULL, it literally does nothing β no drama, no crash, we love a chill function πBUF_MEM_grow()β changes the size of an existing buffer tolen. if it's growing, any data already in there is preserved. your stuff stays safe, no cap π₯BUF_MEM_grow_clean()β same vibe asBUF_MEM_grow()BUT it sets any freed or additionally-allocated memory to zero. so it's the tidy one πBUF_reverse()β reversessizebytes atinintoout. and ifinisNULL, it just reverses the array in-place instead. iconic behavior honestly π
β RETURN VALUES β
BUF_MEM_new()returns the buffer, orNULLon error πBUF_MEM_free()has no return value β it's a void situation, she gives nothing back and that's fineBUF_MEM_grow()andBUF_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 π
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
- freebsd 15.1: base 15.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms