aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorGravatar Craig Tiller <craig.tiller@gmail.com>2015-04-28 13:22:25 -0700
committerGravatar Craig Tiller <craig.tiller@gmail.com>2015-04-28 13:22:25 -0700
commitbae41c847f084fe64b5920f09d7ffbac579c507a (patch)
tree899d7e17c3a7fc03a1fabf6c49288c5d1f3b4163 /src/core
parent40158ed8560c9092c0f16c223f947527454e7f8a (diff)
Promote SWAP to GPR_SWAP
Diffstat (limited to 'src/core')
-rw-r--r--src/core/support/slice_buffer.c16
-rw-r--r--src/core/surface/call.c11
2 files changed, 7 insertions, 20 deletions
diff --git a/src/core/support/slice_buffer.c b/src/core/support/slice_buffer.c
index 1992eeef8b..91b5d8c98b 100644
--- a/src/core/support/slice_buffer.c
+++ b/src/core/support/slice_buffer.c
@@ -37,6 +37,7 @@
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
+#include <grpc/support/useful.h>
/* grow a buffer; requires GRPC_SLICE_BUFFER_INLINE_ELEMENTS > 1 */
#define GROW(x) (3 * (x) / 2)
@@ -161,17 +162,10 @@ void gpr_slice_buffer_reset_and_unref(gpr_slice_buffer *sb) {
sb->length = 0;
}
-#define SWAP(type, a, b) \
- do { \
- type x = a; \
- a = b; \
- b = x; \
- } while (0)
-
void gpr_slice_buffer_swap(gpr_slice_buffer *a, gpr_slice_buffer *b) {
- SWAP(size_t, a->count, b->count);
- SWAP(size_t, a->capacity, b->capacity);
- SWAP(size_t, a->length, b->length);
+ GPR_SWAP(size_t, a->count, b->count);
+ GPR_SWAP(size_t, a->capacity, b->capacity);
+ GPR_SWAP(size_t, a->length, b->length);
if (a->slices == a->inlined) {
if (b->slices == b->inlined) {
@@ -193,6 +187,6 @@ void gpr_slice_buffer_swap(gpr_slice_buffer *a, gpr_slice_buffer *b) {
memcpy(a->slices, b->inlined, a->count * sizeof(gpr_slice));
} else {
/* no inlining: easy swap */
- SWAP(gpr_slice *, a->slices, b->slices);
+ GPR_SWAP(gpr_slice *, a->slices, b->slices);
}
}
diff --git a/src/core/surface/call.c b/src/core/surface/call.c
index f358eb546a..d21bfaa592 100644
--- a/src/core/surface/call.c
+++ b/src/core/surface/call.c
@@ -238,13 +238,6 @@ struct grpc_call {
#define CALL_FROM_TOP_ELEM(top_elem) \
CALL_FROM_CALL_STACK(grpc_call_stack_from_top_element(top_elem))
-#define SWAP(type, x, y) \
- do { \
- type temp = x; \
- x = y; \
- y = temp; \
- } while (0)
-
static void do_nothing(void *ignored, grpc_op_error also_ignored) {}
static void set_deadline_alarm(grpc_call *call, gpr_timespec deadline);
static void call_on_done_recv(void *call, int success);
@@ -575,12 +568,12 @@ static void finish_live_ioreq_op(grpc_call *call, grpc_ioreq_op op,
call->request_data[GRPC_IOREQ_RECV_STATUS_DETAILS]);
break;
case GRPC_IOREQ_RECV_INITIAL_METADATA:
- SWAP(grpc_metadata_array, call->buffered_metadata[0],
+ GPR_SWAP(grpc_metadata_array, call->buffered_metadata[0],
*call->request_data[GRPC_IOREQ_RECV_INITIAL_METADATA]
.recv_metadata);
break;
case GRPC_IOREQ_RECV_TRAILING_METADATA:
- SWAP(grpc_metadata_array, call->buffered_metadata[1],
+ GPR_SWAP(grpc_metadata_array, call->buffered_metadata[1],
*call->request_data[GRPC_IOREQ_RECV_TRAILING_METADATA]
.recv_metadata);
break;