MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / pkg_nt_str_dup

Function pkg_nt_str_dup

ut.h:871–893  ·  view source on GitHub ↗

* Make a copy of an str structure using pkg_malloc * + an additional '\0' byte, so you can make use of dst->s * * dst == src is allowed! */

Source from the content-addressed store, hash-verified

869 * dst == src is allowed!
870 */
871static inline int pkg_nt_str_dup(str* dst, const str* src)
872{
873 const str _src = *src;
874
875 if (!_src.s) {
876 memset(dst, 0, sizeof *dst);
877 return 0;
878 }
879
880 dst->s = pkg_malloc(_src.len + 1);
881 if (!dst->s) {
882 LM_ERR("no private memory left\n");
883 dst->len = 0;
884 if (dst == src)
885 *dst = _src;
886 return -1;
887 }
888
889 memcpy(dst->s, _src.s, _src.len);
890 dst->len = _src.len;
891 dst->s[_src.len] = '\0';
892 return 0;
893}
894
895static inline char *shm_strdup(const char *str)
896{

Callers 5

fixup_f_send_sockFunction · 0.70
fixup_nt_stringFunction · 0.70
mi_check_all_blacklistsFunction · 0.70
mi_check_blacklistFunction · 0.70
cdb_cjson_to_dictFunction · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected