| 149 | } |
| 150 | |
| 151 | int pn_string_grow(pn_string_t *string, size_t capacity) |
| 152 | { |
| 153 | if (!string) return PN_ARG_ERR; |
| 154 | |
| 155 | bool grow = false; |
| 156 | while (string->capacity < (capacity*sizeof(char) + 1)) { |
| 157 | string->capacity *= 2; |
| 158 | grow = true; |
| 159 | } |
| 160 | |
| 161 | if (grow) { |
| 162 | char *growed = (char *) pni_mem_subreallocate(pn_class(string), string, string->bytes, string->capacity); |
| 163 | if (growed) { |
| 164 | string->bytes = growed; |
| 165 | } else { |
| 166 | return PN_ERR; |
| 167 | } |
| 168 | } |
| 169 | |
| 170 | return 0; |
| 171 | } |
| 172 | |
| 173 | int pn_string_setn(pn_string_t *string, const char *bytes, size_t n) |
| 174 | { |
no test coverage detected