Optimize memory allocation for symbols
justinethier opened this issue · 0 comments
justinethier commented
It seems like the strdup
and memcpy
are doing the same work twice for name
. Is there a more efficient way to implement this, in terms of both CPU and memory?
static object add_symbol_by_name(const char *name)
{
symbol_type sym = { {0}, symbol_tag, _strdup(name)};
symbol_type *psym = malloc(sizeof(symbol_type));
memcpy(psym, &sym, sizeof(symbol_type));
return add_symbol(psym);
}