Skip to content
Snippets Groups Projects
Commit dbd36187 authored by Muxi Yan's avatar Muxi Yan
Browse files

Strategy change

parent 2a63e1b2
No related branches found
No related tags found
No related merge requests found
......@@ -51,19 +51,23 @@ static void maybe_embiggen(grpc_slice_buffer *sb) {
size_t slice_count = sb->count + slice_offset;
if (slice_count == sb->capacity) {
sb->capacity = GROW(sb->capacity);
GPR_ASSERT(sb->capacity > slice_count);
if (sb->base_slices == sb->inlined) {
sb->base_slices = gpr_malloc(sb->capacity * sizeof(grpc_slice));
memcpy(sb->base_slices, sb->inlined, slice_count * sizeof(grpc_slice));
sb->slices = sb->base_slices + slice_offset;
if (sb->base_slices != sb->slices) {
/* Make room by moving elements if there's still space unused */
memmove(sb->base_slices, sb->slices, sb->count * sizeof(grpc_slice));
sb->slices = sb->base_slices;
} else {
if (sb->base_slices != sb->slices) {
memmove(sb->base_slices, sb->slices, sb->count * sizeof(grpc_slice));
/* Allocate more memory if no more space is available */
sb->capacity = GROW(sb->capacity);
GPR_ASSERT(sb->capacity > slice_count);
if (sb->base_slices == sb->inlined) {
sb->base_slices = gpr_malloc(sb->capacity * sizeof(grpc_slice));
memcpy(sb->base_slices, sb->inlined, slice_count * sizeof(grpc_slice));
} else {
sb->base_slices =
gpr_realloc(sb->base_slices, sb->capacity * sizeof(grpc_slice));
}
sb->base_slices =
gpr_realloc(sb->base_slices, sb->capacity * sizeof(grpc_slice));
sb->slices = sb->base_slices;
sb->slices = sb->base_slices + slice_offset;
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment