Skip to content

Commit

Permalink
Add db__msg_store_free() for freeing stored messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
ralight committed Jul 10, 2020
1 parent e3e8dc4 commit 3e595d5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
31 changes: 18 additions & 13 deletions src/database.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,26 @@ void db__msg_store_add(struct mosquitto_db *db, struct mosquitto_msg_store *stor
}


void db__msg_store_remove(struct mosquitto_db *db, struct mosquitto_msg_store *store)
void db__msg_store_free(struct mosquitto_msg_store *store)
{
int i;

mosquitto__free(store->source_id);
mosquitto__free(store->source_username);
if(store->dest_ids){
for(i=0; i<store->dest_id_count; i++){
mosquitto__free(store->dest_ids[i]);
}
mosquitto__free(store->dest_ids);
}
mosquitto__free(store->topic);
mosquitto_property_free_all(&store->properties);
UHPA_FREE_PAYLOAD(store);
mosquitto__free(store);
}

void db__msg_store_remove(struct mosquitto_db *db, struct mosquitto_msg_store *store)
{
if(store->prev){
store->prev->next = store->next;
if(store->next){
Expand All @@ -205,18 +221,7 @@ void db__msg_store_remove(struct mosquitto_db *db, struct mosquitto_msg_store *s
db->msg_store_count--;
db->msg_store_bytes -= store->payloadlen;

mosquitto__free(store->source_id);
mosquitto__free(store->source_username);
if(store->dest_ids){
for(i=0; i<store->dest_id_count; i++){
mosquitto__free(store->dest_ids[i]);
}
mosquitto__free(store->dest_ids);
}
mosquitto__free(store->topic);
mosquitto_property_free_all(&store->properties);
UHPA_FREE_PAYLOAD(store);
mosquitto__free(store);
db__msg_store_free(store);
}


Expand Down
1 change: 1 addition & 0 deletions src/mosquitto_broker_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,7 @@ void db__msg_store_ref_inc(struct mosquitto_msg_store *store);
void db__msg_store_ref_dec(struct mosquitto_db *db, struct mosquitto_msg_store **store);
void db__msg_store_clean(struct mosquitto_db *db);
void db__msg_store_compact(struct mosquitto_db *db);
void db__msg_store_free(struct mosquitto_msg_store *store);
int db__message_reconnect_reset(struct mosquitto_db *db, struct mosquitto *context);
void sys_tree__init(struct mosquitto_db *db);
void sys_tree__update(struct mosquitto_db *db, int interval, time_t start_time);
Expand Down

0 comments on commit 3e595d5

Please sign in to comment.