Fix a segfault

This commit is contained in:
Stefan Bühler 2008-07-12 02:39:26 +02:00
parent 9897ce5e22
commit b4cf6d10d5
3 changed files with 8 additions and 2 deletions

View File

@ -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);
}

View File

@ -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);

View File

@ -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;
}%%