diff options
Diffstat (limited to 'ext/unicorn_http/ext_help.h')
-rw-r--r-- | ext/unicorn_http/ext_help.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/ext/unicorn_http/ext_help.h b/ext/unicorn_http/ext_help.h index fec4f41..19f08c9 100644 --- a/ext/unicorn_http/ext_help.h +++ b/ext/unicorn_http/ext_help.h @@ -18,4 +18,12 @@ static void rb_18_str_set_len(VALUE str, long len) # define rb_str_set_len(str,len) rb_18_str_set_len(str,len) #endif +static inline int str_cstr_eq(VALUE val, const char *ptr, size_t len) +{ + return (RSTRING_LEN(val) == len && !memcmp(ptr, RSTRING_PTR(val), len)); +} + +#define STR_CSTR_EQ(val, const_str) \ + str_cstr_eq(val, const_str, sizeof(const_str) - 1) + #endif |