123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- #include <stdlib.h>
- #include <string.h>
- #include "error_private.h"
- #include "zstd_internal.h"
- unsigned ZSTD_versionNumber(void) { return ZSTD_VERSION_NUMBER; }
- const char* ZSTD_versionString(void) { return ZSTD_VERSION_STRING; }
- #undef ZSTD_isError
- unsigned ZSTD_isError(size_t code) { return ERR_isError(code); }
- const char* ZSTD_getErrorName(size_t code) { return ERR_getErrorName(code); }
- ZSTD_ErrorCode ZSTD_getErrorCode(size_t code) { return ERR_getErrorCode(code); }
- const char* ZSTD_getErrorString(ZSTD_ErrorCode code) { return ERR_getErrorString(code); }
- void* ZSTD_malloc(size_t size, ZSTD_customMem customMem)
- {
- if (customMem.customAlloc)
- return customMem.customAlloc(customMem.opaque, size);
- return malloc(size);
- }
- void* ZSTD_calloc(size_t size, ZSTD_customMem customMem)
- {
- if (customMem.customAlloc) {
-
- void* const ptr = customMem.customAlloc(customMem.opaque, size);
- memset(ptr, 0, size);
- return ptr;
- }
- return calloc(1, size);
- }
- void ZSTD_free(void* ptr, ZSTD_customMem customMem)
- {
- if (ptr!=NULL) {
- if (customMem.customFree)
- customMem.customFree(customMem.opaque, ptr);
- else
- free(ptr);
- }
- }
|