source: thirdparty/blosc/internal-complibs/zstd-0.7.4/common/zstd_common.c @ 8ebc79b

Revision 8ebc79b, 3.6 KB checked in by Hal Finkel <hfinkel@…>, 8 years ago (diff)

Add the other internal compression libraries from blocs

  • Property mode set to 100644
Line 
1/*
2    Common functions of Zstd compression library
3    Copyright (C) 2015-2016, Yann Collet.
4
5    BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
6
7    Redistribution and use in source and binary forms, with or without
8    modification, are permitted provided that the following conditions are
9    met:
10    * Redistributions of source code must retain the above copyright
11    notice, this list of conditions and the following disclaimer.
12    * Redistributions in binary form must reproduce the above
13    copyright notice, this list of conditions and the following disclaimer
14    in the documentation and/or other materials provided with the
15    distribution.
16    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17    "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19    A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20    OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23    DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24    THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28    You can contact the author at :
29    - zstd homepage : http://www.zstd.net/
30*/
31
32
33/*-*************************************
34*  Dependencies
35***************************************/
36#include <stdlib.h>         /* malloc */
37#include "error_private.h"
38#define ZSTD_STATIC_LINKING_ONLY
39#include "zstd.h"           /* declaration of ZSTD_isError, ZSTD_getErrorName, ZSTD_getErrorCode, ZSTD_getErrorString, ZSTD_versionNumber */
40#include "zbuff.h"          /* declaration of ZBUFF_isError, ZBUFF_getErrorName */
41
42
43/*-****************************************
44*  Version
45******************************************/
46unsigned ZSTD_versionNumber (void) { return ZSTD_VERSION_NUMBER; }
47
48
49/*-****************************************
50*  ZSTD Error Management
51******************************************/
52/*! ZSTD_isError() :
53*   tells if a return value is an error code */
54unsigned ZSTD_isError(size_t code) { return ERR_isError(code); }
55
56/*! ZSTD_getErrorName() :
57*   provides error code string from function result (useful for debugging) */
58const char* ZSTD_getErrorName(size_t code) { return ERR_getErrorName(code); }
59
60/*! ZSTD_getError() :
61*   convert a `size_t` function result into a proper ZSTD_errorCode enum */
62ZSTD_ErrorCode ZSTD_getErrorCode(size_t code) { return ERR_getErrorCode(code); }
63
64/*! ZSTD_getErrorString() :
65*   provides error code string from enum */
66const char* ZSTD_getErrorString(ZSTD_ErrorCode code) { return ERR_getErrorName(code); }
67
68
69/* **************************************************************
70*  ZBUFF Error Management
71****************************************************************/
72unsigned ZBUFF_isError(size_t errorCode) { return ERR_isError(errorCode); }
73
74const char* ZBUFF_getErrorName(size_t errorCode) { return ERR_getErrorName(errorCode); }
75
76
77
78void* ZSTD_defaultAllocFunction(void* opaque, size_t size)
79{
80    void* address = malloc(size);
81    (void)opaque;
82    /* printf("alloc %p, %d opaque=%p \n", address, (int)size, opaque); */
83    return address;
84}
85
86void ZSTD_defaultFreeFunction(void* opaque, void* address)
87{
88    (void)opaque;
89    /* if (address) printf("free %p opaque=%p \n", address, opaque); */
90    free(address);
91}
Note: See TracBrowser for help on using the repository browser.