mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
libsysprof-capture: Use libc string functions rather than GLib ones
Use `strcmp()` and `strdup()` rather than `g_strcmp0()` and `g_strdup()`. In the latter case, this makes no difference. In the former case it means we potentially need to do some additional `NULL` checks before calling it; although most of the call sites use fixed-length arrays, so no `NULL` check is needed. Signed-off-by: Philip Withnall <withnall@endlessm.com> Helps: #40
This commit is contained in:
@ -333,6 +333,19 @@ sysprof_capture_writer_flush_jitmap (SysprofCaptureWriter *self)
|
||||
return true;
|
||||
}
|
||||
|
||||
/* djb hash */
|
||||
static unsigned int
|
||||
str_hash (const char *str)
|
||||
{
|
||||
const uint8_t *p;
|
||||
uint32_t h = 5381;
|
||||
|
||||
for (p = (const uint8_t *) str; *p != '\0'; p++)
|
||||
h = (h << 5) + h + *p;
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
static bool
|
||||
sysprof_capture_writer_lookup_jitmap (SysprofCaptureWriter *self,
|
||||
const char *name,
|
||||
@ -345,7 +358,7 @@ sysprof_capture_writer_lookup_jitmap (SysprofCaptureWriter *self,
|
||||
assert (name != NULL);
|
||||
assert (addr != NULL);
|
||||
|
||||
hash = g_str_hash (name) % G_N_ELEMENTS (self->addr_hash);
|
||||
hash = str_hash (name) % G_N_ELEMENTS (self->addr_hash);
|
||||
|
||||
for (i = hash; i < G_N_ELEMENTS (self->addr_hash); i++)
|
||||
{
|
||||
@ -426,7 +439,7 @@ sysprof_capture_writer_insert_jitmap (SysprofCaptureWriter *self,
|
||||
assert (self->addr_buf_pos <= sizeof self->addr_buf);
|
||||
|
||||
/* Now place the address into the hashtable */
|
||||
hash = g_str_hash (str) % G_N_ELEMENTS (self->addr_hash);
|
||||
hash = str_hash (str) % G_N_ELEMENTS (self->addr_hash);
|
||||
|
||||
/* Start from the current hash bucket and go forward */
|
||||
for (i = hash; i < G_N_ELEMENTS (self->addr_hash); i++)
|
||||
|
||||
Reference in New Issue
Block a user