Undef in main

FossilOrigin-Name: bad68ecf59eb93817413d54d47c7ca5a5bdb6b36dba0c9163dc7299b26c31f7a
This commit is contained in:
nekobit 2022-10-12 19:30:55 +00:00
parent a8ac0d3b4c
commit 682f6e0813
6 changed files with 26 additions and 28 deletions

View file

@ -2,8 +2,8 @@ CC ?= cc
GIT ?= git
MASTODONT_DIR = mastodont-c/
MASTODONT = $(MASTODONT_DIR)libmastodont.a
CFLAGS += -Wall -I $(MASTODONT_DIR)include/ -Wno-unused-variable -Wno-ignored-qualifiers -I/usr/include/ -I $(MASTODONT_DIR)/libs $(shell pkg-config --cflags libcurl libpcre2-8) `perl -MExtUtils::Embed -e ccopts`
LDFLAGS += -L$(MASTODONT_DIR) -lmastodont $(shell pkg-config --libs libcurl libpcre2-8) -lfcgi -lpthread `perl -MExtUtils::Embed -e ldopts`
CFLAGS += -Wall -I $(MASTODONT_DIR)include/ -Wno-unused-variable -Wno-ignored-qualifiers -I/usr/include/ -I $(MASTODONT_DIR)/libs $(shell pkg-config --cflags libcurl libpcre2-8) `perl -MExtUtils::Embed -e ccopts` -DDEBUGGING_MSTATS
LDFLAGS += -L$(MASTODONT_DIR) -lmastodont $(shell pkg-config --libs libcurl libpcre2-8) -lfcgi -lpthread `perl -MExtUtils::Embed -e ldopts` -DDEBUGGING_MSTATS
SRC = $(wildcard src/*.c)
OBJ = $(patsubst %.c,%.o,$(SRC))
HEADERS = $(wildcard src/*.h) config.h

View file

@ -47,6 +47,9 @@ sub base_page
notification => \&generate_notification,
);
to_template(\%vars, \$data->{'main.tt'});
my $ret = to_template(\%vars, \$data->{'main.tt'});
undef($notifs);
undef($main);
undef($ssn);
return $ret;
}

View file

@ -25,10 +25,9 @@ void content_about(PATH_ARGS)
PERL_STACK_INIT;
HV* session_hv = perlify_session(ssn);
XPUSHs(newRV_noinc((SV*)session_hv));
XPUSHs(newRV_noinc((SV*)template_files));
XPUSHs(newRV_inc((SV*)template_files));
PERL_STACK_SCALAR_CALL("meta::about");
char* dup = PERL_GET_STACK_EXIT;
struct base_page b = {
@ -39,7 +38,8 @@ void content_about(PATH_ARGS)
};
render_base_page(&b, req, ssn, api);
Safefree(dup);
free(dup);
// sv_free(session_hv);
}

View file

@ -84,26 +84,21 @@ void render_base_page(struct base_page* page, FCGX_Request* req, struct session*
}
else ARG_UNDEFINED();
SvREFCNT_dec(pl_notifs_rv);
SvREFCNT_dec(pl_notifs);
SvREFCNT_dec(content);
SvREFCNT_dec(real_ssn);
av_undef(pl_notifs);
sv_set_undef(pl_notifs_rv);
sv_set_undef(real_ssn);
sv_set_undef(content);
// Run function
PERL_STACK_SCALAR_CALL("base_page");
char* dup = PERL_GET_STACK_EXIT;
send_result(req, NULL, "text/html", dup, 0);
free(page->content);
/* av_clear(pl_notifs); */
/* av_undef(pl_notifs); */
/* sv_free(pl_notifs_rv); */
//hv_undef(real_ssn);
//sv_free(content);
mstdnt_cleanup_notifications(notifs, notifs_len);
mastodont_storage_cleanup(&storage);
Safefree(dup);
free(dup);
}
void send_result(FCGX_Request* req, char* status, char* content_type, char* data, size_t data_len)

View file

@ -23,9 +23,9 @@
#include <pthread.h>
// hv_stores(ssn_hv, "id", newSVpv(acct->id, 0));
#define hvstores_str(hv, key, val) if (val) { hv_stores((hv), key, sv_2mortal(newSVpv((val), 0))); }
#define hvstores_int(hv, key, val) hv_stores((hv), key, sv_2mortal(newSViv((val))))
#define hvstores_ref(hv, key, val) if (val) { hv_stores((hv), key, sv_2mortal(newRV_noinc((SV*)(val)))); }
#define hvstores_str(hv, key, val) if (val) { hv_stores((hv), key, Perl_newSVpv_share(aTHX_ (val), 0)); }
#define hvstores_int(hv, key, val) hv_stores((hv), key, newSViv((val)))
#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,8 +49,8 @@
if (!(types && len)) return NULL; \
AV* av = newAV(); \
for (size_t i = 0; i < len; ++i) \
av_push(av, sv_2mortal(newRV_noinc((SV*)sv_2mortal(perlify_##type(types + i))))); \
return sv_2mortal(av); \
av_push(av, newRV_noinc((SV*)perlify_##type(types + i))); \
return av; \
}

View file

@ -191,11 +191,11 @@ HV* perlify_notification(const struct mstdnt_notification* const notif)
hvstores_int(notif_hv, "created_at", notif->created_at);
hvstores_str(notif_hv, "emoji", notif->emoji);
hvstores_str(notif_hv, "type", mstdnt_notification_t_to_str(notif->type));
hvstores_ref(notif_hv, "account", sv_2mortal(perlify_account(notif->account)));
hvstores_ref(notif_hv, "pleroma", sv_2mortal(perlify_notification_pleroma(notif->pleroma)));
hvstores_ref(notif_hv, "status", sv_2mortal(perlify_status(notif->status)));
hvstores_ref(notif_hv, "account", perlify_account(notif->account));
hvstores_ref(notif_hv, "pleroma", perlify_notification_pleroma(notif->pleroma));
hvstores_ref(notif_hv, "status", perlify_status(notif->status));
return (HV*)sv_2mortal((SV*)notif_hv);
return notif_hv;
}
PERLIFY_MULTI(notification, notifications, mstdnt_notification)