]> granicus.if.org Git - neomutt/commitdiff
Add mutt_buffer_make to create a Buffer on the stack
authorPietro Cerutti <gahr@gahr.ch>
Tue, 27 Aug 2019 12:47:52 +0000 (12:47 +0000)
committerRichard Russon <rich@flatcap.org>
Sat, 31 Aug 2019 00:51:08 +0000 (01:51 +0100)
48 files changed:
color.c
commands.c
config/dump.c
config/set.c
email/rfc2047.c
hook.c
icommands.c
imap/imap.c
imap/util.c
init.c
main.c
mutt/buffer.c
mutt/buffer.h
mutt/file.c
mutt/mbyte.c
mutt_lua.c
muttlib.c
pager.c
test/base64/mutt_b64_buffer_decode.c
test/base64/mutt_b64_buffer_encode.c
test/buffer/mutt_buffer_add_printf.c
test/buffer/mutt_buffer_addch.c
test/buffer/mutt_buffer_addstr.c
test/buffer/mutt_buffer_addstr_n.c
test/buffer/mutt_buffer_alloc.c
test/buffer/mutt_buffer_concat_path.c
test/buffer/mutt_buffer_fix_dptr.c
test/buffer/mutt_buffer_init.c
test/buffer/mutt_buffer_is_empty.c
test/buffer/mutt_buffer_len.c
test/buffer/mutt_buffer_printf.c
test/buffer/mutt_buffer_reset.c
test/buffer/mutt_buffer_strcpy.c
test/buffer/mutt_buffer_strcpy_n.c
test/charset/mutt_ch_lookup_add.c
test/config/dump.c
test/file/mutt_buffer_file_expand_fmt_quote.c
test/file/mutt_buffer_quote_filename.c
test/file/mutt_file_expand_fmt.c
test/file/mutt_file_sanitize_regex.c
test/group/mutt_grouplist_add_regex.c
test/path/mutt_path_getcwd.c
test/pattern/comp.c
test/regex/mutt_regex_match.c
test/regex/mutt_regex_new.c
test/regex/mutt_regexlist_add.c
test/regex/mutt_replacelist_add.c
test/url/url_tobuffer.c

diff --git a/color.c b/color.c
index 47a233c44aab259be25e06488dc13f8646e09564..574c8a8b50a5d92c09670a0be61d7be4503346fe 100644 (file)
--- a/color.c
+++ b/color.c
@@ -1132,7 +1132,7 @@ static enum CommandResult parse_color(struct Buffer *buf, struct Buffer *s,
 
     if (MoreArgs(s))
     {
-      struct Buffer temporary = { 0 };
+      struct Buffer temporary = mutt_buffer_make(0);
       mutt_extract_token(&temporary, s, MUTT_TOKEN_NO_FLAGS);
       mutt_str_atoui(temporary.data, &match);
       FREE(&temporary.data);
index 1733e705ca1de28fe102353036dc7df129e4428d..fef2d1a7a2d2131ba1b0374a65c8d139c3643743 100644 (file)
@@ -842,10 +842,8 @@ void mutt_enter_command(void)
   if ((mutt_get_field(":", buf, sizeof(buf), MUTT_COMMAND) != 0) || !buf[0])
     return;
 
-  struct Buffer err = { 0 };
-  mutt_buffer_alloc(&err, 256);
-  struct Buffer token = { 0 };
-  mutt_buffer_alloc(&token, 256);
+  struct Buffer err = mutt_buffer_make(256);
+  struct Buffer token = mutt_buffer_make(256);
 
   /* check if buf is a valid icommand, else fall back quietly to parse_rc_lines */
   enum CommandResult rc = mutt_parse_icommand(buf, &err);
index c64aa28e5a65cb09517c339587a83f3886f309b1..02244455cfb8992b4c45351fa880f0be98142b58 100644 (file)
@@ -208,12 +208,9 @@ bool dump_config(struct ConfigSet *cs, ConfigDumpFlags flags, FILE *fp)
 
   bool result = true;
 
-  struct Buffer value = { 0 };
-  mutt_buffer_alloc(&value, 256);
-  struct Buffer initial = { 0 };
-  mutt_buffer_alloc(&initial, 256);
-  struct Buffer tmp = { 0 };
-  mutt_buffer_alloc(&tmp, 256);
+  struct Buffer value = mutt_buffer_make(256);
+  struct Buffer initial = mutt_buffer_make(256);
+  struct Buffer tmp = mutt_buffer_make(256);
 
   for (size_t i = 0; list[i]; i++)
   {
index d1cc0fd63d1227bbbbdb7ae776520469da98fbe1..e4c76924a4e0fa27f5cf10cbb5bbb0f76e29725a 100644 (file)
@@ -289,7 +289,7 @@ bool cs_register_variables(const struct ConfigSet *cs, struct ConfigDef vars[],
   if (!cs || !vars)
     return false;
 
-  struct Buffer err = { 0 };
+  struct Buffer err = mutt_buffer_make(0);
 
   bool rc = true;
 
index 99ce89875af570710fa3686a198e590e6bf71491..a0ae382c3925dba9f5006dbf7373c1a4c92799b9 100644 (file)
@@ -372,7 +372,7 @@ static char *decode_word(const char *s, size_t len, enum ContentEncoding enc)
 
   if (enc == ENC_QUOTED_PRINTABLE)
   {
-    struct Buffer buf = { 0 };
+    struct Buffer buf = mutt_buffer_make(0);
     for (; it < end; it++)
     {
       if (*it == '_')
@@ -651,19 +651,19 @@ void rfc2047_decode(char **pd)
   if (!pd || !*pd)
     return;
 
-  struct Buffer buf = { 0 }; /* Output buffer                          */
-  char *s = *pd;             /* Read pointer                           */
-  char *beg = NULL;          /* Begin of encoded word                  */
-  enum ContentEncoding enc;  /* ENC_BASE64 or ENC_QUOTED_PRINTABLE     */
-  char *charset = NULL;      /* Which charset                          */
-  size_t charsetlen;         /* Length of the charset                  */
-  char *text = NULL;         /* Encoded text                           */
-  size_t textlen;            /* Length of encoded text                 */
+  struct Buffer buf = mutt_buffer_make(0); /* Output buffer            */
+  char *s = *pd;            /* Read pointer                           */
+  char *beg = NULL;         /* Begin of encoded word                  */
+  enum ContentEncoding enc; /* ENC_BASE64 or ENC_QUOTED_PRINTABLE     */
+  char *charset = NULL;     /* Which charset                          */
+  size_t charsetlen;        /* Length of the charset                  */
+  char *text = NULL;        /* Encoded text                           */
+  size_t textlen;           /* Length of encoded text                 */
 
   /* Keep some state in case the next decoded word is using the same charset
    * and it happens to be split in the middle of a multibyte character.
    * See https://github.com/neomutt/neomutt/issues/1015 */
-  struct Buffer prev = { 0 }; /* Previously decoded word                */
+  struct Buffer prev = mutt_buffer_make(0); /* Previously decoded word  */
   char *prev_charset = NULL;  /* Previously used charset                */
   size_t prev_charsetlen = 0; /* Length of the previously used charset  */
 
diff --git a/hook.c b/hook.c
index 65198f04df476488c2b393dc16ae8b9bed40338b..87f10d3b177f8ce9d8113f4859c6d7fdcda2613e 100644 (file)
--- a/hook.c
+++ b/hook.c
@@ -845,8 +845,8 @@ void mutt_timeout_hook(void)
 void mutt_startup_shutdown_hook(HookFlags type)
 {
   struct Hook *hook = NULL;
-  struct Buffer token = { 0 };
-  struct Buffer err = { 0 };
+  struct Buffer token = mutt_buffer_make(0);
+  struct Buffer err = mutt_buffer_make(0);
   char buf[256];
 
   err.data = buf;
index acaacb2beb944e57a76e00699a58d6e397ebb118..c7743e9d57e01c5367af8d2fc247aedc991d863a 100644 (file)
@@ -79,7 +79,7 @@ enum CommandResult mutt_parse_icommand(/* const */ char *line, struct Buffer *er
   enum CommandResult rc = MUTT_CMD_ERROR;
 
   struct Buffer *token = mutt_buffer_pool_get();
-  struct Buffer expn = { 0 };
+  struct Buffer expn = mutt_buffer_make(0);
   mutt_buffer_addstr(&expn, line);
   expn.dptr = expn.data;
 
@@ -158,7 +158,7 @@ static void dump_macro(struct Buffer *buf, struct Mapping *menu, struct Keymap *
   char key_binding[MAX_SEQ];
   km_expand_key(key_binding, MAX_SEQ, map);
 
-  struct Buffer tmp = { 0 };
+  struct Buffer tmp = mutt_buffer_make(0);
   escape_string(&tmp, map->macro);
 
   if (map->desc)
@@ -247,8 +247,7 @@ static enum CommandResult icmd_bind(struct Buffer *buf, struct Buffer *s,
     return MUTT_CMD_ERROR;
   }
 
-  struct Buffer filebuf = { 0 };
-  mutt_buffer_alloc(&filebuf, 4096);
+  struct Buffer filebuf = mutt_buffer_make(4096);
   if (dump_all || (mutt_str_strcasecmp(buf->data, "all") == 0))
   {
     dump_all_menus(&filebuf, bind);
index cd531fa809269c5d38320b37770fe998c723d258..ee45364e970c87cefdbf26a907281b949aeea09c 100644 (file)
@@ -725,7 +725,7 @@ int imap_read_literal(FILE *fp, struct ImapAccountData *adata,
 {
   char c;
   bool r = false;
-  struct Buffer buf = { 0 };
+  struct Buffer buf = { 0 }; // Do not allocate, maybe it won't be used
 
   if (C_DebugLevel >= IMAP_LOG_LTRL)
     mutt_buffer_alloc(&buf, bytes + 10);
@@ -1017,7 +1017,7 @@ int imap_exec_msgset(struct Mailbox *m, const char *pre, const char *post,
   int rc;
   int count = 0;
 
-  struct Buffer cmd = { 0 };
+  struct Buffer cmd = mutt_buffer_make(0);
 
   /* We make a copy of the headers just in case resorting doesn't give
    exactly the original order (duplicate messages?), because other parts of
@@ -1529,7 +1529,7 @@ int imap_fast_trash(struct Mailbox *m, char *dest)
   if (imap_adata_find(dest, &dest_adata, &dest_mdata) < 0)
     return -1;
 
-  struct Buffer sync_cmd = { 0 };
+  struct Buffer sync_cmd = mutt_buffer_make(0);
 
   /* check that the save-to folder is in the same account */
   if (!mutt_account_match(&(adata->conn->account), &(dest_adata->conn->account)))
@@ -2374,7 +2374,7 @@ static int imap_tags_commit(struct Mailbox *m, struct Email *e, char *buf)
   /* Remove old custom flags */
   if (imap_edata_get(e)->flags_remote)
   {
-    struct Buffer cmd = { 0 };
+    struct Buffer cmd = mutt_buffer_make(128); // just a guess
     mutt_buffer_addstr(&cmd, "UID STORE ");
     mutt_buffer_addstr(&cmd, uid);
     mutt_buffer_addstr(&cmd, " -FLAGS.SILENT (");
@@ -2394,7 +2394,7 @@ static int imap_tags_commit(struct Mailbox *m, struct Email *e, char *buf)
   /* Add new custom flags */
   if (buf)
   {
-    struct Buffer cmd = { 0 };
+    struct Buffer cmd = mutt_buffer_make(128); // just a guess
     mutt_buffer_addstr(&cmd, "UID STORE ");
     mutt_buffer_addstr(&cmd, uid);
     mutt_buffer_addstr(&cmd, " +FLAGS.SILENT (");
index c3d6b22f72fead57dbcc6d291458875b1fdb0e38..1e54281c8f30a7c950c2f28785274a50bb3cb28a 100644 (file)
@@ -527,8 +527,7 @@ int imap_hcache_store_uid_seqset(struct ImapMboxData *mdata)
     return -1;
 
   /* The seqset is likely large.  Preallocate to reduce reallocs */
-  struct Buffer b = { 0 };
-  mutt_buffer_alloc(&b, 8192);
+  struct Buffer b = mutt_buffer_make(8192);
   imap_msn_index_to_uid_seqset(&b, mdata);
 
   int rc = mutt_hcache_store_raw(mdata->hcache, "/UIDSEQSET", 10, b.data,
diff --git a/init.c b/init.c
index d00bc6992cfbef401ebdf5b0e65ffad928b25850..e32d1fda07c9f6f48a98fb5e6ed1ed4ef1834165 100644 (file)
--- a/init.c
+++ b/init.c
@@ -573,7 +573,7 @@ static enum CommandResult parse_replace_list(struct Buffer *buf, struct Buffer *
                                              unsigned long data, struct Buffer *err)
 {
   struct ReplaceList *list = (struct ReplaceList *) data;
-  struct Buffer templ = { 0 };
+  struct Buffer templ = mutt_buffer_make(0);
 
   /* First token is a regex. */
   if (!MoreArgs(s))
@@ -1221,7 +1221,7 @@ static bool is_function(const char *name)
 static enum CommandResult parse_ifdef(struct Buffer *buf, struct Buffer *s,
                                       unsigned long data, struct Buffer *err)
 {
-  struct Buffer token = { 0 };
+  struct Buffer token = mutt_buffer_make(0);
 
   mutt_extract_token(buf, s, MUTT_TOKEN_NO_FLAGS);
 
@@ -2963,9 +2963,7 @@ int mutt_init(bool skip_sys_rc, struct ListHead *commands)
 {
   char buf[1024];
   int need_pause = 0;
-  struct Buffer err = { 0 };
-
-  mutt_buffer_alloc(&err, 256);
+  struct Buffer err = mutt_buffer_make(256);
 
   mutt_grouplist_init();
   /* reverse alias keys need to be strdup'ed because of idna conversions */
@@ -3221,7 +3219,7 @@ enum CommandResult mutt_parse_rc_line(/* const */ char *line,
   int i;
   enum CommandResult rc = MUTT_CMD_SUCCESS;
 
-  struct Buffer expn = { 0 };
+  struct Buffer expn = mutt_buffer_make(0);
   mutt_buffer_addstr(&expn, line);
   expn.dptr = expn.data;
 
@@ -3270,10 +3268,8 @@ finish:
  */
 int mutt_query_variables(struct ListHead *queries)
 {
-  struct Buffer value = { 0 };
-  mutt_buffer_alloc(&value, 256);
-  struct Buffer tmp = { 0 };
-  mutt_buffer_alloc(&tmp, 256);
+  struct Buffer value = mutt_buffer_make(256);
+  struct Buffer tmp = mutt_buffer_make(256);
   int rc = 0;
 
   struct ListNode *np = NULL;
@@ -3726,8 +3722,7 @@ int mutt_var_value_complete(char *buf, size_t buflen, int pos)
       myvarval = myvar_get(var);
       if (myvarval)
       {
-        struct Buffer pretty = { 0 };
-        mutt_buffer_alloc(&pretty, 256);
+        struct Buffer pretty = mutt_buffer_make(256);
         pretty_var(myvarval, &pretty);
         snprintf(pt, buflen - (pt - buf), "%s=%s", var, pretty.data);
         mutt_buffer_dealloc(&pretty);
@@ -3737,10 +3732,8 @@ int mutt_var_value_complete(char *buf, size_t buflen, int pos)
     }
     else
     {
-      struct Buffer value = { 0 };
-      mutt_buffer_alloc(&value, 256);
-      struct Buffer pretty = { 0 };
-      mutt_buffer_alloc(&pretty, 256);
+      struct Buffer value = mutt_buffer_make(256);
+      struct Buffer pretty = mutt_buffer_make(256);
       int rc = cs_he_string_get(Config, he, &value);
       if (CSR_RESULT(rc) == CSR_SUCCESS)
       {
diff --git a/main.c b/main.c
index 6713d0e0b5921a895372319ba79260df09239889..b20266d2c026d429589dc327a9aadb6bef330c54 100644 (file)
--- a/main.c
+++ b/main.c
@@ -144,10 +144,8 @@ static void test_parse_set(void)
     "%s inv%s=42", "%s inv%s?", "%s &%s",     "%s &%s=42", "%s &%s?",
   };
 
-  struct Buffer tmp = { 0 };
-  mutt_buffer_alloc(&tmp, 256);
-  struct Buffer err = { 0 };
-  mutt_buffer_alloc(&err, 256);
+  struct Buffer tmp = mutt_buffer_make(256);
+  struct Buffer err = mutt_buffer_make(256);
   char line[64];
 
   for (size_t v = 0; v < mutt_array_size(vars); v++)
@@ -189,8 +187,7 @@ static void reset_tilde(struct ConfigSet *cs)
     "record",     "signature",
   };
 
-  struct Buffer value = { 0 };
-  mutt_buffer_alloc(&value, 256);
+  struct Buffer value = mutt_buffer_make(256);
   for (size_t i = 0; i < mutt_array_size(names); i++)
   {
     struct HashElem *he = cs_get_elem(cs, names[i]);
@@ -444,7 +441,7 @@ int main(int argc, char *argv[], char *envp[])
   int double_dash = argc, nargc = 1;
   int rc = 1;
   bool repeat_error = false;
-  struct Buffer folder = { 0 };
+  struct Buffer folder = mutt_buffer_make(0);
 
   MuttLogger = log_disp_terminal;
 
@@ -742,7 +739,7 @@ int main(int argc, char *argv[], char *envp[])
 
   if (new_magic)
   {
-    struct Buffer err = { 0 };
+    struct Buffer err = mutt_buffer_make(0);
     int r = cs_str_initial_set(Config, "mbox_type", new_magic, &err);
     if (CSR_RESULT(r) != CSR_SUCCESS)
     {
index 0cb146b6a9e8225c9370d8ca1f9e92fe7dfbfd85..12c891a5ec45f791dab7739011c871de84c6e12d 100644 (file)
@@ -51,6 +51,24 @@ struct Buffer *mutt_buffer_init(struct Buffer *buf)
   return buf;
 }
 
+/**
+ * mutt_buffer_make - Make a new buffer on the stack
+ * @param size Initial size
+ * @retval buf Initialized buffer
+ *
+ * The buffer must be released using mutt_buffer_dealloc
+ */
+struct Buffer mutt_buffer_make(size_t size)
+{
+  struct Buffer buf = { 0 };
+  if (size != 0)
+  {
+    buf.dptr = buf.data = mutt_mem_calloc(1, size);
+    buf.dsize = size;
+  }
+  return buf;
+}
+
 /**
  * mutt_buffer_reset - Reset an existing Buffer
  * @param buf Buffer to reset
@@ -277,6 +295,8 @@ void mutt_buffer_dealloc(struct Buffer *buf)
   if (!buf || !buf->data)
     return;
 
+  buf->dptr = NULL;
+  buf->dsize = 0;
   FREE(&buf->data);
 }
 
index ac2dce56c44f9aed8cde2bfa4eb0f2eaf949c09e..e6c7329096e2026dd153d56022341f7f14d68e18 100644 (file)
@@ -48,6 +48,7 @@ void           mutt_buffer_fix_dptr     (struct Buffer *buf);
 struct Buffer *mutt_buffer_init         (struct Buffer *buf);
 bool           mutt_buffer_is_empty     (const struct Buffer *buf);
 size_t         mutt_buffer_len          (const struct Buffer *buf);
+struct Buffer  mutt_buffer_make         (size_t size);
 void           mutt_buffer_reset        (struct Buffer *buf);
 
 // Functions that APPEND to a Buffer
index 8ca0024707653a008a3945cb083bdc63d5de51ec..080e7a2129c1a2d2c8dc607ccc33e911468cd274 100644 (file)
@@ -92,8 +92,7 @@ static int mkwrapdir(const char *path, struct Buffer *newfile, struct Buffer *ne
   const char *basename = NULL;
   int rc = 0;
 
-  struct Buffer parent = { 0 };
-  mutt_buffer_alloc(&parent, PATH_MAX);
+  struct Buffer parent = mutt_buffer_make(PATH_MAX);
   mutt_buffer_strcpy(&parent, NONULL(path));
 
   char *p = strrchr(parent.data, '/');
@@ -308,8 +307,7 @@ int mutt_file_symlink(const char *oldpath, const char *newpath)
   }
   else
   {
-    struct Buffer abs_oldpath = { 0 };
-    mutt_buffer_alloc(&abs_oldpath, PATH_MAX);
+    struct Buffer abs_oldpath = mutt_buffer_make(PATH_MAX);
 
     if (!mutt_path_getcwd(&abs_oldpath))
     {
@@ -479,8 +477,7 @@ int mutt_file_rmtree(const char *path)
 
   /* We avoid using the buffer pool for this function, because it
    * invokes recursively to an unknown depth. */
-  struct Buffer cur = { 0 };
-  mutt_buffer_alloc(&cur, PATH_MAX);
+  struct Buffer cur = mutt_buffer_make(PATH_MAX);
 
   while ((de = readdir(dirp)))
   {
@@ -523,8 +520,8 @@ int mutt_file_open(const char *path, int flags)
 
   struct stat osb, nsb;
   int fd;
-  struct Buffer safe_file = { 0 };
-  struct Buffer safe_dir = { 0 };
+  struct Buffer safe_file = mutt_buffer_make(0);
+  struct Buffer safe_dir = mutt_buffer_make(0);
 
   if (flags & O_EXCL)
   {
@@ -1418,8 +1415,7 @@ int mutt_file_check_empty(const char *path)
  */
 void mutt_buffer_file_expand_fmt_quote(struct Buffer *dest, const char *fmt, const char *src)
 {
-  struct Buffer tmp = { 0 };
-  mutt_buffer_alloc(&tmp, PATH_MAX);
+  struct Buffer tmp = mutt_buffer_make(PATH_MAX);
 
   mutt_buffer_quote_filename(&tmp, src, true);
   mutt_file_expand_fmt(dest, fmt, mutt_b2s(&tmp));
index f66e55668828232ed6058a5b1b4e37e91d31dc4a..a16bcff0336efc7b35b429a9a2244403fce8ffb0 100644 (file)
@@ -432,7 +432,7 @@ int mutt_mb_filter_unprintable(char **s)
   char *p = *s;
   mbstate_t mbstate1, mbstate2;
 
-  struct Buffer buf = { 0 };
+  struct Buffer buf = mutt_buffer_make(0);
   memset(&mbstate1, 0, sizeof(mbstate1));
   memset(&mbstate2, 0, sizeof(mbstate2));
   for (; (k = mbrtowc(&wc, p, MB_LEN_MAX, &mbstate1)); p += k)
index ad2179437e1e9a3cd9a60e9715822cdae1b35e17..563ebd99f8803754206de0c0cd447723a71d4dd8 100644 (file)
@@ -105,7 +105,7 @@ static int lua_mutt_call(lua_State *l)
     mutt_str_strncat(buf, sizeof(buf), " ", 1);
   }
 
-  struct Buffer expn = { 0 };
+  struct Buffer expn = mutt_buffer_make(0);
   expn.data = buf;
   expn.dptr = buf;
   expn.dsize = mutt_str_strlen(buf);
@@ -156,8 +156,7 @@ static int lua_mutt_set(lua_State *l)
   struct ConfigDef *cdef = he->data;
 
   int rc = 0;
-  struct Buffer err = { 0 };
-  mutt_buffer_alloc(&err, 256);
+  struct Buffer err = mutt_buffer_make(256);
 
   switch (DTYPE(cdef->type))
   {
@@ -246,8 +245,7 @@ static int lua_mutt_get(lua_State *l)
     case DT_SORT:
     case DT_STRING:
     {
-      struct Buffer value = { 0 };
-      mutt_buffer_alloc(&value, 256);
+      struct Buffer value = mutt_buffer_make(256);
       int rc = cs_he_string_get(Config, he, &value);
       if (CSR_RESULT(rc) != CSR_SUCCESS)
       {
@@ -255,8 +253,7 @@ static int lua_mutt_get(lua_State *l)
         return -1;
       }
 
-      struct Buffer escaped = { 0 };
-      mutt_buffer_alloc(&escaped, 256);
+      struct Buffer escaped = mutt_buffer_make(256);
       escape_string(&escaped, value.data);
       lua_pushstring(l, escaped.data);
       mutt_buffer_dealloc(&value);
index 7c58ad63e099e904bd943e4fc74af21fa81d3613..28547f0eeba39d857d5a8bb7406164f769deb9e2 100644 (file)
--- a/muttlib.c
+++ b/muttlib.c
@@ -882,13 +882,13 @@ void mutt_expando_format(char *buf, size_t buflen, size_t col, int cols, const c
       srccopy[n - 1] = '\0';
 
       /* prepare Buffers */
-      struct Buffer srcbuf = { 0 };
+      struct Buffer srcbuf = mutt_buffer_make(0);
       mutt_buffer_addstr(&srcbuf, srccopy);
       /* note: we are resetting dptr and *reading* from the buffer, so we don't
        * want to use mutt_buffer_reset(). */
       srcbuf.dptr = srcbuf.data;
-      struct Buffer word = { 0 };
-      struct Buffer cmd = { 0 };
+      struct Buffer word = mutt_buffer_make(0);
+      struct Buffer cmd = mutt_buffer_make(0);
 
       /* Iterate expansions across successive arguments */
       do
diff --git a/pager.c b/pager.c
index bb59be2468f6974084e9bf8a35c8d56e35a98211..0e570f41be6b0b866df3a78cd091364846db8d43 100644 (file)
--- a/pager.c
+++ b/pager.c
@@ -2300,7 +2300,7 @@ int mutt_pager(const char *banner, const char *fname, PagerFlags flags, struct P
     (rd.line_info[i].syntax)[0].last = -1;
   }
 
-  struct Buffer helpstr = { 0 };
+  struct Buffer helpstr = mutt_buffer_make(0);
   mutt_compile_help(buf, sizeof(buf), MENU_PAGER, PagerHelp);
   mutt_buffer_strcpy(&helpstr, buf);
   if (IsEmail(extra))
index 63acd393e4d52732525e75d292f6cb9f68a5cbe8..6d47b799ab83769000011cf2dd23877a905ed17e 100644 (file)
@@ -34,7 +34,7 @@ void test_mutt_b64_buffer_decode(void)
   }
 
   {
-    struct Buffer buf = { 0 };
+    struct Buffer buf = mutt_buffer_make(0);
     TEST_CHECK(mutt_b64_buffer_decode(&buf, NULL) != 0);
   }
 }
index ba75ebe645df9b94f3fb229cbdc0f3f753874bc2..fd660c592000271044a8beef16c78a73d4dbd719 100644 (file)
@@ -34,7 +34,7 @@ void test_mutt_b64_buffer_encode(void)
   }
 
   {
-    struct Buffer buf = { 0 };
+    struct Buffer buf = mutt_buffer_make(0);
     TEST_CHECK(mutt_b64_buffer_encode(&buf, NULL, 10) == 0);
     mutt_buffer_dealloc(&buf);
   }
index a79909c732614455bed7e1099e1b35f4cfaad916..71552e97cf638a0da092d6067f2a805037acc6cb 100644 (file)
@@ -34,7 +34,7 @@ void test_mutt_buffer_add_printf(void)
   }
 
   {
-    struct Buffer buf = { 0 };
+    struct Buffer buf = mutt_buffer_make(0);
     TEST_CHECK(mutt_buffer_add_printf(&buf, NULL) != 0);
   }
 
@@ -42,7 +42,7 @@ void test_mutt_buffer_add_printf(void)
 
   {
     TEST_CASE("Empty");
-    struct Buffer buf = { 0 };
+    struct Buffer buf = mutt_buffer_make(0);
     TEST_CHECK(mutt_buffer_add_printf(&buf, "") == 0);
     TEST_CHECK(strlen(mutt_b2s(&buf)) == 0);
     mutt_buffer_dealloc(&buf);
@@ -51,7 +51,7 @@ void test_mutt_buffer_add_printf(void)
   {
     TEST_CASE("Static");
     const char *str = "apple";
-    struct Buffer buf = { 0 };
+    struct Buffer buf = mutt_buffer_make(0);
     TEST_CHECK(mutt_buffer_add_printf(&buf, str) == 5);
     TEST_CHECK(strcmp(mutt_b2s(&buf), str) == 0);
     mutt_buffer_dealloc(&buf);
@@ -63,7 +63,7 @@ void test_mutt_buffer_add_printf(void)
         "apple banana cherry damson elderberry fig guava hawthorn ilama "
         "jackfruit kumquat lemon mango nectarine olive papaya quince raspberry "
         "strawberry tangerine ugli vanilla wolfberry xigua yew ziziphus";
-    struct Buffer buf = { 0 };
+    struct Buffer buf = mutt_buffer_make(0);
     TEST_CHECK(mutt_buffer_add_printf(&buf, str) == 195);
     TEST_CHECK(strcmp(mutt_b2s(&buf), str) == 0);
     mutt_buffer_dealloc(&buf);
@@ -73,7 +73,7 @@ void test_mutt_buffer_add_printf(void)
     TEST_CASE("Varargs");
     const char *str = "apple";
     const char *result = "app 1234567 3.1416";
-    struct Buffer buf = { 0 };
+    struct Buffer buf = mutt_buffer_make(0);
     TEST_CHECK(mutt_buffer_add_printf(&buf, "%.3s %ld %3.4f", str, 1234567, 3.141592654) == 18);
     TEST_CHECK(strcmp(mutt_b2s(&buf), result) == 0);
     mutt_buffer_dealloc(&buf);
@@ -84,7 +84,7 @@ void test_mutt_buffer_add_printf(void)
   {
     TEST_CASE("Empty");
     const char *str = "test";
-    struct Buffer buf = { 0 };
+    struct Buffer buf = mutt_buffer_make(0);
     mutt_buffer_addstr(&buf, str);
     TEST_CHECK(mutt_buffer_add_printf(&buf, "") == 0);
     TEST_CHECK(strcmp(mutt_b2s(&buf), str) == 0);
@@ -95,7 +95,7 @@ void test_mutt_buffer_add_printf(void)
     TEST_CASE("Static");
     const char *str = "apple";
     const char *result = "testapple";
-    struct Buffer buf = { 0 };
+    struct Buffer buf = mutt_buffer_make(0);
     mutt_buffer_addstr(&buf, "test");
     TEST_CHECK(mutt_buffer_add_printf(&buf, str) == 5);
     TEST_CHECK(strcmp(mutt_b2s(&buf), result) == 0);
@@ -112,7 +112,7 @@ void test_mutt_buffer_add_printf(void)
         "testapple banana cherry damson elderberry fig guava hawthorn ilama "
         "jackfruit kumquat lemon mango nectarine olive papaya quince raspberry "
         "strawberry tangerine ugli vanilla wolfberry xigua yew ziziphus";
-    struct Buffer buf = { 0 };
+    struct Buffer buf = mutt_buffer_make(0);
     mutt_buffer_addstr(&buf, "test");
     TEST_CHECK(mutt_buffer_add_printf(&buf, str) == 195);
     TEST_CHECK(strcmp(mutt_b2s(&buf), result) == 0);
@@ -123,7 +123,7 @@ void test_mutt_buffer_add_printf(void)
     TEST_CASE("Varargs");
     const char *str = "apple";
     const char *result = "testapp 1234567 3.1416";
-    struct Buffer buf = { 0 };
+    struct Buffer buf = mutt_buffer_make(0);
     mutt_buffer_addstr(&buf, "test");
     TEST_CHECK(mutt_buffer_add_printf(&buf, "%.3s %ld %3.4f", str, 1234567, 3.141592654) == 18);
     TEST_CHECK(strcmp(mutt_b2s(&buf), result) == 0);
index e50569c3301ca00b6a19492cfa5c7603921bd99e..2d59b9da0b8b5abcb2f466ac88d2715f8542eb02 100644 (file)
@@ -34,14 +34,14 @@ void test_mutt_buffer_addch(void)
   }
 
   {
-    struct Buffer buf = { 0 };
+    struct Buffer buf = mutt_buffer_make(0);
     TEST_CHECK(mutt_buffer_addch(&buf, 'a') == 1);
     TEST_CHECK(strcmp(mutt_b2s(&buf), "a") == 0);
     mutt_buffer_dealloc(&buf);
   }
 
   {
-    struct Buffer buf = { 0 };
+    struct Buffer buf = mutt_buffer_make(0);
     mutt_buffer_addstr(&buf, "test");
     TEST_CHECK(mutt_buffer_addch(&buf, 'a') == 1);
     TEST_CHECK(strcmp(mutt_b2s(&buf), "testa") == 0);
index 528da0a70ab4a58856720dc42061f9906ed1fa84..224373aa839be15538a3ad6f3187ba3ed9c1541f 100644 (file)
@@ -34,19 +34,19 @@ void test_mutt_buffer_addstr(void)
   }
 
   {
-    struct Buffer buf = { 0 };
+    struct Buffer buf = mutt_buffer_make(0);
     TEST_CHECK(mutt_buffer_addstr(&buf, NULL) == 0);
   }
 
   {
-    struct Buffer buf = { 0 };
+    struct Buffer buf = mutt_buffer_make(0);
     TEST_CHECK(mutt_buffer_addstr(&buf, "apple") == 5);
     TEST_CHECK(strcmp(mutt_b2s(&buf), "apple") == 0);
     mutt_buffer_dealloc(&buf);
   }
 
   {
-    struct Buffer buf = { 0 };
+    struct Buffer buf = mutt_buffer_make(0);
     mutt_buffer_addstr(&buf, "test");
     TEST_CHECK(mutt_buffer_addstr(&buf, "apple") == 5);
     TEST_CHECK(strcmp(mutt_b2s(&buf), "testapple") == 0);
index 0eb1da50144c4b43bc606cf4f998f3c3bc2132e0..d3e96db819a222620554bfb968d37952b4be093d 100644 (file)
@@ -34,7 +34,7 @@ void test_mutt_buffer_addstr_n(void)
   }
 
   {
-    struct Buffer buf = { 0 };
+    struct Buffer buf = mutt_buffer_make(0);
     TEST_CHECK(mutt_buffer_addstr_n(&buf, NULL, 10) == 0);
   }
 
@@ -48,7 +48,7 @@ void test_mutt_buffer_addstr_n(void)
     for (size_t i = 0; i < mutt_array_size(sizes); i++)
     {
       TEST_CASE_("%ld", sizes[i]);
-      struct Buffer buf = { 0 };
+      struct Buffer buf = mutt_buffer_make(0);
       TEST_CHECK(mutt_buffer_addstr_n(&buf, str, sizes[i]) == sizes[i]);
       TEST_CHECK(strlen(mutt_b2s(&buf)) == MIN(len, sizes[i]));
       TEST_CHECK(strncmp(mutt_b2s(&buf), str, sizes[i]) == 0);
@@ -69,7 +69,7 @@ void test_mutt_buffer_addstr_n(void)
     for (size_t i = 0; i < mutt_array_size(sizes); i++)
     {
       TEST_CASE_("%ld", sizes[i]);
-      struct Buffer buf = { 0 };
+      struct Buffer buf = mutt_buffer_make(0);
       mutt_buffer_addstr(&buf, base);
       TEST_CHECK(mutt_buffer_addstr_n(&buf, str, sizes[i]) == sizes[i]);
       TEST_CHECK(strlen(mutt_b2s(&buf)) == (base_len + MIN(len, sizes[i])));
index 7c766f2027969e1cb0a8f971821f503ca906cf6e..21f0c3bd18828cd1d476127cc0a5354e9a3df1ca 100644 (file)
@@ -35,7 +35,7 @@ void test_mutt_buffer_alloc(void)
   }
 
   {
-    struct Buffer buf = { 0 };
+    struct Buffer buf = mutt_buffer_make(0);
     mutt_buffer_alloc(&buf, 10);
     TEST_CHECK_(1, "mutt_buffer_alloc(buf, 10)");
     mutt_buffer_dealloc(&buf);
@@ -47,7 +47,7 @@ void test_mutt_buffer_alloc(void)
 
     for (size_t i = 0; i < mutt_array_size(sizes); i++)
     {
-      struct Buffer buf = { 0 };
+      struct Buffer buf = mutt_buffer_make(0);
       mutt_buffer_alloc(&buf, orig_size);
       TEST_CASE_("%d", sizes[i]);
       mutt_buffer_alloc(&buf, sizes[i]);
index 26a4a35a0667d5b9c8c08505fed5a82d482ff1f6..5c6dd062d3bd90b64fc8cd95113c6807018ee1b2 100644 (file)
@@ -59,7 +59,7 @@ void test_mutt_buffer_concat_path(void)
       TEST_CASE_("DIR: '%s'  FILE: '%s'", NONULL(concat_test[i][0]),
                  NONULL(concat_test[i][1]));
       {
-        struct Buffer buf = { 0 };
+        struct Buffer buf = mutt_buffer_make(0);
         mutt_buffer_concat_path(&buf, concat_test[i][0], concat_test[i][1]);
         if (concat_test[i][2])
         {
@@ -77,7 +77,7 @@ void test_mutt_buffer_concat_path(void)
 
       {
         const char *str = "test";
-        struct Buffer buf = { 0 };
+        struct Buffer buf = mutt_buffer_make(0);
         mutt_buffer_addstr(&buf, str);
         mutt_buffer_concat_path(&buf, concat_test[i][0], concat_test[i][1]);
         if (concat_test[i][2])
index a4872942f073528ab04bd7bf958420008a16a656..285a4665c4ec30b5d931d09f60e54b762ad79ba7 100644 (file)
@@ -35,14 +35,14 @@ void test_mutt_buffer_fix_dptr(void)
   }
 
   {
-    struct Buffer buf = { 0 };
+    struct Buffer buf = mutt_buffer_make(0);
     mutt_buffer_fix_dptr(&buf);
     TEST_CHECK(mutt_buffer_len(&buf) == 0);
   }
 
   {
     const char *str = "a quick brown fox";
-    struct Buffer buf ={ 0 };
+    struct Buffer buf = mutt_buffer_make(0);
     mutt_buffer_addstr(&buf, str);
     mutt_buffer_fix_dptr(&buf);
     TEST_CHECK(mutt_buffer_len(&buf) == (strlen(str)));
index 68ca4b24765679eac2b4c96165366dc6cd1cabbd..3838a9130613e69a97de9803ab736d6ac659824e 100644 (file)
@@ -34,7 +34,7 @@ void test_mutt_buffer_init(void)
   }
 
   {
-    struct Buffer buf = { 0 };
+    struct Buffer buf = mutt_buffer_make(0);
     TEST_CHECK(mutt_buffer_init(&buf) != NULL);
   }
 }
index 04be31be3661aca7a18e33245e5b0758eaa963e7..b93995b589a6ea0345ffd73242a203fc4d8958b9 100644 (file)
@@ -34,12 +34,12 @@ void test_mutt_buffer_is_empty(void)
   }
 
   {
-    struct Buffer buf = { 0 };
+    struct Buffer buf = mutt_buffer_make(0);
     TEST_CHECK(mutt_buffer_is_empty(&buf));
   }
 
   {
-    struct Buffer buf = { 0 };
+    struct Buffer buf = mutt_buffer_make(0);
     mutt_buffer_addstr(&buf, "test");
     TEST_CHECK(!mutt_buffer_is_empty(&buf));
     mutt_buffer_dealloc(&buf);
index 96caf7fe9eb36dc83b1c05c44373918522996f1e..b351945f7443e1a5c5691c636c6f2629bdf1c2f2 100644 (file)
@@ -34,12 +34,12 @@ void test_mutt_buffer_len(void)
   }
 
   {
-    struct Buffer buf = { 0 };
+    struct Buffer buf = mutt_buffer_make(0);
     TEST_CHECK(mutt_buffer_len(&buf) == 0);
   }
 
   {
-    struct Buffer buf = { 0 };
+    struct Buffer buf = mutt_buffer_make(0);
     mutt_buffer_addstr(&buf, "test");
     TEST_CHECK(mutt_buffer_len(&buf) != 0);
     mutt_buffer_dealloc(&buf);
index 32c42adfd7bb6ce7a477a1605a3794ee59ab1b35..24bd7e4926ceacac21e14f79c52da0cb3a59b614 100644 (file)
@@ -34,7 +34,7 @@ void test_mutt_buffer_printf(void)
   }
 
   {
-    struct Buffer buf = { 0 };
+    struct Buffer buf = mutt_buffer_make(0);
     TEST_CHECK(mutt_buffer_printf(&buf, NULL) != 0);
   }
 
@@ -42,7 +42,7 @@ void test_mutt_buffer_printf(void)
 
   {
     TEST_CASE("Empty");
-    struct Buffer buf = { 0 };
+    struct Buffer buf = mutt_buffer_make(0);
     TEST_CHECK(mutt_buffer_printf(&buf, "") == 0);
     TEST_CHECK(strlen(mutt_b2s(&buf)) == 0);
     mutt_buffer_dealloc(&buf);
@@ -51,7 +51,7 @@ void test_mutt_buffer_printf(void)
   {
     TEST_CASE("Static");
     const char *str = "apple";
-    struct Buffer buf = { 0 };
+    struct Buffer buf = mutt_buffer_make(0);
     TEST_CHECK(mutt_buffer_printf(&buf, str) == 5);
     TEST_CHECK(strcmp(mutt_b2s(&buf), str) == 0);
     mutt_buffer_dealloc(&buf);
@@ -61,7 +61,7 @@ void test_mutt_buffer_printf(void)
     TEST_CASE("Varargs");
     const char *str = "apple";
     const char *result = "app 1234567 3.1416";
-    struct Buffer buf = { 0 };
+    struct Buffer buf = mutt_buffer_make(0);
     TEST_CHECK(mutt_buffer_printf(&buf, "%.3s %ld %3.4f", str, 1234567, 3.141592654) == 18);
     TEST_CHECK(strcmp(mutt_b2s(&buf), result) == 0);
     mutt_buffer_dealloc(&buf);
@@ -72,7 +72,7 @@ void test_mutt_buffer_printf(void)
   {
     TEST_CASE("Empty");
     const char *str = "test";
-    struct Buffer buf = { 0 };
+    struct Buffer buf = mutt_buffer_make(0);
     mutt_buffer_addstr(&buf, str);
     TEST_CHECK(mutt_buffer_printf(&buf, "") == 0);
     TEST_CHECK(strcmp(mutt_b2s(&buf), "") == 0);
@@ -82,7 +82,7 @@ void test_mutt_buffer_printf(void)
   {
     TEST_CASE("Static");
     const char *str = "apple";
-    struct Buffer buf = { 0 };
+    struct Buffer buf = mutt_buffer_make(0);
     mutt_buffer_addstr(&buf, "test");
     TEST_CHECK(mutt_buffer_printf(&buf, str) == 5);
     TEST_CHECK(strcmp(mutt_b2s(&buf), str) == 0);
@@ -95,7 +95,7 @@ void test_mutt_buffer_printf(void)
         "apple banana cherry damson elderberry fig guava hawthorn ilama "
         "jackfruit kumquat lemon mango nectarine olive papaya quince raspberry "
         "strawberry tangerine ugli vanilla wolfberry xigua yew ziziphus";
-    struct Buffer buf = { 0 };
+    struct Buffer buf = mutt_buffer_make(0);
     mutt_buffer_addstr(&buf, "test");
     TEST_CHECK(mutt_buffer_printf(&buf, str) == 195);
     TEST_CHECK(strcmp(mutt_b2s(&buf), str) == 0);
@@ -106,7 +106,7 @@ void test_mutt_buffer_printf(void)
     TEST_CASE("Varargs");
     const char *str = "apple";
     const char *result = "app 1234567 3.1416";
-    struct Buffer buf = { 0 };
+    struct Buffer buf = mutt_buffer_make(0);
     mutt_buffer_addstr(&buf, "test");
     TEST_CHECK(mutt_buffer_printf(&buf, "%.3s %ld %3.4f", str, 1234567, 3.141592654) == 18);
     TEST_CHECK(strcmp(mutt_b2s(&buf), result) == 0);
index 23ec13ad6c119813acc8a465e48be69050906c61..52b30676cb76d0b821dd96a127ea27a4b6275607 100644 (file)
@@ -35,13 +35,13 @@ void test_mutt_buffer_reset(void)
   }
 
   {
-    struct Buffer buf = { 0 };
+    struct Buffer buf = mutt_buffer_make(0);
     mutt_buffer_reset(&buf);
     TEST_CHECK_(1, "mutt_buffer_reset(buf)");
   }
 
   {
-    struct Buffer buf = { 0 };
+    struct Buffer buf = mutt_buffer_make(0);
     mutt_buffer_addstr(&buf, "test");
     mutt_buffer_reset(&buf);
     TEST_CHECK_(1, "mutt_buffer_reset(buf)");
index c4b09cd035af7ac5ed1d8e889a695dca64fef8ef..986fe0bb0f89117233a95b0a49fcd5b04e5ca565 100644 (file)
@@ -35,7 +35,7 @@ void test_mutt_buffer_strcpy(void)
   }
 
   {
-    struct Buffer buf = { 0 };
+    struct Buffer buf = mutt_buffer_make(0);
     mutt_buffer_strcpy(&buf, NULL);
     TEST_CHECK_(1, "mutt_buffer_strcpy(&buf, NULL)");
   }
@@ -44,7 +44,7 @@ void test_mutt_buffer_strcpy(void)
 
   {
     TEST_CASE("Empty");
-    struct Buffer buf = { 0 };
+    struct Buffer buf = mutt_buffer_make(0);
     mutt_buffer_strcpy(&buf, "");
     TEST_CHECK(strcmp(mutt_b2s(&buf), "") == 0);
     mutt_buffer_dealloc(&buf);
@@ -53,7 +53,7 @@ void test_mutt_buffer_strcpy(void)
   {
     TEST_CASE("String");
     const char *str = "test";
-    struct Buffer buf = { 0 };
+    struct Buffer buf = mutt_buffer_make(0);
     mutt_buffer_strcpy(&buf, str);
     TEST_CHECK(strcmp(mutt_b2s(&buf), str) == 0);
     mutt_buffer_dealloc(&buf);
@@ -63,7 +63,7 @@ void test_mutt_buffer_strcpy(void)
 
   {
     TEST_CASE("Empty");
-    struct Buffer buf = { 0 };
+    struct Buffer buf = mutt_buffer_make(0);
     mutt_buffer_addstr(&buf, "test");
     mutt_buffer_strcpy(&buf, "");
     TEST_CHECK(strcmp(mutt_b2s(&buf), "") == 0);
@@ -73,7 +73,7 @@ void test_mutt_buffer_strcpy(void)
   {
     TEST_CASE("String");
     const char *str = "apple";
-    struct Buffer buf = { 0 };
+    struct Buffer buf = mutt_buffer_make(0);
     mutt_buffer_addstr(&buf, "test");
     mutt_buffer_strcpy(&buf, str);
     TEST_CHECK(strcmp(mutt_b2s(&buf), str) == 0);
index e0bc316a9bb6f135672073e140983102a8927b1c..f09b70df5fe983b7722b718bf315063dfdee20cd 100644 (file)
@@ -35,7 +35,7 @@ void test_mutt_buffer_strcpy_n(void)
   }
 
   {
-    struct Buffer buf = { 0 };
+    struct Buffer buf = mutt_buffer_make(0);
     mutt_buffer_strcpy_n(&buf, NULL, 3);
     TEST_CHECK_(1, "mutt_buffer_strcpy_n(&buf, NULL, 3)");
   }
@@ -50,7 +50,7 @@ void test_mutt_buffer_strcpy_n(void)
     for (size_t i = 0; i < mutt_array_size(sizes); i++)
     {
       TEST_CASE_("%ld", sizes[i]);
-      struct Buffer buf = { 0 };
+      struct Buffer buf = mutt_buffer_make(0);
       mutt_buffer_strcpy_n(&buf, str, sizes[i]);
       TEST_CHECK(strlen(mutt_b2s(&buf)) == MIN(len, sizes[i]));
       TEST_CHECK(strncmp(mutt_b2s(&buf), str, sizes[i]) == 0);
@@ -69,7 +69,7 @@ void test_mutt_buffer_strcpy_n(void)
     for (size_t i = 0; i < mutt_array_size(sizes); i++)
     {
       TEST_CASE_("%ld", sizes[i]);
-      struct Buffer buf = { 0 };
+      struct Buffer buf = mutt_buffer_make(0);
       mutt_buffer_addstr(&buf, base);
       mutt_buffer_strcpy_n(&buf, str, sizes[i]);
       TEST_CHECK(strlen(mutt_b2s(&buf)) == MIN(len, sizes[i]));
index ddec4763154b7bd231d79c98b0eba4abf9da2223..4a12c97ec5897d36f8978a6eb706dfc04d0471bc 100644 (file)
@@ -30,12 +30,12 @@ void test_mutt_ch_lookup_add(void)
   // bool mutt_ch_lookup_add(enum LookupType type, const char *pat, const char *replace, struct Buffer *err);
 
   {
-    struct Buffer buf = { 0 };
+    struct Buffer buf = mutt_buffer_make(0);
     TEST_CHECK(!mutt_ch_lookup_add(0, NULL, "banana", &buf));
   }
 
   {
-    struct Buffer buf = { 0 };
+    struct Buffer buf = mutt_buffer_make(0);
     TEST_CHECK(!mutt_ch_lookup_add(0, "apple", NULL, &buf));
   }
 
index 34ca98e5ad96aa1575504c18c13a39c3849e977e..ce2bd3e3fecf55a4bd3ee7b85896209b736e368b 100644 (file)
@@ -87,7 +87,7 @@ bool test_pretty_var(void)
   // size_t pretty_var(const char *str, struct Buffer *buf);
 
   {
-    struct Buffer buf = { 0 };
+    struct Buffer buf = mutt_buffer_make(0);
     if (!TEST_CHECK(pretty_var(NULL, &buf) == 0))
       return false;
   }
@@ -98,8 +98,7 @@ bool test_pretty_var(void)
   }
 
   {
-    struct Buffer buf = { 0 };
-    mutt_buffer_alloc(&buf, 64);
+    struct Buffer buf = mutt_buffer_make(64);
     if (!TEST_CHECK(pretty_var("apple", &buf) > 0))
     {
       mutt_buffer_dealloc(&buf);
@@ -128,7 +127,7 @@ bool test_escape_string(void)
   }
 
   {
-    struct Buffer buf = { 0 };
+    struct Buffer buf = mutt_buffer_make(0);
     if (!TEST_CHECK(escape_string(&buf, NULL) == 0))
       return false;
   }
@@ -137,8 +136,7 @@ bool test_escape_string(void)
     const char *before = "apple\nbanana\rcherry\tdamson\\endive\"fig'grape";
     const char *after =
         "apple\\nbanana\\rcherry\\tdamson\\\\endive\\\"fig'grape";
-    struct Buffer buf = { 0 };
-    mutt_buffer_alloc(&buf, 256);
+    struct Buffer buf = mutt_buffer_make(256);
     if (!TEST_CHECK(escape_string(&buf, before) > 0))
     {
       mutt_buffer_dealloc(&buf);
@@ -238,9 +236,9 @@ bool test_dump_config_neo(void)
 
     struct HashElem *he = cs_get_elem(cs, "Banana");
 
-    struct Buffer buf_val = { 0 };
+    struct Buffer buf_val = mutt_buffer_make(0);
     mutt_buffer_addstr(&buf_val, "yes");
-    struct Buffer buf_init = { 0 };
+    struct Buffer buf_init = mutt_buffer_make(0);
     mutt_buffer_addstr(&buf_init, "yes");
 
     FILE *fp = fopen("/dev/null", "w");
index a7d169c9ef38f8a4057f923a3ad002845f17b756..9e8655c4953fbfc649e040126428e11a06796d01 100644 (file)
@@ -36,14 +36,13 @@ void test_mutt_buffer_file_expand_fmt_quote(void)
   }
 
   {
-    struct Buffer buf = { 0 };
+    struct Buffer buf = mutt_buffer_make(0);
     mutt_buffer_file_expand_fmt_quote(&buf, NULL, "banana");
     TEST_CHECK_(1, "mutt_buffer_file_expand_fmt_quote(&buf, NULL, \"banana\")");
   }
 
   {
-    struct Buffer buf = { 0 };
-    mutt_buffer_alloc(&buf, 32);
+    struct Buffer buf = mutt_buffer_make(32);
     mutt_buffer_file_expand_fmt_quote(&buf, "apple", NULL);
     TEST_CHECK_(1, "mutt_buffer_file_expand_fmt_quote(&buf, \"apple\", NULL)");
     mutt_buffer_dealloc(&buf);
index 12e7db79727b6a3479092858ed742243352a1d4b..b6c42508bbdf41c7c6625e5eb02a438fafdebd9f 100644 (file)
@@ -35,7 +35,7 @@ void test_mutt_buffer_quote_filename(void)
   }
 
   {
-    struct Buffer buf = { 0 };
+    struct Buffer buf = mutt_buffer_make(0);
     mutt_buffer_quote_filename(&buf, NULL, false);
     TEST_CHECK_(1, "mutt_buffer_quote_filename(&buf, NULL, false)");
   }
index 5758071ae624b2c102687f2f21800ca1bee69099..7a52168beff5edb62b795087df7e802534aefb1c 100644 (file)
@@ -35,13 +35,13 @@ void test_mutt_file_expand_fmt(void)
   }
 
   {
-    struct Buffer buf = { 0 };
+    struct Buffer buf = mutt_buffer_make(0);
     mutt_file_expand_fmt(&buf, NULL, "banana");
     TEST_CHECK_(1, "mutt_file_expand_fmt(&buf, NULL, \"banana\")");
   }
 
   {
-    struct Buffer buf = { 0 };
+    struct Buffer buf = mutt_buffer_make(0);
     mutt_file_expand_fmt(&buf, "apple", NULL);
     TEST_CHECK_(1, "mutt_file_expand_fmt(&buf, \"apple\", NULL)");
   }
index d67c0d7e94f199473a08ec4828adad31f85a02f0..7fa60a5a1a4db9c6577b98255af1626a0229b5e9 100644 (file)
@@ -34,7 +34,7 @@ void test_mutt_file_sanitize_regex(void)
   }
 
   {
-    struct Buffer buf = { 0 };
+    struct Buffer buf = mutt_buffer_make(0);
     TEST_CHECK(mutt_file_sanitize_regex(&buf, NULL) != 0);
   }
 }
index 84cce91931a001f923178599448b40018d16abcf..8e608c80b50a7f5ded48fe9325a672bd77d8b5ce 100644 (file)
@@ -31,13 +31,13 @@ void test_mutt_grouplist_add_regex(void)
   // int mutt_grouplist_add_regex(struct GroupList *head, const char *s, int flags, struct Buffer *err);
 
   {
-    struct Buffer err = { 0 };
+    struct Buffer err = mutt_buffer_make(0);
     TEST_CHECK(mutt_grouplist_add_regex(NULL, "apple", 0, &err) == -1);
   }
 
   {
     struct GroupList head = { 0 };
-    struct Buffer err = { 0 };
+    struct Buffer err = mutt_buffer_make(0);
     TEST_CHECK(mutt_grouplist_add_regex(&head, NULL, 0, &err) == -1);
   }
 
index 2eb63749affca331505ab887d9db8b43e9f9d797..b884dfad8f8646aa8b17ea355bdc66730de16698 100644 (file)
@@ -35,7 +35,7 @@ void test_mutt_path_getcwd(void)
   }
 
   {
-    struct Buffer buf = { 0 };
+    struct Buffer buf = mutt_buffer_make(0);
     mutt_path_getcwd(&buf);
     TEST_CHECK(buf.data[0] == '/');
     mutt_buffer_dealloc(&buf);
index 6e2d20ef7a2c220c29b007590ec5a4f2c67f1336..781cbc44a47c10dfc77134503d9e9d2c08dc5f35 100644 (file)
@@ -172,8 +172,7 @@ static int cmp_pattern(struct PatternList *p1, struct PatternList *p2)
 
 void test_mutt_pattern_comp(void)
 {
-  struct Buffer err = { 0 };
-  mutt_buffer_alloc(&err, 1024);
+  struct Buffer err = mutt_buffer_make(1024);
 
   { /* empty */
     char *s = "";
index 1827ec74be91457165243d16cc2b5754b7dead3c..0ec7926f4b44c97a2ba302bc516f87f032a06220 100644 (file)
@@ -9,7 +9,7 @@ static bool test_simple_cases(void)
 {
   log_line(__func__);
 
-  struct Buffer buf = { 0 };
+  struct Buffer buf = mutt_buffer_make(0);
   { /* handle edge cases */
     struct Regex *rx = regex_new("hello bob", 0, &buf);
 
@@ -71,7 +71,7 @@ static bool test_old_implementation(void)
   const char *bob_line = "definitely bob haha";
   const char *not_bob_line = "john dave marty nothing else here";
 
-  struct Buffer buf = { 0 };
+  struct Buffer buf = mutt_buffer_make(0);
   {
     // from: if (regexec(C_PgpGoodSign->regex, bob_line, 0, NULL, 0) == 0)
     //   to: if (mutt_regex_match(C_PgpGoodSign, bob_line))
index c05b3058960ca5a87ce359acc6c64e5e75b58321..bdf03316474f728e8809dee180845e2f9c5167fc 100644 (file)
@@ -30,7 +30,7 @@ void test_mutt_regex_new(void)
   // struct Regex *mutt_regex_new(const char *str, int flags, struct Buffer *err);
 
   {
-    struct Buffer buf = { 0 };
+    struct Buffer buf = mutt_buffer_make(0);
     TEST_CHECK(!mutt_regex_new(NULL, 0, &buf));
   }
 
index d6abfa2bc3147689a2d52a3541e898019f4a7fda..603411925a33e8ed614ee1d418b9a30f5065f8db 100644 (file)
@@ -30,13 +30,13 @@ void test_mutt_regexlist_add(void)
   // int mutt_regexlist_add(struct RegexList *rl, const char *str, int flags, struct Buffer *err);
 
   {
-    struct Buffer buf = { 0 };
+    struct Buffer buf = mutt_buffer_make(0);
     TEST_CHECK(mutt_regexlist_add(NULL, "apple", 0, &buf) == 0);
   }
 
   {
     struct RegexList regexlist = { 0 };
-    struct Buffer buf = { 0 };
+    struct Buffer buf = mutt_buffer_make(0);
     TEST_CHECK(mutt_regexlist_add(&regexlist, NULL, 0, &buf) == 0);
   }
 
index 65d490b29c8aa4c09e8e5b013ce6c46e36ec1628..77bbd721094490a64e23aed1b7a7f3f469b13fac 100644 (file)
@@ -30,19 +30,19 @@ void test_mutt_replacelist_add(void)
   // int mutt_replacelist_add(struct ReplaceList *rl, const char *pat, const char *templ, struct Buffer *err);
 
   {
-    struct Buffer buf = { 0 };
+    struct Buffer buf = mutt_buffer_make(0);
     TEST_CHECK(mutt_replacelist_add(NULL, "apple", "banana", &buf) == 0);
   }
 
   {
     struct ReplaceList replacelist = { 0 };
-    struct Buffer buf = { 0 };
+    struct Buffer buf = mutt_buffer_make(0);
     TEST_CHECK(mutt_replacelist_add(&replacelist, NULL, "banana", &buf) == 0);
   }
 
   {
     struct ReplaceList replacelist = { 0 };
-    struct Buffer buf = { 0 };
+    struct Buffer buf = mutt_buffer_make(0);
     TEST_CHECK(mutt_replacelist_add(&replacelist, "apple", NULL, &buf) == 0);
   }
 
index cc7521b24512b1e8c8c736028a3bce4093653e9e..71f47a397707fe8b494f35fc01b674ab804a714e 100644 (file)
@@ -32,7 +32,7 @@ void test_url_tobuffer(void)
   // int url_tobuffer(struct Url *u, struct Buffer *buf, int flags);
 
   {
-    struct Buffer buf = { 0 };
+    struct Buffer buf = mutt_buffer_make(0);
     TEST_CHECK(url_tobuffer(NULL, &buf, 0) != 0);
   }