Well.. this code seems cleaner than the older one and without memory leaks :)
"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)
> fatal ("`getcwd' failed: %s\n", strerror (errno));
> size *= 2;
> }
_______________________________________________
Emacs-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/emacs-devel