CoreFW  Diff

Differences From Artifact [316847ca63]:

To Artifact [f662e79d40]:


116
117
118
119
120
121
122
123
124

125
126
127


128
129
130
131
132
133
134
				ret = cfw_create(cfw_string, NULL);
				if (ret == NULL) {
					free(ret_str);
					return NULL;
				}
				cfw_string_set_nocopy(ret, ret_str, ret_len);

				new_cache = malloc(stream->cache_len - i - 1);
				if (new_cache == NULL)

					return NULL;
				memcpy(new_cache, stream->cache + i + 1,
				    stream->cache_len - i - 1);



				free(stream->cache);
				stream->cache = new_cache;
				stream->cache_len -= i + 1;

				return ret;
			}







|
|
>
|
|
|
>
>







116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
				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 > 0) {
					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("");

				free(stream->cache);
				stream->cache = new_cache;
				stream->cache_len -= i + 1;

				return ret;
			}
200
201
202
203
204
205
206

207
208
209
210
211
212



213
214
215
216
217
218
219
220
221
222
223

224

225
226
227
228
229





230
231
232
233
234
235
236
				if (ret == NULL) {
					free(buf);
					free(ret_str);
					return NULL;
				}
				cfw_string_set_nocopy(ret, ret_str, ret_len);


				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);




				free(stream->cache);
				stream->cache = new_cache;
				stream->cache_len = buf_len - i - 1;

				free(buf);
				return ret;
			}
		}

		/* There was no newline or \0 */

		new_cache = realloc(stream->cache, stream->cache_len + buf_len);

		if (new_cache == NULL) {
			free(buf);
			return NULL;
		}
		memcpy(new_cache + stream->cache_len, buf, buf_len);





		stream->cache = new_cache;
		stream->cache_len += buf_len;
	}
}

bool
cfw_stream_write(void *ptr, const void *buf, size_t len)







>
|
|
|
|
|
|
>
>
>











>
|
>
|
|
|
|
|
>
>
>
>
>







203
204
205
206
207
208
209
210
211
212
213
214
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
				if (ret == NULL) {
					free(buf);
					free(ret_str);
					return NULL;
				}
				cfw_string_set_nocopy(ret, ret_str, ret_len);

				if (buf_len - i - 1 > 0) {
					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);
				} else
					new_cache = cfw_strdup("");

				free(stream->cache);
				stream->cache = new_cache;
				stream->cache_len = buf_len - i - 1;

				free(buf);
				return ret;
			}
		}

		/* There was no newline or \0 */
		if (stream->cache_len + buf_len > 0) {
			new_cache = realloc(stream->cache,
			    stream->cache_len + buf_len);
			if (new_cache == NULL) {
				free(buf);
				return NULL;
			}
			memcpy(new_cache + stream->cache_len, buf, buf_len);
		} else {
			free(stream->cache);
			new_cache = cfw_strdup("");
		}

		stream->cache = new_cache;
		stream->cache_len += buf_len;
	}
}

bool
cfw_stream_write(void *ptr, const void *buf, size_t len)