| 390 | } |
| 391 | |
| 392 | static inline void * |
| 393 | stats_realloc(void *ptr, size_t oldsz, size_t newsz, int flags) |
| 394 | { |
| 395 | |
| 396 | #ifdef _KERNEL |
| 397 | /* Default to M_NOWAIT if neither M_NOWAIT or M_WAITOK are set. */ |
| 398 | if (!(flags & (M_WAITOK | M_NOWAIT))) |
| 399 | flags |= M_NOWAIT; |
| 400 | ptr = realloc(ptr, newsz, M_STATS, flags); |
| 401 | #else /* ! _KERNEL */ |
| 402 | ptr = realloc(ptr, newsz); |
| 403 | if ((flags & M_ZERO) && ptr != NULL) { |
| 404 | if (oldsz == 0) |
| 405 | memset(ptr, '\0', newsz); |
| 406 | else if (newsz > oldsz) |
| 407 | memset(BLOB_OFFSET(ptr, oldsz), '\0', newsz - oldsz); |
| 408 | } |
| 409 | #endif /* _KERNEL */ |
| 410 | |
| 411 | return (ptr); |
| 412 | } |
| 413 | |
| 414 | static inline char * |
| 415 | stats_strdup(const char *s, |
no test coverage detected