Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/common/context.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,3 +254,13 @@ void printConfig(FILE *outFile) {
}
}
}

void freeContextMetadata(void) {
struct context_metadata *s;
while (ctx.metaMap != NULL) {
s = ctx.metaMap;
HASH_DEL(ctx.metaMap, s); // NOLINT
free(s);
}
HASH_CLEAR(hh, ctx.metaMap);
}
9 changes: 9 additions & 0 deletions src/common/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@ void createContextMetadata(const char *name, const char *printName,
context_source_t source, context_type_t type,
void *value, int isFlag);

/*!
* Free all context metadata allocated during initContext()
*
* Iterates through ctx.metaMap hash table and frees all allocated
* context_metadata structures. Should be called during program
* cleanup.
*/
void freeContextMetadata(void);

void updateIntContext(const char *name, int value, context_source_t source);

void updateCharContext(const char *name, const char *value,
Expand Down
2 changes: 2 additions & 0 deletions src/sipnet/sipnet.c
Original file line number Diff line number Diff line change
Expand Up @@ -1974,4 +1974,6 @@ void cleanupModel() {
freeEventList();
closeEventOutFile();
}

freeContextMetadata();
}