struct session_slot_table *new_session_slot_table() { int i; struct session_slot_table *sst; sst = malloc(sizeof(*sst)); if (!sst) { return NULL; } sst->free_slots = new_bitset(SESSION_SLOT_TABLE_CAPACITY); if (!sst->free_slots) { free(sst); return NULL; } bs_set_all(sst->free_slots); for (i = 0; i < SESSION_SLOT_TABLE_CAPACITY; ++i) { sst->slots[i] = 1; } pthread_mutex_init(&sst->mutex, NULL); pthread_cond_init(&sst->slot_cv, NULL); sst->highest_used_slotid_plus1 = 0; sst->server_highest_slotid = SESSION_SLOT_TABLE_CAPACITY - 1; sst->target_highest_slotid = SESSION_SLOT_TABLE_CAPACITY - 1; return sst; }
static int lua_create_aoi_obj(lua_State *L){ luaRef_t *obj = calloc(1,sizeof(*obj)); *obj = toluaRef(L,1); aoi_object* o = calloc(1,sizeof(*o)); o->in_myscope = in_myscope; o->cb_enter = cb_enter; o->cb_leave = cb_leave; o->ud = obj; o->view_objs = new_bitset(4096); lua_pushlightuserdata(L,o); return 1; }