* Ensure "dst" matches the content of "src" without leaking memory * * Note: if you just want to dup a string, use "pkg_str_dup()" instead */
| 1025 | * Note: if you just want to dup a string, use "pkg_str_dup()" instead |
| 1026 | */ |
| 1027 | static inline int pkg_str_sync(str* dst, const str* src) |
| 1028 | { |
| 1029 | if (ZSTRP(src)) { |
| 1030 | if (dst->s) |
| 1031 | pkg_free(dst->s); |
| 1032 | memset(dst, 0, sizeof *dst); |
| 1033 | return 0; |
| 1034 | } |
| 1035 | |
| 1036 | if (pkg_str_extend(dst, src->len) != 0) { |
| 1037 | LM_ERR("oom\n"); |
| 1038 | return -1; |
| 1039 | } |
| 1040 | |
| 1041 | memcpy(dst->s, src->s, src->len); |
| 1042 | dst->len = src->len; |
| 1043 | return 0; |
| 1044 | } |
| 1045 | |
| 1046 | |
| 1047 |
no test coverage detected