GifLib does not free image?

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
Pirata Nervo
Posts: 409
Joined: Tue Oct 09, 2007 4:22 am

GifLib does not free image?

Post by Pirata Nervo »

I am pulling my hairs off.
I already did more than 20 tests in different ways and this function:

Code: Select all

int
DGifCloseFile(GifFileType * GifFile) {
    
    GifFilePrivateType *Private;
    FILE *File;

    if (GifFile == NULL)
        return GIF_ERROR;

    Private = (GifFilePrivateType *) GifFile->Private;

    if (!IS_READABLE(Private)) {
        /* This file was NOT open for reading: */
        _GifError = D_GIF_ERR_NOT_READABLE;
        return GIF_ERROR;
    }

    File = Private->File;

    if (GifFile->Image.ColorMap) {
        FreeMapObject(GifFile->Image.ColorMap);
        GifFile->Image.ColorMap = NULL;
    }

    if (GifFile->SColorMap) {
        FreeMapObject(GifFile->SColorMap);
        GifFile->SColorMap = NULL;
    }

    if (Private) {
        free((char *)Private);
        Private = NULL;
    }

    if (GifFile->SavedImages) {
        FreeSavedImages(GifFile);
        GifFile->SavedImages = NULL;
    }

    free(GifFile);

    if (File && (fclose(File) != 0)) {
        _GifError = D_GIF_ERR_CLOSE_FAILED;
        return GIF_ERROR;
    }
    return GIF_OK;
}
I don't know what's wrong.

Edit:
this is the original giflib code and not the giflib im using. I am using the one that J.F. posted. I am currently fixing some errors in the original one so I can use it and try it

Edit2:
J.F. if you see this please answer me, in the compiled version of gif lib, did you include the close function?
Image
Upgrade your PSP
Pirata Nervo
Posts: 409
Joined: Tue Oct 09, 2007 4:22 am

Post by Pirata Nervo »

Sorry for the double post, I just want to say it is fixed :)
Image
Upgrade your PSP
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

Pirata Nervo wrote:Sorry for the double post, I just want to say it is fixed :)
It would help others if people would post the "fixes" they discover to problems, even if it's only to say they spelled a function wrong or passed the wrong pointer.
Pirata Nervo
Posts: 409
Joined: Tue Oct 09, 2007 4:22 am

Post by Pirata Nervo »

I was just doing it wrong, I had an if that would never be true.
And inside that if I called the function I posted.

But it works now because the if can be true now :P
Image
Upgrade your PSP
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

See? Now the next person that has trouble freeing a gif won't bug you asking if their problem isn't the same as yours. :D
Pirata Nervo
Posts: 409
Joined: Tue Oct 09, 2007 4:22 am

Post by Pirata Nervo »

lol ok I will start doing this
Image
Upgrade your PSP
Post Reply