BUF_MEM_NEW(3ossl)
π 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 flagBUF_MEM_FLAG_SECUREspecifies that the data pointer should be allocated on the secure heap; go peek atCRYPTO_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 isNULL, 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 toBUF_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 isNULL, the array is reversed in-place. Flip it and reverse it π
π RETURN VALUES
BUF_MEM_new()returns the buffer orNULLon error πBUF_MEM_free()has no return value. It's a void icon, it gives nothing back and that's fine πBUF_MEM_grow()andBUF_MEM_grow_clean()return zero on error or the new size (i.e., len). So0= 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
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
- opensuse-leap 16.0: openssl-3-doc 3.5.0-160000.11.1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms