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 flagBUF_MEM_FLAG_SECUREsays the data pointer should be allocated on the secure heap β go peek atCRYPTO_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 isNULL, literally nothing happens. no drama, no crash, we love that for us. π«ΆBUF_MEM_grow()β changes the size of an already existing buffer tolen. any data already chillin' in the buffer is preserved if it grows in size. no data left behind. πBUF_MEM_grow_clean()β same energy asBUF_MEM_grow()BUT it sets any free'd or additionally-allocated memory to zero. clean girl aesthetic, literally.BUF_reverse()β reversessizebytes atinintoout. and ifinisNULL, the array gets reversed in-place. no extra copy needed, she's efficient. β
π RETURN VALUES π
BUF_MEM_new()returns the buffer, orNULLon error. πBUF_MEM_free()has no return value. it just does its thing and leaves.BUF_MEM_grow()andBUF_MEM_grow_clean()return zero on error, or the new size (that meanslen) 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 π
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
- ubuntu stonking: libssl-doc 4.0.3-1ubuntu1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms