本文整理汇总了C++中TRYFREE函数的典型用法代码示例。如果您正苦于以下问题:C++ TRYFREE函数的具体用法?C++ TRYFREE怎么用?C++ TRYFREE使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TRYFREE函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: destroy
/* ===========================================================================
* Cleanup then free the given gz_stream. Return a zlib error code.
Try freeing in the reverse order of allocations.
*/
static int destroy (gz_stream *s)
{
int err = Z_OK;
if (!s)
return Z_STREAM_ERROR;
TRYFREE(s->msg);
if (s->stream.state != NULL) {
if (s->mode == 'w') {
#ifdef NO_DEFLATE
err = Z_STREAM_ERROR;
#else
err = deflateEnd(&(s->stream));
#endif
} else if (s->mode == 'r') {
err = inflateEnd(&(s->stream));
}
}
if (s->file != (SYS_FILEHANDLE )NULL)
{
FIO_std.fclose(s->file);
}
if (s->z_err < 0)
err = s->z_err;
TRYFREE(s->inbuf);
TRYFREE(s->outbuf);
TRYFREE(s);
return err;
}
示例2: TRYFREE
int UnCompressZip::unzCloseCurrentFile (unzFile file)
{
int err=UNZ_OK;
unz64_s* s;
file_in_zip64_read_info_s* pfile_in_zip_read_info;
if (file==NULL)
return UNZ_PARAMERROR;
s=(unz64_s*)file;
pfile_in_zip_read_info=s->pfile_in_zip_read;
if (pfile_in_zip_read_info==NULL)
return UNZ_PARAMERROR;
if ((pfile_in_zip_read_info->rest_read_uncompressed == 0) &&
(!pfile_in_zip_read_info->raw))
{
if (pfile_in_zip_read_info->crc32 != pfile_in_zip_read_info->crc32_wait)
err=UNZ_CRCERROR;
}
TRYFREE(pfile_in_zip_read_info->read_buffer);
pfile_in_zip_read_info->read_buffer = NULL;
if (pfile_in_zip_read_info->stream_initialised == Z_DEFLATED)
inflateEnd(&pfile_in_zip_read_info->stream);
pfile_in_zip_read_info->stream_initialised = 0;
TRYFREE(pfile_in_zip_read_info);
s->pfile_in_zip_read=NULL;
return err;
}
示例3: unzCloseCurrentFile
/*
Close the file in zip opened with unzipOpenCurrentFile
Return UNZ_CRCERROR if all the file was read but the CRC is not good
*/
extern int ZEXPORT unzCloseCurrentFile (unzFile file)
{
int err=UNZ_OK;
unz_s* s;
file_in_zip_read_info_s* pfile_in_zip_read_info;
if (file==NULL)
return UNZ_PARAMERROR;
s=(unz_s*)file;
pfile_in_zip_read_info=s->pfile_in_zip_read;
if (pfile_in_zip_read_info==NULL)
return UNZ_PARAMERROR;
if (pfile_in_zip_read_info->rest_read_uncompressed == 0)
{
if (pfile_in_zip_read_info->crc32 != pfile_in_zip_read_info->crc32_wait)
err=UNZ_CRCERROR;
}
TRYFREE(pfile_in_zip_read_info->read_buffer);
pfile_in_zip_read_info->read_buffer = NULL;
if (pfile_in_zip_read_info->stream_initialised)
inflateEnd(&pfile_in_zip_read_info->stream);
pfile_in_zip_read_info->stream_initialised = 0;
TRYFREE(pfile_in_zip_read_info);
s->pfile_in_zip_read=NULL;
return err;
}
示例4: unzLocateFile
//extern
int ZEXPORT unzLocateFile (unzFile file, const char *szFileName, int iCaseSensitivity)
{
unz_s* s;
int err;
/* We remember the 'current' position in the file so that we can jump
* back there if we fail.
*/
unz_file_info cur_file_infoSaved;
unz_file_info_internal cur_file_info_internalSaved;
uLong num_fileSaved;
uLong pos_in_central_dirSaved;
char *szCurrentFileName = NULL;
if (file==NULL)
return UNZ_PARAMERROR;
if (strlen(szFileName)>=UNZ_MAXFILENAMEINZIP)
return UNZ_PARAMERROR;
s=(unz_s*)file;
if (!s->current_file_ok) {
return UNZ_END_OF_LIST_OF_FILE;
}
/* Save the current state */
num_fileSaved = s->num_file;
pos_in_central_dirSaved = s->pos_in_central_dir;
cur_file_infoSaved = s->cur_file_info;
cur_file_info_internalSaved = s->cur_file_info_internal;
err = unzGoToFirstFile(file);
szCurrentFileName = (char*) ALLOC(UNZ_MAXFILENAMEINZIP+1); // heap_alloc - 256
while (err == UNZ_OK)
{
err = unzlocal_GetCurrentFileInfoInternal(file,NULL, NULL,
szCurrentFileName,sizeof(szCurrentFileName)-1,
NULL,0,NULL,0);
if (err == UNZ_OK)
{
if (unzStringFileNameCompare(szCurrentFileName,
szFileName,iCaseSensitivity)==0) {
TRYFREE(szCurrentFileName);
return UNZ_OK;
}
err = unzGoToNextFile(file);
}
}
TRYFREE(szCurrentFileName);
/* We failed, so restore the state of the 'current file' to where we
* were.
*/
s->num_file = num_fileSaved ;
s->pos_in_central_dir = pos_in_central_dirSaved ;
s->cur_file_info = cur_file_infoSaved;
s->cur_file_info_internal = cur_file_info_internalSaved;
return err;
}
示例5: _zcfree
static void _zcfree (
voidpf opaque,
voidpf ptr)
{
TRYFREE(ptr);
if (opaque) return; /* make compiler happy */
}
示例6: free_datablock
local void free_datablock( linkedlist_datablock_internal* ldi)
{
while (ldi!=0)
{
linkedlist_datablock_internal* ldinext = ldi->next_datablock;
TRYFREE(ldi);
ldi = ldinext;
}
}
示例7: zipfile
/*
Locate the Central directory of a zipfile (at the end, just before
the global comment)
*/
local uLong ziplocal_SearchCentralDir(
const zlib_filefunc_def* pzlib_filefunc_def,
voidpf filestream)
{
unsigned char* buf;
uLong uSizeFile;
uLong uBackRead;
uLong uMaxBack=0xffff; /* maximum size of global comment */
uLong uPosFound=0;
if (ZSEEK(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0)
return 0;
uSizeFile = ZTELL(*pzlib_filefunc_def,filestream);
if (uMaxBack>uSizeFile)
uMaxBack = uSizeFile;
buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4);
if (buf==NULL)
return 0;
uBackRead = 4;
while (uBackRead<uMaxBack)
{
uLong uReadSize,uReadPos ;
int i;
if (uBackRead+BUFREADCOMMENT>uMaxBack)
uBackRead = uMaxBack;
else
uBackRead+=BUFREADCOMMENT;
uReadPos = uSizeFile-uBackRead ;
uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ?
(BUFREADCOMMENT+4) : (uSizeFile-uReadPos);
if (ZSEEK(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0)
break;
if (ZREAD(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize)
break;
for (i=(int)uReadSize-3; (i--)>0;)
if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06))
{
uPosFound = uReadPos+i;
break;
}
if (uPosFound!=0)
break;
}
TRYFREE(buf);
return uPosFound;
}
示例8: zipfile
/*
Locate the Central directory of a zipfile (at the end, just before
the global comment)
*/
local uLong unzlocal_SearchCentralDir(FILE *fin)
{
unsigned char* buf;
uLong uSizeFile;
uLong uBackRead;
uLong uMaxBack=0xffff; /* maximum size of global comment */
uLong uPosFound=0;
if (fseek(fin,0,SEEK_END) != 0)
return 0;
uSizeFile = ftell( fin );
if (uMaxBack>uSizeFile)
uMaxBack = uSizeFile;
buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4);
if (buf==NULL)
return 0;
uBackRead = 4;
while (uBackRead<uMaxBack)
{
uLong uReadSize,uReadPos ;
int i;
if (uBackRead+BUFREADCOMMENT>uMaxBack)
uBackRead = uMaxBack;
else
uBackRead+=BUFREADCOMMENT;
uReadPos = uSizeFile-uBackRead ;
uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ?
(BUFREADCOMMENT+4) : (uSizeFile-uReadPos);
if (fseek(fin,uReadPos,SEEK_SET)!=0)
break;
if (fread(buf,(uInt)uReadSize,1,fin)!=1)
break;
for (i=(int)uReadSize-3; (i--)>0;)
if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06))
{
uPosFound = uReadPos+i;
break;
}
if (uPosFound!=0)
break;
}
TRYFREE(buf);
return uPosFound;
}
示例9: unzipOpenCurrentFile
/*
Close a ZipFile opened with unzOpen.
If there is files inside the .Zip opened with unzipOpenCurrentFile (see later),
these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
return UNZ_OK if there is no problem. */
ZEXTERN int ZEXPORT unzClose(HUNZFILE file)
{
LPUNZ_INTERNAL s;
if(!file) return UNZ_PARAMERROR;
s = (LPUNZ_INTERNAL)file;
if(s->pfile_in_zip_read) unzCloseCurrentFile(file);
fclose(s->file);
TRYFREE(s);
return UNZ_OK;
}
示例10: unzipOpenCurrentFile
/*
Close a ZipFile opened with unzipOpen.
If there is files inside the .Zip opened with unzipOpenCurrentFile (see later),
these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
return UNZ_OK if there is no problem. */
extern int ZEXPORT unzClose (unzFile file) {
unz_s* s;
if (file==NULL)
return UNZ_PARAMERROR;
s=(unz_s*)file;
if (s->pfile_in_zip_read!=NULL)
unzCloseCurrentFile(file);
fclose(s->file);
TRYFREE(s);
return UNZ_OK;
}
示例11: unzCloseCurrentFile
int UnCompressZip::unzClose (unzFile file)
{
unz64_s* s;
if (file==NULL)
return UNZ_PARAMERROR;
s=(unz64_s*)file;
if (s->pfile_in_zip_read!=NULL)
unzCloseCurrentFile(file);
ZCLOSE64(s->z_filefunc, s->filestream);
TRYFREE(s);
return UNZ_OK;
}
示例12: unzClose
//extern
int ZEXPORT unzClose (unzFile file)
{
unz_s* s;
if (file==NULL)
return UNZ_PARAMERROR;
s=(unz_s*)file;
if (s->pfile_in_zip_read!=NULL)
unzCloseCurrentFile(file);
ZCLOSE(s->z_filefunc, s->filestream);
TRYFREE(s);
return UNZ_OK;
}
示例13: unzipOpenCurrentFile
/*
Close a ZipFile opened with unzipOpen.
If there is files inside the .Zip opened with unzipOpenCurrentFile (see later),
these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
return UNZ_OK if there is no problem. */
int unzClose (unzFile file)
{
unz_s* s;
if (file==NULL)
return UNZ_PARAMERROR;
s=(unz_s*)file;
if (s->pfile_in_zip_read!=NULL)
unzCloseCurrentFile(file);
fclose((FILE*)s->filestream);
TRYFREE(s);
return UNZ_OK;
}
示例14: opened
/* Open a Zip file. path contain the full pathname (by example, on
a Windows NT computer "c:\\test\\zlib109.zip" or on an Unix computer
"zlib/zlib109.zip".
If the zipfile cannot be opened (file don't exist or in not valid),
the return value is NULL.
Else, the return value is a HUNZFILE Handle, usable with other
function of this unzip package. */
ZEXTERN HUNZFILE ZEXPORT unzOpen(LPCSTR pszFileName)
{
LPUNZ_INTERNAL s;
int err = UNZ_OK;
int iPathSize;
BOOL fPath;
char buf[4];
LPSTR pszName;
// getting the full path to the file
iPathSize = GetFullPathName(pszFileName, 0, buf, &pszName);
if(!iPathSize)
{ iPathSize = lstrlen(pszFileName);
fPath = FALSE; }
else fPath = TRUE;
// alloc memory for the internal structure
s = (LPUNZ_INTERNAL)ALLOCZ(sizeof(UNZ_INTERNAL) + iPathSize + 2);
if(!s) return NULL;
// copying the file path to the memory
if(fPath)
{
iPathSize = GetFullPathName(pszFileName, iPathSize + 1,
s->pszFilePath, &pszName);
if(!iPathSize) err = UNZ_ERRNO;
}
else
{ zmemcpy(s->pszFilePath, pszFileName, iPathSize);
s->pszFilePath[iPathSize] = 0; }
// opening the file
if(err == UNZ_OK) err = unzLocal_OpenInternal(s);
if(err != UNZ_OK)
{ TRYFREE(s); s = NULL; }
return (HUNZFILE)s;
}
示例15: unzlocal_SearchCentralDir
static DWORD unzlocal_SearchCentralDir(const zlib_filefunc_def *pzlib_filefunc_def, void *filestream)
{
BYTE *buf;
DWORD uSizeFile;
DWORD uBackRead;
DWORD uMaxBack = 0xffff; /* maximum size of global comment */
DWORD uPosFound = 0;
if (ZSEEK(*pzlib_filefunc_def, filestream, 0, SEEK_END) != 0)
{
return 0;
}
uSizeFile = ZTELL(*pzlib_filefunc_def, filestream);
if (uMaxBack > uSizeFile)
{
uMaxBack = uSizeFile;
}
buf = (BYTE*)ALLOC(BUFREADCOMMENT + 4);
if (buf == NULL)
{
return 0;
}
uBackRead = 4;
while (uBackRead < uMaxBack)
{
DWORD uReadSize, uReadPos;
int i;
if (uBackRead + BUFREADCOMMENT > uMaxBack)
{
uBackRead = uMaxBack;
}
else
{
uBackRead += BUFREADCOMMENT;
}
uReadPos = uSizeFile - uBackRead;
uReadSize = ((BUFREADCOMMENT + 4) < (uSizeFile - uReadPos)) ? (BUFREADCOMMENT + 4): (uSizeFile - uReadPos);
if (ZSEEK(*pzlib_filefunc_def, filestream, uReadPos, SEEK_SET) != 0)
{
break;
}
if (ZREAD(*pzlib_filefunc_def, filestream, buf, uReadSize) != uReadSize)
{
break;
}
for (i = (int)uReadSize - 3; (i--) > 0;)
if (((*(buf + i)) == 0x50) && ((*(buf + i + 1)) == 0x4b) && ((*(buf + i + 2)) == 0x05) && ((*(buf + i + 3)) == 0x06))
{
uPosFound = uReadPos + i;
break;
}
if (uPosFound != 0)
{
break;
}
}
TRYFREE(buf);
return uPosFound;
}