|
17 | 17 | #include "stats.h"
|
18 | 18 | #include "util/arr_rm_alloc.h"
|
19 | 19 | #include "util/dict.h"
|
| 20 | +#include "util/string_utils.h" |
20 | 21 | #include <pthread.h>
|
21 | 22 |
|
22 | 23 | RedisModuleType *RedisAI_ModelType = NULL;
|
@@ -113,10 +114,7 @@ static void *RAI_Model_RdbLoad(struct RedisModuleIO *io, int encver) {
|
113 | 114 | RedisModuleString *stats_keystr =
|
114 | 115 | RedisModule_CreateStringFromString(stats_ctx, RedisModule_GetKeyNameFromIO(io));
|
115 | 116 | const char *stats_devicestr = RedisModule_Strdup(devicestr);
|
116 |
| - if (tag) { |
117 |
| - RedisModule_RetainString(NULL, tag); |
118 |
| - } |
119 |
| - RedisModuleString *stats_tag = tag; |
| 117 | + RedisModuleString *stats_tag = RAI_HoldString(NULL, tag); |
120 | 118 |
|
121 | 119 | model->infokey =
|
122 | 120 | RAI_AddStatsEntry(stats_ctx, stats_keystr, RAI_MODEL, backend, stats_devicestr, stats_tag);
|
@@ -325,8 +323,7 @@ RAI_Model *RAI_ModelCreate(RAI_Backend backend, const char *devicestr, RedisModu
|
325 | 323 |
|
326 | 324 | if (model) {
|
327 | 325 | if (tag) {
|
328 |
| - RedisModule_RetainString(NULL, tag); |
329 |
| - model->tag = tag; |
| 326 | + model->tag = RAI_HoldString(NULL, tag); |
330 | 327 | } else {
|
331 | 328 | model->tag = RedisModule_CreateString(NULL, "", 0);
|
332 | 329 | }
|
@@ -596,12 +593,12 @@ int RedisAI_Parse_ModelRun_RedisCommand(RedisModuleCtx *ctx, RedisModuleString *
|
596 | 593 | is_input = 1;
|
597 | 594 | outputs_flag_count = 1;
|
598 | 595 | } else {
|
599 |
| - RedisModule_RetainString(ctx, argv[argpos]); |
| 596 | + RedisModuleString *arg = RAI_HoldString(ctx, argv[argpos]); |
600 | 597 | if (is_input == 0) {
|
601 |
| - *inkeys = array_append(*inkeys, argv[argpos]); |
| 598 | + *inkeys = array_append(*inkeys, arg); |
602 | 599 | ninputs++;
|
603 | 600 | } else {
|
604 |
| - *outkeys = array_append(*outkeys, argv[argpos]); |
| 601 | + *outkeys = array_append(*outkeys, arg); |
605 | 602 | noutputs++;
|
606 | 603 | }
|
607 | 604 | }
|
|
0 commit comments