diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2019-06-05 11:56:11 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2019-06-05 17:54:21 +0200 |
commit | 60e917fa7cb55b4f675110bae78df56cd49bd486 (patch) | |
tree | e54c4b49146ce50f035a04e5f985fb2c690a9c08 /src/erec.c | |
parent | 5db92ace9263ea1daa1d10c6f3a04ecc97317258 (diff) |
src: dynamic input_descriptor allocation
This patch introduces the input descriptor list, that stores the
existing input descriptor objects. These objects are now dynamically
allocated and release from scanner_destroy() path.
Follow up patches that decouple the parsing and the evaluation phases
require this for error reporting as described by b14572f72aac ("erec:
Fix input descriptors for included files"), this patch partially reverts
such partial.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/erec.c')
-rw-r--r-- | src/erec.c | 35 |
1 files changed, 1 insertions, 34 deletions
@@ -34,50 +34,17 @@ static const char * const error_record_names[] = { [EREC_ERROR] = "Error" }; -static void input_descriptor_destroy(const struct input_descriptor *indesc) -{ - if (indesc->location.indesc && - indesc->location.indesc->type != INDESC_INTERNAL) { - input_descriptor_destroy(indesc->location.indesc); - } - if (indesc->name) - xfree(indesc->name); - xfree(indesc); -} - -static struct input_descriptor *input_descriptor_dup(const struct input_descriptor *indesc) -{ - struct input_descriptor *dup_indesc; - - dup_indesc = xmalloc(sizeof(struct input_descriptor)); - *dup_indesc = *indesc; - - if (indesc->location.indesc && - indesc->location.indesc->type != INDESC_INTERNAL) - dup_indesc->location.indesc = input_descriptor_dup(indesc->location.indesc); - - if (indesc->name) - dup_indesc->name = xstrdup(indesc->name); - - return dup_indesc; -} - void erec_add_location(struct error_record *erec, const struct location *loc) { assert(erec->num_locations < EREC_LOCATIONS_MAX); erec->locations[erec->num_locations] = *loc; - erec->locations[erec->num_locations].indesc = input_descriptor_dup(loc->indesc); + erec->locations[erec->num_locations].indesc = loc->indesc; erec->num_locations++; } void erec_destroy(struct error_record *erec) { - unsigned int i; - xfree(erec->msg); - for (i = 0; i < erec->num_locations; i++) { - input_descriptor_destroy(erec->locations[i].indesc); - } xfree(erec); } |