summaryrefslogtreecommitdiff
path: root/src/lwp.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2007-12-02 19:59:16 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2007-12-02 20:01:03 +0000
commit1fad4eab5ab73563e36c60eedddd090eb0f893dc (patch)
tree13513a7570ea166a46bf109edd1ba860cccc0ed0 /src/lwp.c
parent67a456891b99d8ec352a3fc4851c111302a689ae (diff)
Represent an allocator using an integer instead of its address.
Diffstat (limited to 'src/lwp.c')
-rw-r--r--src/lwp.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/lwp.c b/src/lwp.c
index a52b66d..4e33115 100644
--- a/src/lwp.c
+++ b/src/lwp.c
@@ -43,6 +43,7 @@ struct _lwp_allocator {
struct _lwp_allocator *ht_next;
gulong hash;
+ guint key;
guint n_ips;
gpointer ips[0];
};
@@ -57,6 +58,7 @@ static pthread_mutex_t event_mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
static LWP_Allocator *pending_allocators;
static LWP_Allocator *allocator_ht[31627];
+static guint allocator_key;
static LWP_Symbol *pending_ips;
static LWP_IP *ip_ht[6247];
@@ -207,7 +209,7 @@ _lwp_write_events (const LWP_EventRecord *events, guint n_events)
goto CLEAN_SK;
for (A = pending_allocators; A != NULL; A = A->next) {
- if (! _lwp_writen (sk, &A, sizeof (A)) ||
+ if (! _lwp_writen (sk, &A->key, sizeof (A->key)) ||
! _lwp_writen (sk, &A->n_ips, sizeof (A->n_ips)) ||
! _lwp_writen (sk, A->ips, sizeof (A->ips[0]) * A->n_ips))
{
@@ -330,7 +332,7 @@ _lwp_add_ip (gconstpointer eip)
}
-static LWP_Allocator *
+static guint
_lwp_allocator_alloc (gpointer *ips, guint n_ips, gulong hash)
{
LWP_Allocator *A;
@@ -338,6 +340,7 @@ _lwp_allocator_alloc (gpointer *ips, guint n_ips, gulong hash)
A = _lwp_perm_alloc (sizeof (LWP_Allocator) + sizeof(gpointer) * n_ips);
+ A->key = ++allocator_key;
A->hash = hash;
A->n_ips = n_ips;
memcpy (A->ips, ips, sizeof (gpointer) * n_ips);
@@ -353,7 +356,7 @@ _lwp_allocator_alloc (gpointer *ips, guint n_ips, gulong hash)
for (n = 0; n < n_ips; n++)
_lwp_add_ip (ips[n]);
- return A;
+ return A->key;
}
static gulong
@@ -387,7 +390,7 @@ _lwp_allocator_equal (LWP_Allocator *A, gpointer *ips, guint n_ips, gulong hash)
return TRUE;
}
-static LWP_Allocator *
+static guint
_lwp_add_allocator (gpointer *ips, guint n_ips)
{
LWP_Allocator *A;
@@ -402,7 +405,7 @@ _lwp_add_allocator (gpointer *ips, guint n_ips)
}
if (A != NULL)
- return A;
+ return A->key;
return _lwp_allocator_alloc (ips, n_ips, hash);
}
@@ -424,7 +427,7 @@ _lwp_record_event (LWP_EventType type, const LWP_Event *ev)
events[n_events].event = *ev;
if (type == LWP_INIT || type == LWP_FINI) {
- events[n_events].allocator = NULL;
+ events[n_events].allocator = 0;
} else {
gpointer stack_ips[1024 / sizeof (gpointer)], *ips;
guint n_ips, max_ips;