* 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! */
| 869 | * dst == src is allowed! |
| 870 | */ |
| 871 | static 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 | |
| 895 | static inline char *shm_strdup(const char *str) |
| 896 | { |
no outgoing calls
no test coverage detected