Index: lib/Devel/LeakTrace.xs =================================================================== --- lib/Devel/LeakTrace.xs (revision 2264) +++ lib/Devel/LeakTrace.xs (working copy) @@ -3,7 +3,9 @@ #include "perl.h" #include "XSUB.h" +#if 0 #include +#endif typedef struct { char *file; @@ -11,9 +13,14 @@ } when; /* a few globals, never mind the mess for now */ +#if 0 GHashTable *used = NULL; GHashTable *new_used = NULL; +#endif +HV *used = NULL; +HV *new_used = NULL; + /* cargo from Devel::Leak - wander the arena, see what SVs live */ typedef long used_proc _((void *,SV *,long)); @@ -36,7 +43,73 @@ } /* end Devel::Leak cargo */ +/* Perl equivalents for some glib hash routines */ +/* + * Create a new hash, returning the hash value. The two parameters + * are ignored. + */ +static HV * +g_hash_table_new(void *p1, void *p2) { + return newHV(); +} + +/* + * Destroy a hash + */ +static void +g_hash_table_destroy(HV *hv) { + return hv_undef(hv); +} + +/* + * Given a hash and a key, return the value at that key. + */ +static void * +g_hash_table_lookup(HV *hv, SV *key) { + SV **svp; + char *k; + STRLEN klen; + void *val; + + k = SvPV(key, klen); + + svp = hv_fetch(hv, k, klen, 0); + val = (void *)SvIV(*svp); + + fprintf(stderr, "lookup(): key: '%s' -> %p\n", k, val); + + return (void *)val; +} + +static void +g_hash_table_insert(HV *hv, SV *key, void *val) { + char *k; + STRLEN klen; + when *w; + + w = (when *)val; + + k = SvPV(key, klen); + + fprintf(stderr, "insert(): key: '%s' -> %p\n", k, val); + fprintf(stderr, " : file -> %s\n", w->file); + fprintf(stderr, " : line -> %d\n", w->line); + + hv_store(hv, k, klen, newSViv(val), 0); + + return; +} + +typedef void foreach_func_t _((void *, void *, void *)); +#define gpointer void * + +static void +g_hash_table_foreach(HV *hv, foreach_func_t func, void *p1) { + /* Not implemented yet, pending getting the other functions working. */ + return; +} + static long note_used(void *p, SV* sv, long n) { @@ -97,6 +170,10 @@ if (!w) w = malloc(sizeof(when)); w->line = line; w->file = file; + + fprintf(stderr, "note_changes(): ptr: %p\n", w); + fprintf(stderr, " : file: %s\n", w->file); + fprintf(stderr, " : lint: %d\n", w->line); new_used = g_hash_table_new( NULL, NULL ); if (sv_apply_to_used( w, note_used, 0 )) w = NULL; if (used) g_hash_table_destroy( used ); Index: Build.PL =================================================================== --- Build.PL (revision 2264) +++ Build.PL (working copy) @@ -1,8 +1,8 @@ use strict; use Module::Build; -die "You don't seem to have glib installed (couldn't run glib-config --version), stopping\n" - unless `glib-config --version`; +#die "You don't seem to have glib installed (couldn't run glib-config --version), stopping\n" +# unless `glib-config --version`; my $build = Module::Build->new( module_name => "Devel::LeakTrace", @@ -12,8 +12,8 @@ 'Module::Build' => '0.19', # xs 'Test::More' => 0, }, - extra_compiler_flags => ''.`glib-config --cflags`, - extra_linker_flags => ''.`glib-config --libs`, +# extra_compiler_flags => ''.`glib-config --cflags`, +# extra_linker_flags => ''.`glib-config --libs`, create_makefile_pl => 'passthrough', );