mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
Add a cache of the text section.
2006-10-08 Soren Sandmann <sandmann@redhat.com> * elfparser.c (struct ElfParser): Add a cache of the text section. * binparser.c (struct BinParser): Add a cache of a bin record to get rid of malloc()/free() overhead. * elfparser.c (struct ElfSym): Cache the size of the symbol
This commit is contained in:
committed by
Søren Sandmann Pedersen
parent
86810e63a5
commit
0cf636d8fe
23
binparser.c
23
binparser.c
@ -35,6 +35,9 @@ struct BinParser
|
||||
gsize offset;
|
||||
const guchar * data;
|
||||
gsize length;
|
||||
|
||||
gboolean cache_in_use;
|
||||
BinRecord cache;
|
||||
};
|
||||
|
||||
BinParser *
|
||||
@ -46,6 +49,7 @@ bin_parser_new (const guchar *data,
|
||||
parser->offset = 0;
|
||||
parser->data = data;
|
||||
parser->length = length;
|
||||
parser->cache_in_use = FALSE;
|
||||
|
||||
return parser;
|
||||
}
|
||||
@ -359,18 +363,33 @@ bin_parser_get_record (BinParser *parser,
|
||||
BinFormat *format,
|
||||
gsize offset)
|
||||
{
|
||||
BinRecord *record = g_new0 (BinRecord, 1);
|
||||
BinRecord *record;
|
||||
|
||||
if (!parser->cache_in_use)
|
||||
{
|
||||
parser->cache_in_use = TRUE;
|
||||
record = &(parser->cache);
|
||||
}
|
||||
else
|
||||
{
|
||||
record = g_new0 (BinRecord, 1);
|
||||
}
|
||||
|
||||
record->parser = parser;
|
||||
record->index = 0;
|
||||
record->offset = offset;
|
||||
record->format = format;
|
||||
|
||||
return record;
|
||||
}
|
||||
|
||||
void
|
||||
bin_record_free (BinRecord *record)
|
||||
{
|
||||
g_free (record);
|
||||
if (record == &(record->parser->cache))
|
||||
record->parser->cache_in_use = FALSE;
|
||||
else
|
||||
g_free (record);
|
||||
}
|
||||
|
||||
guint64
|
||||
|
||||
Reference in New Issue
Block a user