Search code examples
iphonephp-ziparchive

iPhone memory leak issue in ZipArchive lib


I'm gratefully using the ZipArchive library but it seems there is a memory leak. I don't know how to fix this - it's written in C and I'm unfamiliar with it. My question is - is it possible to autorelease the line s=(unz_s*)ALLOC(sizeof(unz_s)); like you would in Objective-C in this scenario?

extern unzFile ZEXPORT unzOpen2 (path, pzlib_filefunc_def)
        const char *path;
        zlib_filefunc_def* pzlib_filefunc_def;
    {

        // ...

        s=(unz_s*)ALLOC(sizeof(unz_s));
        *s=us;
        unzGoToFirstFile((unzFile)s);
        return (unzFile)s;
    }

Here is a screen grab of the location of the leak for clarity:

http://ziparchive.googlecode.com/issues/attachment?aid=-5463964192517894688&name=Screen+shot+2010-08-20+at+8.12.58+PM.png&token=8c66aa58a4826b99ba157903fbae83bb&inline=1

Can anybody could shed some light on how I might fix this? Thanks.


Solution

  • i have faced the same problem and Solved by reading some of the blogs . it seems to simple
    close your ZipArchive Object before relesing Object
    its look like
    [ZipObj UnzipCloseFile];