2010-02-19 00:42:13 UTC
this is my for loop... I have a memory leak at _strdup()! what do I have to free in order to get rid of it?
for (linenr = 1; ; ++linenr) {
char *nlpos = NULL;
// Read a line of input and check to see if it ends with
// a newline character. Print a message if not.
char *gotline = fgets (buffer, sizeof buffer, stdin);
if (gotline == NULL) break;
nlpos = strchr (buffer, '\n');
if (nlpos != NULL) {
*nlpos = '\0';
head=insertascending(head, strdup(buffer));
}else {
xfprintf (stderr, "%s: %d: unterminated line: %s\n",
progname, linenr, buffer);
};
};