MCPcopy Create free account
hub / github.com/aboutcode-org/scancode-toolkit / dlsym

Function dlsym

tests/licensedcode/data/perf/udll.cxx:312–339  ·  view source on GitHub ↗

dlsym, prepend the underscore and call dlsymIntern */

Source from the content-addressed store, hash-verified

310
311/* dlsym, prepend the underscore and call dlsymIntern */
312static void *dlsym(void *handle, const char *symbol)
313{
314 static char undersym[257]; /* Saves calls to malloc(3) */
315 int sym_len = strlen(symbol);
316 void *value = NULL;
317 char *malloc_sym = NULL;
318
319 if (sym_len < 256)
320 {
321 snprintf(undersym, 256, "_%s", symbol);
322 value = dlsymIntern(handle, undersym);
323 }
324 else
325 {
326 malloc_sym = malloc(sym_len + 2);
327 if (malloc_sym)
328 {
329 sprintf(malloc_sym, "_%s", symbol);
330 value = dlsymIntern(handle, malloc_sym);
331 free(malloc_sym);
332 }
333 else
334 {
335 error(0, "Unable to allocate memory");
336 }
337 }
338 return value;
339}
340
341#else
342

Callers 1

GetFunctionMethod · 0.70

Calls 5

snprintfFunction · 0.85
dlsymInternFunction · 0.85
errorFunction · 0.70
mallocFunction · 0.50
freeFunction · 0.50

Tested by

no test coverage detected