Overview
Comment: | Allow appending NULL to strings. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
1adab684f641392894c3bf15efa3317f |
User & Date: | js on 2012-09-30 03:40:38 |
Other Links: | manifest | tags |
Context
2013-06-08
| ||
09:47 | Use (void*)NULL instead of NULL in varargs. check-in: c9caa75847 user: js tags: trunk | |
2012-09-30
| ||
03:40 | Allow appending NULL to strings. check-in: 1adab684f6 user: js tags: trunk | |
03:20 | Work around malloc(0) returning NULL. check-in: 384257c4cc user: js tags: trunk | |
Changes
Modified src/stream.c from [f662e79d40] to [765c2b0a12].
︙ | ︙ | |||
116 117 118 119 120 121 122 | ret = cfw_create(cfw_string, NULL); if (ret == NULL) { free(ret_str); return NULL; } cfw_string_set_nocopy(ret, ret_str, ret_len); | | | 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | ret = cfw_create(cfw_string, NULL); if (ret == NULL) { free(ret_str); return NULL; } cfw_string_set_nocopy(ret, ret_str, ret_len); if (stream->cache_len > i + 1) { if ((new_cache = malloc( stream->cache_len - i - 1)) == NULL) return NULL; memcpy(new_cache, stream->cache + i + 1, stream->cache_len - i - 1); } else new_cache = cfw_strdup(""); |
︙ | ︙ | |||
203 204 205 206 207 208 209 | if (ret == NULL) { free(buf); free(ret_str); return NULL; } cfw_string_set_nocopy(ret, ret_str, ret_len); | | | 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | if (ret == NULL) { free(buf); free(ret_str); return NULL; } cfw_string_set_nocopy(ret, ret_str, ret_len); if (buf_len > i + 1) { new_cache = malloc(buf_len - i - 1); if (new_cache == NULL) { free(buf); return NULL; } memcpy(new_cache, buf + i + 1, buf_len - i - 1); |
︙ | ︙ |
Modified src/string.c from [61c34032c7] to [50cffdfc15].
︙ | ︙ | |||
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | str->len = len; } bool cfw_string_append(CFWString *str, CFWString *append) { char *new; if ((new = realloc(str->data, str->len + append->len + 1)) == NULL) return false; memcpy(new + str->len, append->data, append->len); new[str->len + append->len] = 0; str->data = new; str->len += append->len; return true; } bool cfw_string_append_c(CFWString *str, const char *append) { | > > > > | | > > > > | 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 | str->len = len; } bool cfw_string_append(CFWString *str, CFWString *append) { char *new; if (append == NULL) return true; if ((new = realloc(str->data, str->len + append->len + 1)) == NULL) return false; memcpy(new + str->len, append->data, append->len); new[str->len + append->len] = 0; str->data = new; str->len += append->len; return true; } bool cfw_string_append_c(CFWString *str, const char *append) { char *new; size_t append_len; if (append == NULL) return true; append_len = strlen(append); if ((new = realloc(str->data, str->len + append_len + 1)) == NULL) return false; memcpy(new + str->len, append, append_len); new[str->len + append_len] = 0; |
︙ | ︙ |