static int lua_mutt_enter(lua_State *l)
{
mutt_debug(LL_DEBUG2, " * lua_mutt_enter()\n");
- struct Buffer token, err;
+ struct Buffer *err = mutt_buffer_pool_get();
+ struct Buffer *token = mutt_buffer_pool_get();
char *buf = mutt_str_strdup(lua_tostring(l, -1));
int rc = 0;
- mutt_buffer_init(&err);
- mutt_buffer_init(&token);
-
- err.dsize = 256;
- err.data = mutt_mem_malloc(err.dsize);
-
- if (mutt_parse_rc_line(buf, &token, &err))
+ if (mutt_parse_rc_line(buf, token, err))
{
- luaL_error(l, "NeoMutt error: %s", err.data);
+ luaL_error(l, "NeoMutt error: %s", mutt_b2s(err));
rc = -1;
}
else
{
- if (!lua_pushstring(l, err.data))
+ if (!lua_pushstring(l, mutt_b2s(err)))
handle_error(l);
else
rc++;
}
FREE(&buf);
- FREE(&err.data);
+ mutt_buffer_pool_release(&token);
+ mutt_buffer_pool_release(&err);
return rc;
}