diff options
author | John Hawthorn <jhawthor@uvic.ca> | 2008-06-25 16:20:40 -0700 |
---|---|---|
committer | John Hawthorn <jhawthor@uvic.ca> | 2008-06-25 16:20:40 -0700 |
commit | 45cf68a160f94d1091c3e5c69237505b138daf25 (patch) | |
tree | 33b3c29257f6f983b90174caeaa03f60c856de69 /src/bmp.c | |
parent | 665c97078cfa687273e89c8b969d08f5290bcc01 (diff) | |
download | mirror-meh-45cf68a160f94d1091c3e5c69237505b138daf25.tar.gz mirror-meh-45cf68a160f94d1091c3e5c69237505b138daf25.tar.bz2 mirror-meh-45cf68a160f94d1091c3e5c69237505b138daf25.zip |
added close method. Fixed all known memory leaks
Diffstat (limited to 'src/bmp.c')
-rw-r--r-- | src/bmp.c | 14 |
1 files changed, 11 insertions, 3 deletions
@@ -10,6 +10,7 @@ struct rgb_t{ struct bmp_t{ struct image img; + FILE *f; unsigned long bitmapoffset; int compression; int bpp; @@ -43,7 +44,7 @@ struct image *bmp_open(FILE *f){ return NULL; b = malloc(sizeof(struct bmp_t)); - b->img.f = f; + b->f = f; fseek(f, 10, SEEK_SET); b->bitmapoffset = getlong(f); @@ -151,7 +152,7 @@ int bmp_read(struct image *img){ unsigned int i, y; unsigned int dy; unsigned char *row; - FILE *f = img->f; + FILE *f = b->f; row = malloc(b->rowwidth); dy = img->width * 3; @@ -170,8 +171,15 @@ int bmp_read(struct image *img){ return 0; } +void bmp_close(struct image *img){ + struct bmp_t *b = (struct bmp_t *)img; + free(b->colours); + fclose(b->f); +} + struct imageformat bmp = { bmp_open, - bmp_read + bmp_read, + bmp_close }; |