diff options
author | Julien Dessaux | 2019-09-12 18:01:14 +0200 |
---|---|---|
committer | Julien Dessaux | 2019-09-12 18:01:14 +0200 |
commit | 0bc24859aeca6a4e0d34f05b60b27250b1253ddd (patch) | |
tree | 4aeb8a1c304a80d4ed7c18491fde2e5d54b47451 | |
parent | Fixed code flow with memory free (diff) | |
download | rocket-cli-client-0bc24859aeca6a4e0d34f05b60b27250b1253ddd.tar.gz rocket-cli-client-0bc24859aeca6a4e0d34f05b60b27250b1253ddd.tar.bz2 rocket-cli-client-0bc24859aeca6a4e0d34f05b60b27250b1253ddd.zip |
Changed subscription id to rid
Diffstat (limited to '')
-rw-r--r-- | common/subscriptions.c | 14 | ||||
-rw-r--r-- | common/subscriptions.h | 4 | ||||
-rw-r--r-- | restapi/subscriptions.c | 6 |
3 files changed, 12 insertions, 12 deletions
diff --git a/common/subscriptions.c b/common/subscriptions.c index 0874cb0..9c8c345 100644 --- a/common/subscriptions.c +++ b/common/subscriptions.c @@ -1,16 +1,16 @@ #include "subscriptions.h" -void common_subscription_add(struct subscription** subscriptions, const char* id, const char* name, enum subscription_type type, size_t unread) +void common_subscription_add(struct subscription** subscriptions, const char* rid, const char* name, enum subscription_type type, size_t unread) { - struct subscription * subscription = common_subscription_new(id, name, type, unread); - HASH_ADD_KEYPTR(hh, *subscriptions, subscription->id, strlen(id), subscription); + struct subscription * subscription = common_subscription_new(rid, name, type, unread); + HASH_ADD_KEYPTR(hh, *subscriptions, subscription->rid, strlen(rid), subscription); } -struct subscription* common_subscription_new(const char* id, const char* name, enum subscription_type type, size_t unread) +struct subscription* common_subscription_new(const char* rid, const char* name, enum subscription_type type, size_t unread) { struct subscription* subscription = malloc(sizeof(struct subscription)); - subscription->id = malloc(strlen(id) + 1); - strcpy(subscription->id, id); + subscription->rid = malloc(strlen(rid) + 1); + strcpy(subscription->rid, rid); subscription->name = malloc(strlen(name) + 1); strcpy(subscription->name, name); subscription->type = type; @@ -24,7 +24,7 @@ void common_subscriptions_free(struct subscription* subscriptions) HASH_ITER(hh, subscriptions, sub, tmp) { HASH_DEL(subscriptions, sub); - free(sub->id); + free(sub->rid); free(sub->name); free(sub); } diff --git a/common/subscriptions.h b/common/subscriptions.h index a152345..0ade221 100644 --- a/common/subscriptions.h +++ b/common/subscriptions.h @@ -14,7 +14,7 @@ enum subscription_type { }; struct subscription { - char* id; + char* rid; char* name; enum subscription_type type; size_t unread; @@ -22,7 +22,7 @@ struct subscription { }; void common_subscription_add(struct subscription** subscriptions, const char* id, const char* name, enum subscription_type type, size_t unread); -struct subscription* common_subscription_new(const char* id, const char* name, enum subscription_type type, size_t unread); +struct subscription* common_subscription_new(const char* rid, const char* name, enum subscription_type type, size_t unread); void common_subscriptions_free(struct subscription* subscriptions); void common_subscriptions_const_walk(const struct subscription* subscriptions, void (*func)(const struct subscription*)); diff --git a/restapi/subscriptions.c b/restapi/subscriptions.c index e41cf95..5a1abe6 100644 --- a/restapi/subscriptions.c +++ b/restapi/subscriptions.c @@ -37,13 +37,13 @@ restapi_subscriptions_get(void) } const cJSON* update = NULL; cJSON_ArrayForEach(update, updates) { - const cJSON* id = cJSON_GetObjectItemCaseSensitive(update, "_id"); + const cJSON* rid = cJSON_GetObjectItemCaseSensitive(update, "rid"); const cJSON* name = cJSON_GetObjectItemCaseSensitive(update, "name"); const cJSON* type = cJSON_GetObjectItemCaseSensitive(update, "t"); const cJSON* open = cJSON_GetObjectItemCaseSensitive(update, "open"); const cJSON* unread = cJSON_GetObjectItemCaseSensitive(update, "unread"); enum subscription_type etype; - if (!cJSON_IsString(id) || id->valuestring == NULL || !cJSON_IsString(name) || name->valuestring == NULL || !cJSON_IsString(type) || type->valuestring == NULL || !cJSON_IsTrue(open) || !cJSON_IsNumber(unread)) + if (!cJSON_IsString(rid) || rid->valuestring == NULL || !cJSON_IsString(name) || name->valuestring == NULL || !cJSON_IsString(type) || type->valuestring == NULL || !cJSON_IsTrue(open) || !cJSON_IsNumber(unread)) continue; if (strcmp(type->valuestring, "c") == 0) etype = SUBSCRIPTION_CHANNEL; @@ -55,7 +55,7 @@ restapi_subscriptions_get(void) fprintf(stderr, "Bug found : Unknown subscription type %s\n%s\n", type->valuestring, buffer); exit(999); } - common_subscription_add(&subscriptions, id->valuestring, name->valuestring, etype, unread->valueint); + common_subscription_add(&subscriptions, rid->valuestring, name->valuestring, etype, unread->valueint); } } get_json_cleanup: |