Changeset 579 for trunk/src/sh_mem.c


Ignore:
Timestamp:
May 14, 2023, 10:08:17 PM (16 months ago)
Author:
katerina
Message:

Fix for ticket #467 (memleak).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/sh_mem.c

    r516 r579  
    7777#endif
    7878
    79 /* define MEM_LOG to an absolute filename to enable this */
     79/* define MEM_LOG to enable this */
     80/* #define MEM_LOG 1 */
    8081#ifdef MEM_LOG
    8182void sh_mem_dump ()
     
    8384  memlist_t   * this = memlist;
    8485  FILE * fd;
    85 
     86  static unsigned int nr = 0;
     87  char filename[256];
     88
     89  snprintf(filename, sizeof(filename), "sh_mem_dump.%04u.%lu", nr, (unsigned long) sh.pid);
     90 
    8691  SH_MUTEX_RECURSIVE_INIT(mutex_mem);
    8792  SH_MUTEX_RECURSIVE_LOCK(mutex_mem);
    8893
    89   fd = fopen(MEM_LOG, "w");
     94  fd = fopen(filename, "w");
    9095  if (!fd)
    9196    {
    92       perror(MEM_LOG);
     97      perror(filename);
    9398      _exit(EXIT_FAILURE);
    9499    }
     
    103108
    104109  SH_MUTEX_RECURSIVE_UNLOCK(mutex_mem);
    105   _exit(EXIT_SUCCESS);
     110  ++nr;
     111  /* _exit(EXIT_SUCCESS); */
     112  return;
    106113}
    107114#else
Note: See TracChangeset for help on using the changeset viewer.