OPENSSL_MALLOC(3)
π 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()andCRYPTO_free()first appeared in SSLeay 0.6.4 and have been available since OpenBSD 2.4.OPENSSL_malloc()andOPENSSL_free()first appeared in OpenSSL 0.9.6 and have been available since OpenBSD 2.9.CRYPTO_strdup()andOPENSSL_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
- alpine 3.24: libressl-doc 4.3.1-r0 Β· custom
- arch rolling: libressl 4.4.0-1 Β· ISC AND custom:OpenSSL
- Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms