minor changes to string functions

master
Dvir Volk 8 years ago
parent 7b2ccbde29
commit fa182e29cd

@ -26,8 +26,20 @@ int RMUtil_StringEquals(RedisModuleString *s1, RedisModuleString *s2) {
size_t l1, l2; size_t l1, l2;
c1 = RedisModule_StringPtrLen(s1, &l1); c1 = RedisModule_StringPtrLen(s1, &l1);
c2 = RedisModule_StringPtrLen(s2, &l2); c2 = RedisModule_StringPtrLen(s2, &l2);
if (l1 != l2) return 0;
return strncmp(c1, c2, MAX(l1, l2)) == 0; return strncmp(c1, c2, l1) == 0;
}
int RMUtil_StringEqualsC(RedisModuleString *s1, const char *s2) {
const char *c1;
size_t l1, l2 = strlen(s2);
c1 = RedisModule_StringPtrLen(s1, &l1);
if (l1 != l2) return 0;
return strncmp(c1, s2, l1) == 0;
} }
void RMUtil_StringToLower(RedisModuleString *s) { void RMUtil_StringToLower(RedisModuleString *s) {

@ -12,6 +12,9 @@ RedisModuleString *RMUtil_CreateFormattedString(RedisModuleCtx *ctx, const char
/* Return 1 if the two strings are equal. Case *sensitive* */ /* Return 1 if the two strings are equal. Case *sensitive* */
int RMUtil_StringEquals(RedisModuleString *s1, RedisModuleString *s2); int RMUtil_StringEquals(RedisModuleString *s1, RedisModuleString *s2);
/* Return 1 if the string is equal to a C NULL terminated string. Case *sensitive* */
int RMUtil_StringEqualsC(RedisModuleString *s1, const char *s2);
/* Converts a redis string to lowercase in place without reallocating anything */ /* Converts a redis string to lowercase in place without reallocating anything */
void RMUtil_StringToLower(RedisModuleString *s); void RMUtil_StringToLower(RedisModuleString *s);

Loading…
Cancel
Save