If realloc() fails (see // Here.), the memory occupied by zLine will not be de-allocated.
(http://www.c-faq.com/malloc/realloc.html) static char *local_getline(char *zPrompt, FILE *in){ char *zLine; int nLine; int n; nLine = 100; zLine = malloc( nLine ); if( zLine==0 ) return 0; n = 0; while( 1 ){ if( n+100>nLine ){ nLine = nLine*2 + 100; zLine = realloc(zLine, nLine); // Here. if( zLine==0 ) return 0; } if( fgets(&zLine[n], nLine - n, in)==0 ){ if( n==0 ){ free(zLine); return 0; } zLine[n] = 0; break; } while( zLine[n] ){ n++; } if( n>0 && zLine[n-1]=='\n' ){ n--; zLine[n] = 0; break; } } _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users