trace throw error instead of assert in C

This commit is contained in:
云风
2013-09-16 13:01:37 +08:00
parent 36676afc03
commit 7263b3d0f9
2 changed files with 6 additions and 1 deletions

View File

@@ -399,6 +399,9 @@ static int
_trace_new(lua_State *L) {
struct trace_pool *p = lua_touserdata(L,1);
struct trace_info *t = trace_new(p);
if (t==NULL) {
return luaL_error(L, "Last trace didn't close");
}
lua_pushlightuserdata(L,t);
return 1;
}

View File

@@ -81,7 +81,9 @@ trace_release(struct trace_pool *p) {
struct trace_info *
trace_new(struct trace_pool *p) {
assert(p->current == NULL);
if (p->current) {
return NULL;
}
struct trace_info *t = malloc(sizeof(*t));
p->current = t;
t->session = 0;