goto DONE; // "d" might not have been in returned table
assert(*d == 800);
- XFREE(MTYPE_TMP, d); // caller responsible for free
+ XFREE(MTYPE_SCRIPT_RES, d); // caller responsible for free
DONE:
frrscript_delete(fs);
void *lua_toprefix(lua_State *L, int idx)
{
- struct prefix *p = XCALLOC(MTYPE_TMP, sizeof(struct prefix));
+ struct prefix *p = XCALLOC(MTYPE_SCRIPT_RES, sizeof(struct prefix));
lua_decode_prefix(L, idx, p);
return p;
The returned data must always be copied off the stack and the copy must be
-allocated with ``MTYPE_TMP``. This way it is possible to unload the script
+allocated with ``MTYPE_SCRIPT_RES``. This way it is possible to unload the script
(destroy the state) without invalidating any references to values stored in it.
Note that it is the caller's responsibility to free the data.
#include "log.h"
#include "buffer.h"
+DEFINE_MTYPE(LIB, SCRIPT_RES, "Scripting results");
+
/* Lua stuff */
/*
void *lua_toprefix(lua_State *L, int idx)
{
- struct prefix *p = XCALLOC(MTYPE_TMP, sizeof(struct prefix));
+ struct prefix *p = XCALLOC(MTYPE_SCRIPT_RES, sizeof(struct prefix));
lua_decode_prefix(L, idx, p);
return p;
}
}
void *lua_tointerface(lua_State *L, int idx)
{
- struct interface *ifp = XCALLOC(MTYPE_TMP, sizeof(struct interface));
+ struct interface *ifp =
+ XCALLOC(MTYPE_SCRIPT_RES, sizeof(struct interface));
lua_decode_interface(L, idx, ifp);
return ifp;
void *lua_toinaddr(lua_State *L, int idx)
{
- struct in_addr *inaddr = XCALLOC(MTYPE_TMP, sizeof(struct in_addr));
+ struct in_addr *inaddr =
+ XCALLOC(MTYPE_SCRIPT_RES, sizeof(struct in_addr));
lua_decode_inaddr(L, idx, inaddr);
return inaddr;
}
void *lua_toin6addr(lua_State *L, int idx)
{
- struct in6_addr *in6addr = XCALLOC(MTYPE_TMP, sizeof(struct in6_addr));
+ struct in6_addr *in6addr =
+ XCALLOC(MTYPE_SCRIPT_RES, sizeof(struct in6_addr));
lua_decode_in6addr(L, idx, in6addr);
return in6addr;
}
void *lua_tosockunion(lua_State *L, int idx)
{
- union sockunion *su = XCALLOC(MTYPE_TMP, sizeof(union sockunion));
+ union sockunion *su =
+ XCALLOC(MTYPE_SCRIPT_RES, sizeof(union sockunion));
lua_decode_sockunion(L, idx, su);
return su;
void *lua_totimet(lua_State *L, int idx)
{
- time_t *t = XCALLOC(MTYPE_TMP, sizeof(time_t));
+ time_t *t = XCALLOC(MTYPE_SCRIPT_RES, sizeof(time_t));
lua_decode_timet(L, idx, t);
return t;
void *lua_tointegerp(lua_State *L, int idx)
{
- long long *num = XCALLOC(MTYPE_TMP, sizeof(long long));
+ long long *num = XCALLOC(MTYPE_SCRIPT_RES, sizeof(long long));
lua_decode_integerp(L, idx, num);
return num;
void *lua_tostringp(lua_State *L, int idx)
{
- char *string = XSTRDUP(MTYPE_TMP, lua_tostring(L, idx));
+ char *string = XSTRDUP(MTYPE_SCRIPT_RES, lua_tostring(L, idx));
return string;
}