cyclone icon indicating copy to clipboard operation
cyclone copied to clipboard

Optimize memory allocation for symbols

Open justinethier opened this issue 7 months ago • 0 comments

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);                                                       
} 

justinethier avatar Nov 28 '23 03:11 justinethier