Changeset 136 for trunk/nom/src


Ignore:
Timestamp:
Dec 3, 2006, 10:08:56 AM (19 years ago)
Author:
cinc
Message:

Reviewed memory allocation functions.

Location:
trunk/nom/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/nom/src/nommemory.c

    r94 r136  
    4646#include <nomtk.h>
    4747
     48/* This tells us if memory allocation is done using the garbage collector */
     49extern gboolean bUseGC; /* Set during initialization */
     50
    4851NOMEXTERN nomToken NOMLINK NOMMalloc(ULONG size)
    4952{
     
    6366
    6467  if((memPtr=g_malloc(size*num + sizeof(ULONG)))==NULLHANDLE)
    65     return NULLHANDLE;
    66   memset(memPtr, 0, size*num + sizeof(ULONG));
     68    return NULLHANDLE; /* We won't end here because GLib just terminates the process :-/
     69                          A really sick idea imho. */
     70  if(!bUseGC)
     71    memset(memPtr, 0, size*num + sizeof(ULONG)); /* GC always returns zeroed memory */
     72
    6773  *memPtr=size;
    6874  memPtr++;
  • trunk/nom/src/nomtkinit.c

    r135 r136  
    6262/* Global class manager object */
    6363NOMClassMgr* NOMClassMgrObject; /* Referenced from different files */
    64 
     64gboolean bUseGC=FALSE; /* MArk if we use the garbage collector */
    6565
    6666/********************************************************/
     
    106106 g_mem_set_vtable(&vtbl);
    107107 fprintf(stderr, "   GC memory functions set for GLIB. (%s: %d)\n", __FILE__, __LINE__);
     108 bUseGC=TRUE;
    108109}
    109110
Note: See TracChangeset for help on using the changeset viewer.