diff --git a/include/mosquitto_broker.h b/include/mosquitto_broker.h index 0e4a908c..6f1d79fd 100644 --- a/include/mosquitto_broker.h +++ b/include/mosquitto_broker.h @@ -570,6 +570,11 @@ mosq_EXPORT void *mosquitto_realloc(void *ptr, size_t size); */ mosq_EXPORT char *mosquitto_strdup(const char *s); +/* + * Function: mosquitto_strndup + */ +mosq_EXPORT char *mosquitto_strndup(const char *s, size_t n); + /* ========================================================================= * * Section: Utility Functions diff --git a/src/linker-macosx.syms b/src/linker-macosx.syms index 1a23d786..fea51df1 100644 --- a/src/linker-macosx.syms +++ b/src/linker-macosx.syms @@ -67,6 +67,7 @@ _mosquitto_set_clientid _mosquitto_set_username _mosquitto_strdup _mosquitto_string_to_property_info +_mosquitto_strndup _mosquitto_sub_matches_acl _mosquitto_sub_matches_acl_with_pattern _mosquitto_sub_topic_check diff --git a/src/linker.syms b/src/linker.syms index 79864a6c..9867f369 100644 --- a/src/linker.syms +++ b/src/linker.syms @@ -68,6 +68,7 @@ mosquitto_set_username; mosquitto_strdup; mosquitto_string_to_property_info; + mosquitto_strndup; mosquitto_sub_matches_acl; mosquitto_sub_matches_acl_with_pattern; mosquitto_sub_topic_check2; diff --git a/src/memory_public.c b/src/memory_public.c index 3d3a5619..57533a55 100644 --- a/src/memory_public.c +++ b/src/memory_public.c @@ -44,3 +44,8 @@ BROKER_EXPORT char *mosquitto_strdup(const char *s) { return mosquitto__strdup(s); } + +BROKER_EXPORT char *mosquitto_strndup(const char *s, size_t n) +{ + return mosquitto__strndup(s,n); +}