LCOV - code coverage report
Current view: top level - pression/compressor/zstd/lib/common - zstd_common.c (source / functions) Hit Total Coverage
Test: Pression Lines: 13 19 68.4 %
Date: 2016-12-06 05:44:58 Functions: 5 11 45.5 %

          Line data    Source code
       1             : /**
       2             :  * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
       3             :  * All rights reserved.
       4             :  *
       5             :  * This source code is licensed under the BSD-style license found in the
       6             :  * LICENSE file in the root directory of this source tree. An additional grant
       7             :  * of patent rights can be found in the PATENTS file in the same directory.
       8             :  */
       9             : 
      10             : 
      11             : 
      12             : /*-*************************************
      13             : *  Dependencies
      14             : ***************************************/
      15             : #include <stdlib.h>         /* malloc */
      16             : #include "error_private.h"
      17             : #define ZSTD_STATIC_LINKING_ONLY
      18             : #include "zstd.h"           /* declaration of ZSTD_isError, ZSTD_getErrorName, ZSTD_getErrorCode, ZSTD_getErrorString, ZSTD_versionNumber */
      19             : #include "zbuff.h"          /* declaration of ZBUFF_isError, ZBUFF_getErrorName */
      20             : 
      21             : 
      22             : /*-****************************************
      23             : *  Version
      24             : ******************************************/
      25           0 : unsigned ZSTD_versionNumber (void) { return ZSTD_VERSION_NUMBER; }
      26             : 
      27             : 
      28             : /*-****************************************
      29             : *  ZSTD Error Management
      30             : ******************************************/
      31             : /*! ZSTD_isError() :
      32             : *   tells if a return value is an error code */
      33        6948 : unsigned ZSTD_isError(size_t code) { return ERR_isError(code); }
      34             : 
      35             : /*! ZSTD_getErrorName() :
      36             : *   provides error code string from function result (useful for debugging) */
      37           0 : const char* ZSTD_getErrorName(size_t code) { return ERR_getErrorName(code); }
      38             : 
      39             : /*! ZSTD_getError() :
      40             : *   convert a `size_t` function result into a proper ZSTD_errorCode enum */
      41           0 : ZSTD_ErrorCode ZSTD_getErrorCode(size_t code) { return ERR_getErrorCode(code); }
      42             : 
      43             : /*! ZSTD_getErrorString() :
      44             : *   provides error code string from enum */
      45           0 : const char* ZSTD_getErrorString(ZSTD_ErrorCode code) { return ERR_getErrorName(code); }
      46             : 
      47             : 
      48             : /* **************************************************************
      49             : *  ZBUFF Error Management
      50             : ****************************************************************/
      51           0 : unsigned ZBUFF_isError(size_t errorCode) { return ERR_isError(errorCode); }
      52             : 
      53           0 : const char* ZBUFF_getErrorName(size_t errorCode) { return ERR_getErrorName(errorCode); }
      54             : 
      55             : 
      56             : 
      57             : /*=**************************************************************
      58             : *  Custom allocator
      59             : ****************************************************************/
      60             : /* default uses stdlib */
      61         148 : void* ZSTD_defaultAllocFunction(void* opaque, size_t size)
      62             : {
      63         148 :     void* address = malloc(size);
      64             :     (void)opaque;
      65         148 :     return address;
      66             : }
      67             : 
      68         148 : void ZSTD_defaultFreeFunction(void* opaque, void* address)
      69             : {
      70             :     (void)opaque;
      71         148 :     free(address);
      72         148 : }
      73             : 
      74         148 : void* ZSTD_malloc(size_t size, ZSTD_customMem customMem)
      75             : {
      76         148 :     return customMem.customAlloc(customMem.opaque, size);
      77             : }
      78             : 
      79         222 : void ZSTD_free(void* ptr, ZSTD_customMem customMem)
      80             : {
      81         222 :     if (ptr!=NULL)
      82         148 :         customMem.customFree(customMem.opaque, ptr);
      83         222 : }

Generated by: LCOV version 1.11