dlsym, prepend the underscore and call dlsymIntern */
| 310 | |
| 311 | /* dlsym, prepend the underscore and call dlsymIntern */ |
| 312 | static 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 |
no test coverage detected