Every call to this function, will make the string 'str' requiring * an additional call to RedisModule_FreeString() in order to really * free the string. Note that the automatic freeing of the string obtained * enabling modules automatic memory management counts for one * RedisModule_FreeString() call (it is just executed automatically). * * Normally you want to call this function when, at th
| 1264 | * |
| 1265 | * It is possible to call this function with a NULL context. */ |
| 1266 | void RM_RetainString(RedisModuleCtx *ctx, RedisModuleString *str) { |
| 1267 | if (ctx == NULL || !autoMemoryFreed(ctx,REDISMODULE_AM_STRING,str)) { |
| 1268 | /* Increment the string reference counting only if we can't |
| 1269 | * just remove the object from the list of objects that should |
| 1270 | * be reclaimed. Why we do that, instead of just incrementing |
| 1271 | * the refcount in any case, and let the automatic FreeString() |
| 1272 | * call at the end to bring the refcount back at the desired |
| 1273 | * value? Because this way we ensure that the object refcount |
| 1274 | * value is 1 (instead of going to 2 to be dropped later to 1) |
| 1275 | * after the call to this function. This is needed for functions |
| 1276 | * like RedisModule_StringAppendBuffer() to work. */ |
| 1277 | incrRefCount(str); |
| 1278 | } |
| 1279 | } |
| 1280 | |
| 1281 | /** |
| 1282 | * This function can be used instead of RedisModule_RetainString(). |
nothing calls this directly
no test coverage detected