diff options
-rw-r--r-- | apps/buffering.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/apps/buffering.c b/apps/buffering.c index 48ef1bc6c0..213826fda0 100644 --- a/apps/buffering.c +++ b/apps/buffering.c | |||
@@ -243,10 +243,7 @@ buf_ridx == buf_widx means the buffer is empty. | |||
243 | alloc_all tells us if we must immediately be able to allocate data_size | 243 | alloc_all tells us if we must immediately be able to allocate data_size |
244 | returns a valid memory handle if all conditions for allocation are met. | 244 | returns a valid memory handle if all conditions for allocation are met. |
245 | NULL if there memory_handle itself cannot be allocated or if the | 245 | NULL if there memory_handle itself cannot be allocated or if the |
246 | data_size cannot be allocated and alloc_all is set. This function's | 246 | data_size cannot be allocated and alloc_all is set. */ |
247 | only potential side effect is to allocate space for the cur_handle | ||
248 | if it returns NULL. | ||
249 | */ | ||
250 | static struct memory_handle *add_handle(size_t data_size, bool can_wrap, | 247 | static struct memory_handle *add_handle(size_t data_size, bool can_wrap, |
251 | bool alloc_all) | 248 | bool alloc_all) |
252 | { | 249 | { |
@@ -263,6 +260,8 @@ static struct memory_handle *add_handle(size_t data_size, bool can_wrap, | |||
263 | mutex_lock(&llist_mutex); | 260 | mutex_lock(&llist_mutex); |
264 | mutex_lock(&llist_mod_mutex); | 261 | mutex_lock(&llist_mod_mutex); |
265 | 262 | ||
263 | new_widx = buf_widx; | ||
264 | |||
266 | if (cur_handle && cur_handle->filerem > 0) { | 265 | if (cur_handle && cur_handle->filerem > 0) { |
267 | /* the current handle hasn't finished buffering. We can only add | 266 | /* the current handle hasn't finished buffering. We can only add |
268 | a new one if there is already enough free space to finish | 267 | a new one if there is already enough free space to finish |
@@ -275,12 +274,12 @@ static struct memory_handle *add_handle(size_t data_size, bool can_wrap, | |||
275 | return NULL; | 274 | return NULL; |
276 | } else { | 275 | } else { |
277 | /* Allocate the remainder of the space for the current handle */ | 276 | /* Allocate the remainder of the space for the current handle */ |
278 | buf_widx = ringbuf_add(cur_handle->widx, cur_handle->filerem); | 277 | new_widx = ringbuf_add(cur_handle->widx, cur_handle->filerem); |
279 | } | 278 | } |
280 | } | 279 | } |
281 | 280 | ||
282 | /* align to 4 bytes up */ | 281 | /* align to 4 bytes up */ |
283 | new_widx = ringbuf_add(buf_widx, 3) & ~3; | 282 | new_widx = ringbuf_add(new_widx, 3) & ~3; |
284 | 283 | ||
285 | len = data_size + sizeof(struct memory_handle); | 284 | len = data_size + sizeof(struct memory_handle); |
286 | 285 | ||