diff options
author | Přemysl Janouch <p.janouch@gmail.com> | 2011-02-02 19:30:06 +0100 |
---|---|---|
committer | Přemysl Janouch <p.janouch@gmail.com> | 2011-02-02 23:53:38 +0100 |
commit | 75c2358b6967c0148087638364b64da66667f8a2 (patch) | |
tree | 4a7119d8f07b74f9d4c3beef8a7ec82b5871135e /liblogdiag/ld-lua.c | |
parent | f864693f1bac4617f1ae8e42cd847ccf5e57055f (diff) | |
download | logdiag-75c2358b6967c0148087638364b64da66667f8a2.tar.gz logdiag-75c2358b6967c0148087638364b64da66667f8a2.tar.xz logdiag-75c2358b6967c0148087638364b64da66667f8a2.zip |
Extend LdPointArray.
Diffstat (limited to 'liblogdiag/ld-lua.c')
-rw-r--r-- | liblogdiag/ld-lua.c | 11 |
1 files changed, 5 insertions, 6 deletions
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; |