aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/lib/support/slice.c
diff options
context:
space:
mode:
authorGravatar David Garcia Quintas <dgq@google.com>2016-08-01 14:52:02 -0700
committerGravatar David Garcia Quintas <dgq@google.com>2016-08-01 14:52:02 -0700
commit62105352beec527b28313ad055264731461b5b61 (patch)
tree71ceefebcc7d36eccf34cf61cec164748802e39a /src/core/lib/support/slice.c
parent5dde14ce433ebfb6444e49d31764138a855ac997 (diff)
parent2507fef7379aa54cbced074f1b1e7ba3b53eae26 (diff)
Merge branch 'master' of github.com:grpc/grpc into lr_july_16
Diffstat (limited to 'src/core/lib/support/slice.c')
-rw-r--r--src/core/lib/support/slice.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/core/lib/support/slice.c b/src/core/lib/support/slice.c
index b9a7c77bda..8a2c0a9086 100644
--- a/src/core/lib/support/slice.c
+++ b/src/core/lib/support/slice.c
@@ -94,14 +94,16 @@ static void new_slice_unref(void *p) {
}
}
-gpr_slice gpr_slice_new(void *p, size_t len, void (*destroy)(void *)) {
+gpr_slice gpr_slice_new_with_user_data(void *p, size_t len,
+ void (*destroy)(void *),
+ void *user_data) {
gpr_slice slice;
new_slice_refcount *rc = gpr_malloc(sizeof(new_slice_refcount));
gpr_ref_init(&rc->refs, 1);
rc->rc.ref = new_slice_ref;
rc->rc.unref = new_slice_unref;
rc->user_destroy = destroy;
- rc->user_data = p;
+ rc->user_data = user_data;
slice.refcount = &rc->rc;
slice.data.refcounted.bytes = p;
@@ -109,6 +111,11 @@ gpr_slice gpr_slice_new(void *p, size_t len, void (*destroy)(void *)) {
return slice;
}
+gpr_slice gpr_slice_new(void *p, size_t len, void (*destroy)(void *)) {
+ /* Pass "p" to *destroy when the slice is no longer needed. */
+ return gpr_slice_new_with_user_data(p, len, destroy, p);
+}
+
/* gpr_slice_new_with_len support structures - we create a refcount object
extended with the user provided data pointer & destroy function */
typedef struct new_with_len_slice_refcount {