summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/erec.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/src/erec.c b/src/erec.c
index 36032165..eacdd97a 100644
--- a/src/erec.c
+++ b/src/erec.c
@@ -33,15 +33,45 @@ static const char *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);
+ }
+ 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);
+
+ 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] = *loc;
+ erec->locations[erec->num_locations].indesc = input_descriptor_dup(loc->indesc);
+ erec->num_locations++;
}
static 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);
}