Skip to content

Commit e98c974

Browse files
committed
implemented the context metadata cleanup mechanism
1 parent 0e7b86b commit e98c974

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

src/common/context.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,3 +261,12 @@ void printConfig(FILE *outFile) {
261261
}
262262
}
263263
}
264+
265+
void destroyContextMetadata(void) {
266+
struct context_metadata *s, *tmp;
267+
HASH_ITER(hh, ctx.metaMap, s, tmp) {
268+
HASH_DEL(ctx.metaMap, s);
269+
free(s);
270+
}
271+
ctx.metaMap = NULL;
272+
}

src/common/context.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,14 @@ void createContextMetadata(const char *name, const char *printName,
9393
context_source_t source, context_type_t type,
9494
void *value, int isFlag);
9595

96+
/*!
97+
* Cleanup context metadata
98+
*
99+
* Free all allocated memory in the context metadata hash table.
100+
* Call this when done using the context to prevent memory leaks.
101+
*/
102+
void destroyContextMetadata(void);
103+
96104
void updateIntContext(const char *name, int value, context_source_t source);
97105

98106
void updateCharContext(const char *name, const char *value,

src/sipnet/sipnet.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1888,4 +1888,6 @@ void cleanupModel() {
18881888
freeEventList();
18891889
closeEventOutFile();
18901890
}
1891+
1892+
destroyContextMetadata();
18911893
}

0 commit comments

Comments
 (0)