mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-07-24 13:12:03 +00:00
FS-11621: add switch_core_strndup
This commit is contained in:
@@ -269,9 +269,13 @@ SWITCH_DECLARE(char *) switch_core_perform_session_strdup(switch_core_session_t
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(char *) switch_core_perform_strdup(switch_memory_pool_t *pool, const char *todup, const char *file, const char *func, int line)
|
||||
{
|
||||
return switch_core_perform_strndup(pool, todup, todup ? strlen(todup) + 1 : 0, file, func, line);
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(char *) switch_core_perform_strndup(switch_memory_pool_t *pool, const char *todup, size_t len, const char *file, const char *func, int line)
|
||||
{
|
||||
char *duped = NULL;
|
||||
switch_size_t len;
|
||||
switch_assert(pool != NULL);
|
||||
|
||||
if (!todup) {
|
||||
@@ -287,8 +291,6 @@ SWITCH_DECLARE(char *) switch_core_perform_strdup(switch_memory_pool_t *pool, co
|
||||
#endif
|
||||
#endif
|
||||
|
||||
len = strlen(todup) + 1;
|
||||
|
||||
#ifdef DEBUG_ALLOC
|
||||
if (len > DEBUG_ALLOC_CUTOFF)
|
||||
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_CONSOLE, "%p Core Strdup Allocate %s %d\n",
|
||||
|
||||
Reference in New Issue
Block a user