]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib: Update int and ll decoders with new MTYPE
authorDonald Lee <dlqs@gmx.com>
Mon, 9 Aug 2021 20:54:50 +0000 (04:54 +0800)
committerQuentin Young <qlyoung@qlyoung.net>
Tue, 21 Nov 2023 01:45:02 +0000 (20:45 -0500)
In the master branch a new MTYPE_SCRIPT_RES was created for
frrscript_get_results, lua_to decoders should use that

Signed-off-by: Donald Lee <dlqs@gmx.com>
lib/frrlua.c
tests/lib/test_frrscript.c

index 0e95e49c6fab84c514c7a2540a101e20749e1637..2cab1a5460f2f59d7d6ea32508899edebd1c5679 100644 (file)
@@ -274,7 +274,7 @@ void lua_decode_integerp(lua_State *L, int idx, int *num)
 
 void *lua_tointegerp(lua_State *L, int idx)
 {
-       int *num = XCALLOC(MTYPE_TMP, sizeof(int));
+       int *num = XCALLOC(MTYPE_SCRIPT_RES, sizeof(int));
 
        lua_decode_integerp(L, idx, num);
        return num;
@@ -348,7 +348,7 @@ void lua_decode_longlongp(lua_State *L, int idx, long long *num)
 
 void *lua_tolonglongp(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_longlongp(L, idx, num);
        return num;
index 7d4746cf3ea29d5a211690bf85e807efd7e4acdb..9698aeaa6cb11481844d1a006cee46e778ea7d51 100644 (file)
@@ -32,7 +32,7 @@ int main(int argc, char **argv)
        assert(result == 0);
        result = frrscript_call(fs, "bar", ("a", &a), ("b", &b));
        assert(result == 0);
-       long long *cptr = frrscript_get_result(fs, "bar", "c", lua_tointegerp);
+       long long *cptr = frrscript_get_result(fs, "bar", "c", lua_tolonglongp);
 
        /* a should not occur in the returned table in script */
        assert(a == 100);
@@ -47,7 +47,7 @@ int main(int argc, char **argv)
        result = frrscript_call(fs, "fact", ("n", &n));
        assert(result == 0);
        long long *ansptr =
-               frrscript_get_result(fs, "fact", "ans", lua_tointegerp);
+               frrscript_get_result(fs, "fact", "ans", lua_tolonglongp);
        assert(*ansptr == 120);
 
        /* check consecutive call + get_result without re-loading */