From 6e6ca8ad9a37ca5de6f80849e55d733d8d389d9e Mon Sep 17 00:00:00 2001 From: nekobit Date: Fri, 26 Aug 2022 18:20:54 +0000 Subject: [PATCH] Fiddling... FossilOrigin-Name: 7ac1a6ecafbc849e0510aeccf025ea07d7853f64eb89e87dc19046c8efa36a8c --- src/base_page.c | 1 + src/global_perl.h | 8 +++----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/base_page.c b/src/base_page.c index c6039fa..9bb501d 100644 --- a/src/base_page.c +++ b/src/base_page.c @@ -81,6 +81,7 @@ void render_base_page(struct base_page* page, FCGX_Request* req, struct session* mXPUSHs(newRV_noinc((SV*)perlify_notifications(notifs, notifs_len))); } else ARG_UNDEFINED(); + // Run function PERL_STACK_SCALAR_CALL("base_page"); diff --git a/src/global_perl.h b/src/global_perl.h index 38c31ab..6c544c6 100644 --- a/src/global_perl.h +++ b/src/global_perl.h @@ -23,10 +23,9 @@ #include // hv_stores(ssn_hv, "id", newSVpv(acct->id, 0)); -#define hvstores_str(hv, key, val) hv_stores((hv), key, ((val) ? newSVpv((val), 0) : &PL_sv_undef)) +#define hvstores_str(hv, key, val) if (val) { hv_stores((hv), key, newSVpv((val), 0)); } #define hvstores_int(hv, key, val) hv_stores((hv), key, newSViv((val))) -#define hvstores_ref(hv, key, val) hv_stores((hv), key, \ - ((val) ? newRV_noinc((SV* const)(val)) : &PL_sv_undef)) +#define hvstores_ref(hv, key, val) if (val) { hv_stores((hv), key, newRV_noinc((SV*)(val))); } /* Seeing all this shit littered in Treebird's code made me decide to write some macros */ #define PERL_STACK_INIT perl_lock(); \ @@ -49,9 +48,8 @@ #define PERLIFY_MULTI(type, types, mstype) AV* perlify_##types(const struct mstype* const types, size_t len) { \ if (!(types && len)) return NULL; \ AV* av = newAV(); \ - av_extend(av, len-1); \ for (size_t i = 0; i < len; ++i) \ - av_store(av, i, newRV_noinc((SV*)perlify_##type(types + i))); \ + av_push(av, newRV_noinc((SV*)perlify_##type(types + i))); \ return av; \ }