util-src/table.c
author Kim Alvefur <zash@zash.se>
Fri, 03 Apr 2015 19:52:48 +0200
changeset 6618 8e4572a642cb
parent 6613 7c4cf87f4dff
child 7522 d278a770eddc
permissions -rw-r--r--
util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6613
7c4cf87f4dff util.table, Makefile: New C module that allows pre-allocation of tables to improve performance and decrease memory fragmentation
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
     1
#include <lua.h>
7c4cf87f4dff util.table, Makefile: New C module that allows pre-allocation of tables to improve performance and decrease memory fragmentation
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
     2
#include <lauxlib.h>
7c4cf87f4dff util.table, Makefile: New C module that allows pre-allocation of tables to improve performance and decrease memory fragmentation
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
     3
7c4cf87f4dff util.table, Makefile: New C module that allows pre-allocation of tables to improve performance and decrease memory fragmentation
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
     4
static int Lcreate_table(lua_State* L) {
7c4cf87f4dff util.table, Makefile: New C module that allows pre-allocation of tables to improve performance and decrease memory fragmentation
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
     5
	lua_createtable(L, luaL_checkinteger(L, 1), luaL_checkinteger(L, 2));
7c4cf87f4dff util.table, Makefile: New C module that allows pre-allocation of tables to improve performance and decrease memory fragmentation
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
     6
	return 1;
7c4cf87f4dff util.table, Makefile: New C module that allows pre-allocation of tables to improve performance and decrease memory fragmentation
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
     7
}
7c4cf87f4dff util.table, Makefile: New C module that allows pre-allocation of tables to improve performance and decrease memory fragmentation
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
     8
6618
8e4572a642cb util-src/*.c: astyle --indent=tab --brackets=attach --indent-switches --break-blocks --pad-oper --unpad-paren --add-brackets --align-pointer=type --lineend=linux
Kim Alvefur <zash@zash.se>
parents: 6613
diff changeset
     9
int luaopen_util_table(lua_State* L) {
6613
7c4cf87f4dff util.table, Makefile: New C module that allows pre-allocation of tables to improve performance and decrease memory fragmentation
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    10
	lua_newtable(L);
7c4cf87f4dff util.table, Makefile: New C module that allows pre-allocation of tables to improve performance and decrease memory fragmentation
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    11
	lua_pushcfunction(L, Lcreate_table);
7c4cf87f4dff util.table, Makefile: New C module that allows pre-allocation of tables to improve performance and decrease memory fragmentation
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    12
	lua_setfield(L, -2, "create");
7c4cf87f4dff util.table, Makefile: New C module that allows pre-allocation of tables to improve performance and decrease memory fragmentation
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    13
	return 1;
7c4cf87f4dff util.table, Makefile: New C module that allows pre-allocation of tables to improve performance and decrease memory fragmentation
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    14
}