ReactOS  0.4.14-dev-297-g23e575c
zstd_common.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
3  * All rights reserved.
4  *
5  * This source code is licensed under both the BSD-style license (found in the
6  * LICENSE file in the root directory of this source tree) and the GPLv2 (found
7  * in the COPYING file in the root directory of this source tree).
8  * You may select, at your option, one of the above-listed licenses.
9  */
10 
11 
12 
13 /*-*************************************
14 * Dependencies
15 ***************************************/
16 #include <stdlib.h> /* malloc, calloc, free */
17 #include <string.h> /* memset */
18 #include "error_private.h"
19 #include "zstd_internal.h"
20 
21 
22 /*-****************************************
23 * Version
24 ******************************************/
25 unsigned ZSTD_versionNumber(void) { return ZSTD_VERSION_NUMBER; }
26 
27 const char* ZSTD_versionString(void) { return ZSTD_VERSION_STRING; }
28 
29 
30 /*-****************************************
31 * ZSTD Error Management
32 ******************************************/
35 unsigned ZSTD_isError(size_t code) { return ERR_isError(code); }
36 
39 const char* ZSTD_getErrorName(size_t code) { return ERR_getErrorName(code); }
40 
44 
48 
49 
50 
51 /*=**************************************************************
52 * Custom allocator
53 ****************************************************************/
54 void* ZSTD_malloc(size_t size, ZSTD_customMem customMem)
55 {
56  return customMem.customAlloc(customMem.opaque, size);
57 }
58 
59 void* ZSTD_calloc(size_t size, ZSTD_customMem customMem)
60 {
61  /* calloc implemented as malloc+memset;
62  * not as efficient as calloc, but next best guess for custom malloc */
63  void* const ptr = customMem.customAlloc(customMem.opaque, size);
64  memset(ptr, 0, size);
65  return ptr;
66 }
67 
68 void ZSTD_free(void* ptr, ZSTD_customMem customMem)
69 {
70  if (ptr!=NULL)
71  customMem.customFree(customMem.opaque, ptr);
72 }
unsigned ZSTD_versionNumber(void)
Definition: zstd_common.c:25
const char * ZSTD_getErrorString(ZSTD_ErrorCode code)
Definition: zstd_common.c:47
const char * ZSTD_versionString(void)
Definition: zstd_common.c:27
ZSTD_ErrorCode ZSTD_getErrorCode(size_t code)
Definition: zstd_common.c:43
void ZSTD_free(void *ptr, ZSTD_customMem customMem)
Definition: zstd_common.c:68
#define ZSTD_VERSION_STRING
Definition: zstd.h:82
ZSTD_ErrorCode
Definition: zstd_errors.h:52
ERR_STATIC const char * ERR_getErrorName(size_t code)
Definition: error_private.h:67
ERR_STATIC ERR_enum ERR_getErrorCode(size_t code)
Definition: error_private.h:58
unsigned ZSTD_isError(size_t code)
Definition: zstd_common.c:35
static PVOID ptr
Definition: dispmode.c:27
smooth NULL
Definition: ftsmooth.c:416
ERR_STATIC unsigned ERR_isError(size_t code)
Definition: error_private.h:56
GLsizeiptr size
Definition: glext.h:5919
void * ZSTD_malloc(size_t size, ZSTD_customMem customMem)
Definition: zstd_common.c:54
void * ZSTD_calloc(size_t size, ZSTD_customMem customMem)
Definition: zstd_common.c:59
#define memset(x, y, z)
Definition: compat.h:39
const char * ERR_getErrorString(ERR_enum code)
Definition: error_private.c:15
const char * ZSTD_getErrorName(size_t code)
Definition: zstd_common.c:39
#define ZSTD_VERSION_NUMBER
Definition: zstd.h:76