diff options
author | Sanjay Ghemawat <sanjay@google.com> | 2016-07-21 09:32:06 -0700 |
---|---|---|
committer | Sanjay Ghemawat <sanjay@google.com> | 2016-07-21 09:32:06 -0700 |
commit | fca59fb2aa4a0be093d12162c763b8563ada4087 (patch) | |
tree | af2b40d6c32ed3272d5577203c4e2f7c7fed26be /include | |
parent | 76692bb28329bf10ca162a5e70083aa2650bcb7f (diff) |
Add gpr_slice_new_with_user_data.
gpr_slice_new_with_user_data is like gpr_slice_new, but allows the
caller to specify a distinct pointer to pass to the destroy function.
This is useful when the data is part of a larger data structure that
should be destroyed when the data is no longer needed.
Diffstat (limited to 'include')
-rw-r--r-- | include/grpc/impl/codegen/slice.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/include/grpc/impl/codegen/slice.h b/include/grpc/impl/codegen/slice.h index c684b7587d..dfc0a774fc 100644 --- a/include/grpc/impl/codegen/slice.h +++ b/include/grpc/impl/codegen/slice.h @@ -120,6 +120,14 @@ GPRAPI void gpr_slice_unref(gpr_slice s); passed in at destruction. */ GPRAPI gpr_slice gpr_slice_new(void *p, size_t len, void (*destroy)(void *)); +/* Equivalent to gpr_slice_new, but with a separate pointer that is + passed to the destroy function. This function can be useful when + the data is part of a larger structure that must be destroyed when + the data is no longer needed. */ +GPRAPI gpr_slice gpr_slice_new_with_user_data(void *p, size_t len, + void (*destroy)(void *), + void *user_data); + /* Equivalent to gpr_slice_new, but with a two argument destroy function that also takes the slice length. */ GPRAPI gpr_slice gpr_slice_new_with_len(void *p, size_t len, |