Add FLAG_ALLOCATED_PAYLOAD to tell freeMessage() to also free the payload buffer. Don't free the message itself in freeMessage() because it's always stack allocated
This commit is contained in:
parent
b081b155cf
commit
fb40201672
2 changed files with 6 additions and 1 deletions
|
|
@ -16,6 +16,7 @@
|
||||||
#define FLAG_ALLOCATED_OPTION_FIELDS 0x1
|
#define FLAG_ALLOCATED_OPTION_FIELDS 0x1
|
||||||
#define FLAG_ALLOCATED_MESSAGE_BUFFER 0x2
|
#define FLAG_ALLOCATED_MESSAGE_BUFFER 0x2
|
||||||
#define FLAG_ALLOCATED_OPTION_ITEMS 0x4
|
#define FLAG_ALLOCATED_OPTION_ITEMS 0x4
|
||||||
|
#define FLAG_ALLOCATED_PAYLOAD 0x8
|
||||||
|
|
||||||
/* Linked List to store the options */
|
/* Linked List to store the options */
|
||||||
typedef struct _OPTION_ITEM {
|
typedef struct _OPTION_ITEM {
|
||||||
|
|
|
||||||
|
|
@ -353,5 +353,9 @@ void freeMessage(PRTSP_MESSAGE msg){
|
||||||
if (msg->flags & FLAG_ALLOCATED_OPTION_ITEMS){
|
if (msg->flags & FLAG_ALLOCATED_OPTION_ITEMS){
|
||||||
freeOptionList(msg->options);
|
freeOptionList(msg->options);
|
||||||
}
|
}
|
||||||
free(msg);
|
|
||||||
|
/* If we've allocated the payload */
|
||||||
|
if (msg->flags & FLAG_ALLOCATED_PAYLOAD) {
|
||||||
|
free(msg->payload);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue