Changeset 135 for trunk/nom


Ignore:
Timestamp:
Dec 3, 2006, 9:59:44 AM (19 years ago)
Author:
cinc
Message:

Added garbage collection. To use it the GC init function must be called before using any GLib (or GTK) stuff.

Location:
trunk/nom
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/nom/Makefile

    r97 r135  
    2222BINDIR          =       ./../../../bin
    2323TOOLDIR         =       ./../tools
     24
     25GCLIB           =       ./../../../o/gc.a
    2426
    2527# Define objects to build
     
    6971
    7072
    71 $(BINDIR)/nobjtk.dll:    $(OBJDIR)/o.dep $(NOMOBJECTS) $(OBJECTS) ./exports.def
     73$(BINDIR)/nobjtk.dll:    $(OBJDIR)/o.dep $(NOMOBJECTS) $(OBJECTS) $(GCLIB) ./exports.def
    7274        @echo "[33;1;mLinking "$@"...[0;m"
    7375        cmd.exe /C create_vobjtk_def $(OBJDIR)/nobjtk.def
    74         $(CC) $(GCCLDFLAGS)  -o $@ $(OBJECTS) $(LIBS) $(OBJDIR)/nobjtk.def
     76        $(CC) $(GCCLDFLAGS)  -o $@ $(OBJECTS) $(LIBS) $(GCLIB) $(OBJDIR)/nobjtk.def
    7577        emximp -o $(OBJDIR)/$(basename $(notdir $@)).a $(OBJDIR)/nobjtk.def
    7678        @echo "[32;1;mDone linking "$@"...[0;m"
     
    132134        mkdir -p $(CLASSTEMPLATEDIR)
    133135
     136$(GCLIB):
     137        cp $(GCPATH)/.libs/gc.a $(GCLIB)
     138
    134139clean:
    135140        @cd $(OBJDIR) && rm *
  • trunk/nom/exports.def

    r94 r135  
    99        NOMFree         
    1010;       somIsObj               
     11
     12        nomInitGarbageCollection
    1113
    1214        nomPrintf               
  • trunk/nom/make.inc

    r94 r135  
    3636IDLCOMP         =       L:\svn-sources\nom\trunk\ORBit2-2.14.0\src\idl-compiler\.libs\orbit-idl-2.exe
    3737#IDLCOMP                =       L:/ORBit2-2.14.0/src/idl-compiler/.libs/orbit-idl-2.exe
     38
     39GCPATH          =       L:/svn-sources/nom/trunk/gc6.8
  • trunk/nom/src/nomtkinit.c

    r94 r135  
    5151   #include "nomtst2.h" */
    5252#include <nomclassmanager.h>
     53/* Garbage collector */
     54#include <gc.h>
    5355
    5456/* Undef if you want debugging msg from somEnvironmentNew() */
     
    6567/*   Toolkit functions, exported                        */
    6668/********************************************************/
     69
     70static gpointer  gcMalloc(gulong ulBytes)
     71{
     72  //printf("Hi there...\n");
     73  // return malloc(ulBytes);
     74  return (gpointer) GC_malloc(ulBytes);
     75}
     76
     77static gpointer  gcRealloc(gpointer mem, gulong ulBytes)
     78{
     79  // printf("...and here\n");
     80  //  return realloc(mem, ulBytes);
     81  return (gpointer) GC_realloc(mem, ulBytes);
     82}
     83
     84static void  gcFree(gpointer mem)
     85{
     86  //  printf("free(): %x\n", mem);
     87  return;
     88  GC_free(mem);
     89}
     90
     91/*
     92  This is called from the EMX wrapper to set the garbage collector
     93  memory functions as the GLIB default allocation function.
     94 */
     95void _System  nomInitGarbageCollection()
     96{
     97 GMemVTable vtbl={0};
     98
     99 /* Init the garbage collector */
     100 GC_init();
     101
     102 vtbl.malloc=(gpointer)gcMalloc;
     103 vtbl.realloc=(gpointer)gcRealloc;
     104 vtbl.free=(gpointer)gcFree;
     105
     106 g_mem_set_vtable(&vtbl);
     107 fprintf(stderr, "   GC memory functions set for GLIB. (%s: %d)\n", __FILE__, __LINE__);
     108}
    67109
    68110/*
Note: See TracChangeset for help on using the changeset viewer.