MCPcopy Create free account
hub / github.com/RedisGraph/RedisGraph / AR_RTRIM

Function AR_RTRIM

src/arithmetic/string_funcs/string_funcs.c:102–117  ·  view source on GitHub ↗

returns the original string with trailing whitespace removed.

Source from the content-addressed store, hash-verified

100
101// returns the original string with trailing whitespace removed.
102SIValue AR_RTRIM(SIValue *argv, int argc, void *private_data) {
103 if(SIValue_IsNull(argv[0])) return SI_NullVal();
104
105 char *str = argv[0].stringval;
106
107 size_t i = strlen(str);
108 while(i > 0 && str[i - 1] == ' ') {
109 i --;
110 }
111
112 char *trimmed = rm_malloc((i + 1) * sizeof(char));
113 strncpy(trimmed, str, i);
114 trimmed[i] = '\0';
115
116 return SI_TransferStringVal(trimmed);
117}
118
119// incase the parameter type is
120// 1. string - returns a string in which the order of all characters in the original string have been reversed.

Callers 1

AR_TRIMFunction · 0.85

Calls 4

SIValue_IsNullFunction · 0.85
SI_NullValFunction · 0.85
rm_mallocFunction · 0.85
SI_TransferStringValFunction · 0.85

Tested by

no test coverage detected