diff options
author | Muxi Yan <mxyan@google.com> | 2017-04-07 09:48:03 -0700 |
---|---|---|
committer | Muxi Yan <mxyan@google.com> | 2017-04-07 09:48:03 -0700 |
commit | 01499e051e3c55410ba09b39b9e6431de43f53b7 (patch) | |
tree | b4373e9c081b949747a66c1cde5c499bca7603c3 /src/core/lib | |
parent | d7a610bf545e03f49ef029f81b2b06a378869646 (diff) |
Revert "Fix a bug in slice_buffer:maybe_embiggen"
This reverts commit 9a0356b1e6d0f4fdd1e29a48596b91458b038f46.
Diffstat (limited to 'src/core/lib')
-rw-r--r-- | src/core/lib/slice/slice_buffer.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/core/lib/slice/slice_buffer.c b/src/core/lib/slice/slice_buffer.c index 451319c50d..9176dc8a42 100644 --- a/src/core/lib/slice/slice_buffer.c +++ b/src/core/lib/slice/slice_buffer.c @@ -46,6 +46,11 @@ #define GROW(x) (3 * (x) / 2) static void maybe_embiggen(grpc_slice_buffer *sb) { + if (sb->base_slices != sb->slices) { + memmove(sb->base_slices, sb->slices, sb->count * sizeof(grpc_slice)); + sb->slices = sb->base_slices; + } + /* How far away from sb->base_slices is sb->slices pointer */ size_t slice_offset = (size_t)(sb->slices - sb->base_slices); size_t slice_count = sb->count + slice_offset; @@ -56,15 +61,12 @@ static void maybe_embiggen(grpc_slice_buffer *sb) { 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; } else { - if (sb->base_slices != sb->slices) { - memmove(sb->base_slices, sb->slices, sb->count * 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; } } |