OPENSSL_MALLOC(3)

πŸ“¦ version 4.4.0, in alpine 3.24, arch rolling

πŸ’… OPENSSL_MALLOC(3) πŸ’…

okay so bestie, this is OPENSSL_MALLOC(3) from the Library Functions Manual β€” and yes, it's literally the legacy memory-allocation wrapper page for libcrypto. Short page, real lore, let's get into it. 🫢


🌸 NAME 🌸

OPENSSL_malloc, OPENSSL_free, OPENSSL_strdup, CRYPTO_malloc, CRYPTO_free, CRYPTO_strdup β€” the legacy OpenSSL memory allocation wrappers. That's the whole squad, no cap. ✨

✨ SYNOPSIS ✨

here's the exact code, bestie β€” signatures copied character for character, because we do not play with types around here:

library β€œlibcrypto” #include <openssl/crypto.h>

void *
OPENSSL_malloc(size_t num);

void
OPENSSL_free(void *addr);

char *
OPENSSL_strdup(const char *str);

void *
CRYPTO_malloc(size_t num, const char *file, int line);

void
CRYPTO_free(void *str, const char *, int);

char *
CRYPTO_strdup(const char *p, const char *file, int line);

πŸ¦‹ DESCRIPTION πŸ¦‹

🚨 the big rule first: do not use any of the interfaces documented here in new code. They are provided purely for compatibility with legacy application code. It's giving museum exhibit, not new-build energy. πŸ’€

These functions are wrappers around the corresponding standard malloc(3), free(3), and strdup(3) functions.

The OPENSSL_*() functions are implemented as macros. iconic behavior, honestly. πŸ’…

πŸŽ€ RETURN VALUES πŸŽ€

These functions return the same type and value as the corresponding standard functions. that's it, that's the tea. πŸ“

πŸ‘‘ SEE ALSO πŸ‘‘

one reference, one icon. 🌟

πŸ’œ HISTORY πŸ’œ

  • CRYPTO_malloc() and CRYPTO_free() first appeared in SSLeay 0.6.4 and have been available since OpenBSD 2.4.
  • OPENSSL_malloc() and OPENSSL_free() first appeared in OpenSSL 0.9.6 and have been available since OpenBSD 2.9.
  • CRYPTO_strdup() and OPENSSL_strdup() first appeared in OpenSSL 0.9.8j and have been available since OpenBSD 4.5.

so yes, these are old old. vintage, even. 🧚

πŸ”₯ CAVEATS πŸ”₯

If interoperability with other implementations is required, memory returned by the library as bare pointers must be freed with OPENSSL_free().

like, do not mix up your frees, bestie. if interop with other implementations matters, bare pointers from the library must go back through OPENSSL_free(). periodt. 😭


with love from Debian, dated June 8, 2025 β€” OPENSSL_MALLOC(3), mwah πŸ’‹

πŸ“¦ where this page comes from