Re: memory leak (well, kind of...) ?
Posted in 1993
andrew.shaw — — source: Informix-list mailing list archive (1991-1998)
From article <1spl0mINN67p@emory.mathcs.emory.edu>, by obelix.informix.com!johnl@emory.mathcs.emory.edu (Jonathan Leffler): > > Here's a simple program that eventually crashes on most machines: > > #include <string.h> > #include <stdlib.h> > int main() > { > void *v = 0; > long l = 0; > > while (l > 0) > { > v = realloc(v, l += 1024); > strcpy(v, "Abyssinia"); > } > return(0); > } > Actually it should never crash on any machine. Indeed, the whole program (as written) should optimize to "main() { return (0); }". > Just because it can be written doesn't make it sensible. No argument with that. Andrew Shaw andrew.shaw@att.com