aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
authorJohn Hawthorn <jhawthor@uvic.ca>2008-06-25 16:20:40 -0700
committerJohn Hawthorn <jhawthor@uvic.ca>2008-06-25 16:20:40 -0700
commit45cf68a160f94d1091c3e5c69237505b138daf25 (patch)
tree33b3c29257f6f983b90174caeaa03f60c856de69 /src/main.c
parent665c97078cfa687273e89c8b969d08f5290bcc01 (diff)
downloadmirror-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/main.c')
-rw-r--r--src/main.c26
1 files changed, 7 insertions, 19 deletions
diff --git a/src/main.c b/src/main.c
index 016aff1..ecefda4 100644
--- a/src/main.c
+++ b/src/main.c
@@ -69,7 +69,6 @@ void run(){
struct image *img = NULL;
XImage *ximg = NULL;
int redraw = 0;
- FILE *f = NULL;
for(;;){
XEvent event;
@@ -78,8 +77,6 @@ void run(){
break;
XNextEvent(display, &event);
switch(event.type){
- case MapNotify:
- break;
case ConfigureNotify:
if(width != event.xconfigure.width || height != event.xconfigure.height){
width = event.xconfigure.width;
@@ -138,18 +135,14 @@ void run(){
if(!img){
const char *firstimg = filename;
while(!img){
- if(f){
- fclose(f);
- f = NULL;
- }
- if(!(f = fopen(filename, "rb")))
- fprintf(stderr, "Cannot open '%s'\n", filename);
-
- if(f){
+ FILE *f;
+ if((f = fopen(filename, "rb"))){
if((img = imgopen(f)))
break;
else
fprintf(stderr, "Invalid format '%s'\n", filename);
+ }else{
+ fprintf(stderr, "Cannot open '%s'\n", filename);
}
filename = direction();
@@ -158,19 +151,14 @@ void run(){
exit(EXIT_FAILURE);
}
}
- img->buf = NULL;
+
setaspect(img->width, img->height);
- continue; /* make sure setaspect can do its thing */
- }
- if(!img->buf){
+
img->buf = malloc(3 * img->width * img->height);
if(img->fmt->read(img)){
fprintf(stderr, "read error!\n");
}
- if(f){
- fclose(f);
- f = NULL;
- }
+ img->fmt->close(img);
continue; /* Allow for some events to be read, read is slow */
}
ximg = getimage(img, width, height);