ReactOS 0.4.15-dev-8058-ga7cbb60
zstd_common.c
Go to the documentation of this file.
1/*
2 * Copyright (c) 2016-2020, 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******************************************/
25unsigned ZSTD_versionNumber(void) { return ZSTD_VERSION_NUMBER; }
26
27const char* ZSTD_versionString(void) { return ZSTD_VERSION_STRING; }
28
29
30/*-****************************************
31* ZSTD Error Management
32******************************************/
33#undef ZSTD_isError /* defined within zstd_internal.h */
37unsigned ZSTD_isError(size_t code) { return ERR_isError(code); }
38
41const char* ZSTD_getErrorName(size_t code) { return ERR_getErrorName(code); }
42
46
50
51
52
53/*=**************************************************************
54* Custom allocator
55****************************************************************/
56void* ZSTD_malloc(size_t size, ZSTD_customMem customMem)
57{
58 return customMem.customAlloc(customMem.opaque, size);
59}
60
61void* ZSTD_calloc(size_t size, ZSTD_customMem customMem)
62{
63 /* calloc implemented as malloc+memset;
64 * not as efficient as calloc, but next best guess for custom malloc */
65 void* const ptr = customMem.customAlloc(customMem.opaque, size);
66 memset(ptr, 0, size);
67 return ptr;
68}
69
70void ZSTD_free(void* ptr, ZSTD_customMem customMem)
71{
72 if (ptr!=NULL)
73 customMem.customFree(customMem.opaque, ptr);
74}
#define NULL
Definition: types.h:112
const char * ERR_getErrorString(ERR_enum code)
Definition: error_private.c:15
ERR_STATIC ERR_enum ERR_getErrorCode(size_t code)
Definition: error_private.h:58
ERR_STATIC unsigned ERR_isError(size_t code)
Definition: error_private.h:56
ERR_STATIC const char * ERR_getErrorName(size_t code)
Definition: error_private.h:71
GLsizeiptr size
Definition: glext.h:5919
static PVOID ptr
Definition: dispmode.c:27
#define memset(x, y, z)
Definition: compat.h:39
Definition: inflate.c:139
#define ZSTD_VERSION_NUMBER
Definition: zstd.h:77
#define ZSTD_VERSION_STRING
Definition: zstd.h:83
ZSTD_ErrorCode ZSTD_getErrorCode(size_t code)
Definition: zstd_common.c:45
const char * ZSTD_versionString(void)
Definition: zstd_common.c:27
unsigned ZSTD_versionNumber(void)
Definition: zstd_common.c:25
void ZSTD_free(void *ptr, ZSTD_customMem customMem)
Definition: zstd_common.c:70
const char * ZSTD_getErrorString(ZSTD_ErrorCode code)
Definition: zstd_common.c:49
void * ZSTD_malloc(size_t size, ZSTD_customMem customMem)
Definition: zstd_common.c:56
void * ZSTD_calloc(size_t size, ZSTD_customMem customMem)
Definition: zstd_common.c:61
const char * ZSTD_getErrorName(size_t code)
Definition: zstd_common.c:41
ZSTD_ErrorCode
Definition: zstd_errors.h:52
#define ZSTD_isError
Definition: zstd_internal.h:46