diff options
author | 2017-01-03 09:23:09 -0800 | |
---|---|---|
committer | 2017-01-03 09:23:09 -0800 | |
commit | 36d374681ae254a4269fec3aa7e5dc7dbb43a768 (patch) | |
tree | e1c623279678c4db4a9324f4b8720822cffe18f0 /src/core/lib/support | |
parent | 702f93d3645055bd77181935c18f41a9de272c1e (diff) | |
parent | f2a66434e2e3f84830b4a26cc5e2badb5d943dfa (diff) |
Merge github.com:grpc/grpc into slice_with_exec_ctx
Diffstat (limited to 'src/core/lib/support')
-rw-r--r-- | src/core/lib/support/string.c | 12 | ||||
-rw-r--r-- | src/core/lib/support/string.h | 2 |
2 files changed, 14 insertions, 0 deletions
diff --git a/src/core/lib/support/string.c b/src/core/lib/support/string.c index 0dc55c2ca3..d20b86f7cf 100644 --- a/src/core/lib/support/string.c +++ b/src/core/lib/support/string.c @@ -301,3 +301,15 @@ void gpr_string_split(const char *input, const char *sep, char ***strs, } add_string_to_split(input, input + strlen(input), strs, nstrs, &capstrs); } + +void *gpr_memrchr(const void *s, int c, size_t n) { + if (s == NULL) return NULL; + char *b = (char *)s; + size_t i; + for (i = 0; i < n; i++) { + if (b[n - i - 1] == c) { + return &b[n - i - 1]; + } + } + return NULL; +} diff --git a/src/core/lib/support/string.h b/src/core/lib/support/string.h index 43ab4dc1be..c7fb0dbd14 100644 --- a/src/core/lib/support/string.h +++ b/src/core/lib/support/string.h @@ -121,6 +121,8 @@ char *gpr_strvec_flatten(gpr_strvec *strs, size_t *total_length); lower(a)==lower(b), >0 if lower(a)>lower(b) */ int gpr_stricmp(const char *a, const char *b); +void *gpr_memrchr(const void *s, int c, size_t n); + #ifdef __cplusplus } #endif |