diff options
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 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; +} |