Originally Posted by
Salem
Mmm, all I get is
Go on holiday, ask for room 404, then hassle the check-in staff that you can't find it
Me too, oh well. @Richard: great idea to do this. I sure wish I had gotten some criticism when I wrote my first open source project. I have been tidying it up ever since. Check out the unique formatting style in this little gem:
Code:
char *linein (FILE *stream) { /* uses malloc */
int c=0;
char *line = NULL, buffer[1024], byte, kb=0, *tmp;
memset(buffer,0,1024);
if (Debug>2) { g_print("linein()..."); fflush(stdout); }
while (fread(&byte,1,1,stream)==1) {
buffer[c]=byte;
c++;
if (byte=='\n') break;
if (c==1024) {
kb++;
if (kb>1) { if (!(tmp=realloc(line,1024*kb))) { fprintf(stderr, "!!!%s linein() REALLOC FAILED, OUT OF MEMORY\n", Me);
return line; }
line=tmp; }
else { line=ec_malloc(strlen(buffer)+1); line[0]='\0'; }
strcat(line,buffer);
memset(buffer,0,1024);
c=0;
}
}
if (c==0) return line;
if (kb) { if (!(tmp=realloc(line,kb*1024+strlen(buffer)+1))) {
fprintf(stderr, "!!!%s linein() REALLOC FAILED, OUT OF MEMORY\n", Me); return line; }
line=tmp;
} else line=ec_malloc(strlen(buffer)+1);
strcat(line,buffer);
if (Debug>2) { g_print("%s",line); fflush(stdout); }
return line;
}
...from version 0.7.1. This goes on for 3-4000 lines. I actually have to avert my eyes when I see the list of globals.