From 75c2358b6967c0148087638364b64da66667f8a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=99emysl=20Janouch?= Date: Wed, 2 Feb 2011 19:30:06 +0100 Subject: Extend LdPointArray. --- liblogdiag/ld-lua.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'liblogdiag/ld-lua.c') diff --git a/liblogdiag/ld-lua.c b/liblogdiag/ld-lua.c index 973de4e..b97b892 100644 --- a/liblogdiag/ld-lua.c +++ b/liblogdiag/ld-lua.c @@ -576,15 +576,14 @@ read_terminals (lua_State *L, int index, LdPointArray **terminals) { LdPointArray *points; size_t num_points; - unsigned i = 0; num_points = lua_objlen (L, index); - points = ld_point_array_new (num_points); + points = ld_point_array_sized_new (num_points); lua_pushnil (L); while (lua_next (L, index) != 0) { - g_assert (i < num_points); + g_assert (points->length < points->size); if (!lua_istable (L, -1) || lua_objlen (L, -1) != 2) goto read_terminals_fail; @@ -592,16 +591,16 @@ read_terminals (lua_State *L, int index, LdPointArray **terminals) lua_rawgeti (L, -1, 1); if (!lua_isnumber (L, -1)) goto read_terminals_fail; - points->points[i].x = lua_tonumber (L, -1); + points->points[points->length].x = lua_tonumber (L, -1); lua_pop (L, 1); lua_rawgeti (L, -1, 2); if (!lua_isnumber (L, -1)) goto read_terminals_fail; - points->points[i].y = lua_tonumber (L, -1); + points->points[points->length].y = lua_tonumber (L, -1); lua_pop (L, 2); - i++; + points->length++; } *terminals = points; return TRUE; -- cgit v1.2.3