Files
mars-matrixssl/core/wrapper/wrap-malloc.c
Janne Johansson d0a51a7e43 MatrixSSL 4.0.0
2018-09-13 12:17:26 +03:00

28 lines
627 B
C

/* Provide this file after compilation via EXTRA_LDFLAGS to compilation. */
#include <stdlib.h>
#include "wrap-malloc.h"
void *myMalloc(size_t size)
{
/* Resolve ambiquity on zero byte allocation: always allocate one byte. */
return size > (size_t)0 ? malloc(size) : malloc(1);
}
void myFree(void *ptr)
{
free(ptr);
}
void *myCalloc(size_t nmemb, size_t size)
{
/* Resolve ambiquity on zero byte allocation: always allocate one byte. */
return nmemb > (size_t)0 && size > (size_t)0 ?
calloc(nmemb, size) : malloc(1);
}
void *myRealloc(void *ptr, size_t size)
{
return realloc(ptr, size);
}