From 3a74272a201cdfa3fd3992200d43f8f5ef34974a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20Luka=20=C5=A0ijanec?= Date: Tue, 28 Jun 2022 20:08:14 +0200 Subject: merge: @varovalka and old work from @ass --- ircxmpp.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'ircxmpp.h') diff --git a/ircxmpp.h b/ircxmpp.h index 38b6f16..19cf1c9 100644 --- a/ircxmpp.h +++ b/ircxmpp.h @@ -1,3 +1,4 @@ +#define IX_S0(x) (x ? x : "") enum ircxmpp_loglevel { IRCXMPP_DEBUG, IRCXMPP_INFO, @@ -10,6 +11,18 @@ typedef void (* ircxmpp_domain_setter) (void *, const char *); #ifdef IX_LIB /* do not use functions until #endif in programs that use libircxmpp. */ #include /* do not use members of struct ircxmpp, use opaque ircxmpp type! */ #include +#include +#define ISA(type, name) type * name; size_t name##_sizeof; size_t name##_length +#define ALLOC_CHUNK 1 // \\ note: this ISA is array of type not array of type * +#define REALLOC_K 1.5 +#define BIGGER_ARRAY(name) do { \ + name = realloc(name, sizeof(name[0])*ceil(name##_sizeof*REALLOC_K)); \ + for (int BA = name##_sizeof; BA < ceil(name##_sizeof*REALLOC_K); BA++) \ + name[BA] = NULL; \ + name##_sizeof = ceil(name##_sizeof*REALLOC_K); \ + } while (0) +#define MR(n) if (n##_sizeof <= n##_length) /* make room */ \ + BIGGER_ARRAY(n) enum irc_numeric { /* numerics from rfc 1459 */ ERR_NOSUCHNICK = 401, ERR_NOSUCHSERVER, @@ -179,6 +192,8 @@ struct ircxmpp { ircxmpp_domain_setter domain_setter; void * domain_setter_userdata; char * domain; + ISA(struct bridge *, to_free_bridges); + ISA(char *, to_free_reasons); // static reason strings, do not free them }; static void send_xmpp_logs_to_me ( void * const, const xmpp_log_level_t, const char * const, const char * const); -- cgit v1.2.3