aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
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
commitc2fb75f4e5971d4309c7a19b3e9f69e8111d03f0 (patch)
tree95715c2231f8287bb49f1fd691900b320107748d
parent66f3304bec026ead71e7f7992bef30e899518561 (diff)
downloadmirror-meh-c2fb75f4e5971d4309c7a19b3e9f69e8111d03f0.tar.gz
mirror-meh-c2fb75f4e5971d4309c7a19b3e9f69e8111d03f0.tar.bz2
mirror-meh-c2fb75f4e5971d4309c7a19b3e9f69e8111d03f0.zip
use GNU getline (temporary)
-rw-r--r--src/main.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/main.c b/src/main.c
index b2ed1e9..7b687c5 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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;