This allocator will be mostly used to allocate contexts/keys.
Change-Id: I5c3a5efcda5a243503ac80502c221157e18eaa2a
Signed-off-by: Mateusz Kulikowski <m.kulikowski@samsung.com>
// TODO: this should be a macro to CRYPTO_*
void *yaca_malloc(size_t size);
+/**
+ * @brief yaca_zalloc Allocates the zeroed memory.
+ *
+ * @param[in] size Size of the allocation (bytes).
+ *
+ * @return NULL on failure, pointer to allocated and zeroed memory otherwise.
+ */
+// TODO: this should be a macro to CRYPTO_*
+void *yaca_zalloc(size_t size);
+
/**
* @brief yaca_realloc Re-allocates the memory.
*
*/
#include <assert.h>
+#include <string.h>
#include <openssl/crypto.h>
#include <openssl/evp.h>
return OPENSSL_malloc(size);
}
+API void *yaca_zalloc(size_t size)
+{
+ void *blob = OPENSSL_malloc(size);
+ if (blob != NULL)
+ memset(blob, 0, size);
+ return blob;
+}
+
API void *yaca_realloc(void *addr, size_t size)
{
return OPENSSL_realloc(addr, size);