www.pudn.com > 200410111032011273DESMD5ZLIB算法源代码.rar > Zutil.cpp


/* zutil.c -- target dependent utility functions for the compression library 
 * Copyright (C) 1995-1998 Jean-loup Gailly. 
 * For conditions of distribution and use, see copyright notice in zlib.h 
 */ 
 
/* @(#) $Id$ */ 
 
#include "stdafx.h" 
#include "zutil.h" 
 
struct internal_state      {int dummy;}; /* for buggy compilers */ 
const char *z_errmsg[10] = { 
"need dictionary",     /* Z_NEED_DICT       2  */ 
"stream end",          /* Z_STREAM_END      1  */ 
"",                    /* Z_OK              0  */ 
"file error",          /* Z_ERRNO         (-1) */ 
"stream error",        /* Z_STREAM_ERROR  (-2) */ 
"data error",          /* Z_DATA_ERROR    (-3) */ 
"insufficient memory", /* Z_MEM_ERROR     (-4) */ 
"buffer error",        /* Z_BUF_ERROR     (-5) */ 
"incompatible version",/* Z_VERSION_ERROR (-6) */ 
""}; 
 
 
/* exported to allow conversion of error code to string for compress() and 
 * unzipcompress() 
 */ 
const char *  zError(int err) 
{ 
    return ERR_MSG(err); 
} 
 
void *zcalloc (void *opaque, unsigned items, unsigned size) 
{ 
    if (opaque) items += size - size; /* make compiler happy */ 
    return (void *)calloc(items, size); 
} 
 
void  zcfree (void *opaque, void *ptr) 
{ 
    free(ptr); 
    if (opaque) return; /* make compiler happy */ 
}