Mail Archives: cygwin-developers/1998/08/26/09:58:32
I've committed these changes (and the revision sent in subsequent email).
Thank you for submitting them.
cgf
>From: Sergey Okhapkin <sos AT prospect DOT com DOT ru>
>Date: Wed, 26 Aug 1998 16:11:37 +0400
>
>Hi!
>
>include/sys/strace.h (_STRACE_MALLOC, malloc_printf): define.
>
>malloc.cc (malloc, free, realloc, calloc): malloc_printf added.
>
>path.cc (getcwd_inner): do realloc instead of malloc.
>
>syscalls.cc (_close): delete unix_path_name_, because fhandler_base
> destructor is never called!
>
>With these changes endless open/close loop runs without memory leaks.
>
>
>--- strace.h.orig Tue Apr 21 23:39:19 1998
>+++ strace.h Wed Aug 26 13:26:47 1998
>@@ -46,6 +46,7 @@
> #define _STRACE_NEWFILE 0x1000 /* open a new file for strace */
> #define _STRACE_EXITDUMP 0x4000 /* dump strace cache on exit */
> #define _STRACE_CACHE 0x8000 /* cache strace messages */
>+#define _STRACE_MALLOC 0x10000 /* trace malloc calls */
>
> /* Return the current strace mask. */
> int strace (void);
>@@ -72,6 +73,7 @@
> #define select_printf(fmt, args...) strace_printf_wrap(SELECT, fmt , ## args)
> #define wm_printf(fmt, args...) strace_printf_wrap(WM, fmt , ## args)
> #define sigproc_printf(fmt, args...) strace_printf_wrap(SIGP, fmt , ## args)
>+#define malloc_printf(fmt, args...) strace_printf_wrap(MALLOC, fmt , ## args)
>
> #ifdef __cplusplus
> }
>
>
>--- path.cc.orig Sat Aug 15 22:31:56 1998
>+++ path.cc Wed Aug 26 16:04:26 1998
>@@ -1242,7 +1242,8 @@ getcwd_inner (char *buf, size_t ulen, in
>
> size_t tlen = strlen (temp);
>
>- current_directory_posix_name = (char *) malloc (tlen + 1);
>+ current_directory_posix_name = (char *) realloc (
>+ current_directory_posix_name, tlen + 1);
> if (current_directory_posix_name != NULL)
> strcpy (current_directory_posix_name, temp);
>
>
>
>--- syscalls.cc.orig Wed Aug 26 15:49:21 1998
>+++ syscalls.cc Wed Aug 26 15:47:04 1998
>@@ -394,6 +394,7 @@ _close (int fd)
> else
> {
> res = myself->hmap[fd].h->close ();
>+ delete [] myself->hmap[fd].h->get_name ();
> myself->hmap.release (fd);
> }
> syscall_printf ("%d = close (%d)\n", res, fd);
- Raw text -