add data_free callback
This commit is contained in:
parent
93181d2cc4
commit
a691637343
@ -81,10 +81,16 @@ typedef struct {
|
|||||||
#define DATA_PTR(branch) \
|
#define DATA_PTR(branch) \
|
||||||
((char *)branch->data + branch->lookup->offset)
|
((char *)branch->data + branch->lookup->offset)
|
||||||
|
|
||||||
|
static void data_free(void *data)
|
||||||
|
{
|
||||||
|
free(data);
|
||||||
|
}
|
||||||
|
|
||||||
struct ptql_branch_t {
|
struct ptql_branch_t {
|
||||||
ptql_lookup_t *lookup;
|
ptql_lookup_t *lookup;
|
||||||
void *data;
|
void *data;
|
||||||
unsigned int data_size;
|
unsigned int data_size;
|
||||||
|
void (*data_free)(void *);
|
||||||
unsigned int flags;
|
unsigned int flags;
|
||||||
unsigned int op_flags;
|
unsigned int op_flags;
|
||||||
union {
|
union {
|
||||||
@ -422,7 +428,7 @@ static int ptql_branch_list_destroy(sigar_t *sigar,
|
|||||||
&branches->data[i];
|
&branches->data[i];
|
||||||
|
|
||||||
if (branch->data_size && branch->data) {
|
if (branch->data_size && branch->data) {
|
||||||
free(branch->data);
|
branch->data_free(branch->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (branch->lookup &&
|
if (branch->lookup &&
|
||||||
@ -860,6 +866,7 @@ static int ptql_branch_add(ptql_parse_branch_t *parsed,
|
|||||||
branch = &branches->data[branches->number++];
|
branch = &branches->data[branches->number++];
|
||||||
branch->data = NULL;
|
branch->data = NULL;
|
||||||
branch->data_size = 0;
|
branch->data_size = 0;
|
||||||
|
branch->data_free = data_free;
|
||||||
branch->op_flags = parsed->op_flags;
|
branch->op_flags = parsed->op_flags;
|
||||||
|
|
||||||
op = ptql_op_code_get(parsed->op);
|
op = ptql_op_code_get(parsed->op);
|
||||||
|
Loading…
Reference in New Issue
Block a user