From b4cf6d10d5aa6b0fa0b3e3d1e99f9381cb62b4c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BChler?= Date: Sat, 12 Jul 2008 02:39:26 +0200 Subject: [PATCH] Fix a segfault --- src/control.c | 3 +++ src/control_parser.h | 3 ++- src/control_parser.rl | 4 +++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/control.c b/src/control.c index c94b85b..25a5725 100644 --- a/src/control.c +++ b/src/control.c @@ -79,6 +79,7 @@ trial *trial_new(const char *hostname, const char *port) { t->socket = sock; g_queue_init(&t->telemetry); t->map.solid_objects = g_array_new(FALSE, FALSE, sizeof(object)); + control_parser_new(t); return t; } @@ -86,6 +87,7 @@ void trial_reset_run(trial *t) { g_queue_foreach(&t->telemetry, telemetry_free, NULL); g_queue_clear(&t->telemetry); t->last_ts = 0; + control_parser_reset(t); } void trial_wait_for_start(trial *t) { @@ -139,5 +141,6 @@ void trial_free(trial *t) { g_queue_foreach(&t->telemetry, telemetry_free, NULL); g_queue_clear(&t->telemetry); g_array_free(t->map.solid_objects, TRUE); + control_parser_free(t); g_slice_free(trial, t); } diff --git a/src/control_parser.h b/src/control_parser.h index 1abe808..87f0321 100644 --- a/src/control_parser.h +++ b/src/control_parser.h @@ -15,7 +15,8 @@ struct control_parser_ctx { size_t mark; GString *tmp; - double d; + timestamp ts; + double x, y, r, dir; }; void control_parser_new(trial *t); diff --git a/src/control_parser.rl b/src/control_parser.rl index 483c861..a98fccb 100644 --- a/src/control_parser.rl +++ b/src/control_parser.rl @@ -38,9 +38,11 @@ static double extract_double(context *ctx, char *fpc) { max_speed = double >mark % { t->map.max_speed = extract_double(ctx, fpc); }; max_turn = double >mark % { t->map.max_turn = extract_double(ctx, fpc); }; max_hard_turn = double >mark % { t->map.max_hard_turn = extract_double(ctx, fpc); }; -# I dx dy time_limit min_sensor max_sensor max_speed max_turn max_hard_turn ; + init = "I" sp dx sp dy sp double sp min_sensor sp max_sensor sp max_speed sp max_turn sp max_hard_turn ";"; + + main := init @ done; }%%