diff options
author | 2017-01-04 09:52:38 -0800 | |
---|---|---|
committer | 2017-01-04 09:52:38 -0800 | |
commit | d191d31e4963b23255840ffe648290ab92d5e8bc (patch) | |
tree | 7d41f228315210f851fbdc83e8c4fe0e90bae298 /src/core/lib/support/string.c | |
parent | ef35bc33bdf7cc40ad3ef1fd254b3959ddd9fe6d (diff) | |
parent | 19cd772a6c4ac947b7a22f2de37daf61c6f9d80c (diff) |
Merge branch 'master' into tweak_slice_buffer
Diffstat (limited to 'src/core/lib/support/string.c')
-rw-r--r-- | src/core/lib/support/string.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/core/lib/support/string.c b/src/core/lib/support/string.c index f10a30f0fd..426fce28f8 100644 --- a/src/core/lib/support/string.c +++ b/src/core/lib/support/string.c @@ -275,3 +275,15 @@ int gpr_stricmp(const char *a, const char *b) { } while (ca == cb && ca && cb); return ca - cb; } + +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; +} |