diff options
author | "John Hawthorn ext:(%22) <jhawthor@uvic.ca> | 2008-12-31 14:08:49 -0800 |
---|---|---|
committer | "John Hawthorn ext:(%22) <jhawthor@uvic.ca> | 2008-12-31 14:08:49 -0800 |
commit | c2fb75f4e5971d4309c7a19b3e9f69e8111d03f0 (patch) | |
tree | 95715c2231f8287bb49f1fd691900b320107748d /src | |
parent | 66f3304bec026ead71e7f7992bef30e899518561 (diff) | |
download | mirror-meh-c2fb75f4e5971d4309c7a19b3e9f69e8111d03f0.tar.gz mirror-meh-c2fb75f4e5971d4309c7a19b3e9f69e8111d03f0.tar.bz2 mirror-meh-c2fb75f4e5971d4309c7a19b3e9f69e8111d03f0.zip |
use GNU getline (temporary)
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -1,4 +1,5 @@ +#define _GNU_SOURCE #include <unistd.h> #include <assert.h> @@ -256,11 +257,12 @@ void readlist(FILE *f){ while(!feof(f)){ images = realloc(images, lsize * sizeof(char *)); while(imageslen < lsize && !feof(f)){ - char *tmp = malloc(512); - if(fgets(tmp, 512, f)){ - tmp[strlen(tmp)-1] = '\0'; - images[imageslen] = tmp; - imageslen++; + char *line = NULL; + size_t slen = 0; + ssize_t read; + if((read = getline(&line, &slen, f)) > 0){ + line[read-1] = '\0'; + images[imageslen++] = line; } } lsize *= 2; |