"Alfred M. Szmidt" <[EMAIL PROTECTED]> writes: > and leaks memory. If the path is 400, you do 3 mallocs, but the > first two are never freed. > > That is just a small matter of moving the free outside the if. :-) > > int buf_size = 100; > while (1) > { > buf = (char *) xmalloc (buf_size); > if (getcwd (buf, buf_size) == buf) > break; > free (buf); > if (errno != ERANGE)
At this point errno may already be changed by free(). Why not just use xrealloc in the first place? Andreas. -- Andreas Schwab, SuSE Labs, [EMAIL PROTECTED] SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different." _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel