buflib_shrink use NULL to signal start isn't changing

Change-Id: Id3e86d3860b8ed860dc6dcbc394b1b8f9f3274b5
This commit is contained in:
William Wilgus 2023-01-12 20:52:29 -05:00 committed by William Wilgus
parent 719d48afc4
commit 40355caefd
5 changed files with 5 additions and 7 deletions

View file

@ -414,7 +414,7 @@ static void read_viewers_config_init(void)
goto out; goto out;
read_config_init(fd); read_config_init(fd);
core_shrink(strdup_handle, core_get_data(strdup_handle), strdup_cur_idx); core_shrink(strdup_handle, NULL, strdup_cur_idx);
out: out:
close(fd); close(fd);

View file

@ -1285,7 +1285,7 @@ static bool initialize_tagtree(void) /* also used when user selects 'Reload' in
add_event(PLAYBACK_EVENT_TRACK_BUFFER, tagtree_buffer_event); add_event(PLAYBACK_EVENT_TRACK_BUFFER, tagtree_buffer_event);
add_event(PLAYBACK_EVENT_TRACK_FINISH, tagtree_track_finish_event); add_event(PLAYBACK_EVENT_TRACK_FINISH, tagtree_track_finish_event);
core_shrink(tagtree_handle, core_get_data(tagtree_handle), tagtree_buf_used); core_shrink(tagtree_handle, NULL, tagtree_buf_used);
return true; return true;
} }

View file

@ -894,7 +894,7 @@ bool
buflib_shrink(struct buflib_context* ctx, int handle, void* new_start, size_t new_size) buflib_shrink(struct buflib_context* ctx, int handle, void* new_start, size_t new_size)
{ {
char* oldstart = buflib_get_data(ctx, handle); char* oldstart = buflib_get_data(ctx, handle);
char* newstart = new_start; char* newstart = new_start != NULL ? new_start : oldstart;
char* newend = newstart + new_size; char* newend = newstart + new_size;
/* newstart must be higher and new_size not "negative" */ /* newstart must be higher and new_size not "negative" */

View file

@ -172,12 +172,10 @@ static void finalize(struct chunk_alloc_header *hdr, struct chunk *chunk_array)
int handle = chunk_array[idx].handle; int handle = chunk_array[idx].handle;
struct buflib_context *ctx = hdr->context; struct buflib_context *ctx = hdr->context;
void* chunk_start = buflib_get_data(ctx, handle);
hdr->chunk_bytes_total -= hdr->chunk_bytes_free; hdr->chunk_bytes_total -= hdr->chunk_bytes_free;
hdr->chunk_bytes_free = 0; hdr->chunk_bytes_free = 0;
buflib_shrink(ctx, handle, chunk_start, hdr->chunk_bytes_total); buflib_shrink(ctx, handle, NULL, hdr->chunk_bytes_total);
logf("%s shrink hdr idx[%ld] offset[%ld]: new size: %ld", logf("%s shrink hdr idx[%ld] offset[%ld]: new size: %ld",
__func__, idx, chunk_array[idx].max_start_offset, hdr->chunk_bytes_total); __func__, idx, chunk_array[idx].max_start_offset, hdr->chunk_bytes_total);

View file

@ -217,7 +217,7 @@ int uimage_load(struct uimage_header* uh, size_t* out_size,
if(ret) if(ret)
goto err; goto err;
core_shrink(out_h, core_get_data(out_h), *out_size); core_shrink(out_h, NULL, *out_size);
ret = 0; ret = 0;
err: err: