From: Pietro Cerutti Date: Tue, 27 Aug 2019 12:47:52 +0000 (+0000) Subject: Add mutt_buffer_make to create a Buffer on the stack X-Git-Tag: 2019-10-25~64^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1c114855a5656e05cc0fb26a610e72decbd58612;p=neomutt Add mutt_buffer_make to create a Buffer on the stack --- diff --git a/color.c b/color.c index 47a233c44..574c8a8b5 100644 --- 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); diff --git a/commands.c b/commands.c index 1733e705c..fef2d1a7a 100644 --- a/commands.c +++ b/commands.c @@ -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); diff --git a/config/dump.c b/config/dump.c index c64aa28e5..02244455c 100644 --- a/config/dump.c +++ b/config/dump.c @@ -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++) { diff --git a/config/set.c b/config/set.c index d1cc0fd63..e4c76924a 100644 --- a/config/set.c +++ b/config/set.c @@ -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; diff --git a/email/rfc2047.c b/email/rfc2047.c index 99ce89875..a0ae382c3 100644 --- a/email/rfc2047.c +++ b/email/rfc2047.c @@ -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 65198f04d..87f10d3b1 100644 --- 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; diff --git a/icommands.c b/icommands.c index acaacb2be..c7743e9d5 100644 --- a/icommands.c +++ b/icommands.c @@ -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); diff --git a/imap/imap.c b/imap/imap.c index cd531fa80..ee45364e9 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -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 ("); diff --git a/imap/util.c b/imap/util.c index c3d6b22f7..1e54281c8 100644 --- a/imap/util.c +++ b/imap/util.c @@ -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 d00bc6992..e32d1fda0 100644 --- 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 6713d0e0b..b20266d2c 100644 --- 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) { diff --git a/mutt/buffer.c b/mutt/buffer.c index 0cb146b6a..12c891a5e 100644 --- a/mutt/buffer.c +++ b/mutt/buffer.c @@ -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); } diff --git a/mutt/buffer.h b/mutt/buffer.h index ac2dce56c..e6c732909 100644 --- a/mutt/buffer.h +++ b/mutt/buffer.h @@ -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 diff --git a/mutt/file.c b/mutt/file.c index 8ca002470..080e7a212 100644 --- a/mutt/file.c +++ b/mutt/file.c @@ -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)); diff --git a/mutt/mbyte.c b/mutt/mbyte.c index f66e55668..a16bcff03 100644 --- a/mutt/mbyte.c +++ b/mutt/mbyte.c @@ -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) diff --git a/mutt_lua.c b/mutt_lua.c index ad2179437..563ebd99f 100644 --- a/mutt_lua.c +++ b/mutt_lua.c @@ -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); diff --git a/muttlib.c b/muttlib.c index 7c58ad63e..28547f0ee 100644 --- 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 bb59be246..0e570f41b 100644 --- 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)) diff --git a/test/base64/mutt_b64_buffer_decode.c b/test/base64/mutt_b64_buffer_decode.c index 63acd393e..6d47b799a 100644 --- a/test/base64/mutt_b64_buffer_decode.c +++ b/test/base64/mutt_b64_buffer_decode.c @@ -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); } } diff --git a/test/base64/mutt_b64_buffer_encode.c b/test/base64/mutt_b64_buffer_encode.c index ba75ebe64..fd660c592 100644 --- a/test/base64/mutt_b64_buffer_encode.c +++ b/test/base64/mutt_b64_buffer_encode.c @@ -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); } diff --git a/test/buffer/mutt_buffer_add_printf.c b/test/buffer/mutt_buffer_add_printf.c index a79909c73..71552e97c 100644 --- a/test/buffer/mutt_buffer_add_printf.c +++ b/test/buffer/mutt_buffer_add_printf.c @@ -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); diff --git a/test/buffer/mutt_buffer_addch.c b/test/buffer/mutt_buffer_addch.c index e50569c33..2d59b9da0 100644 --- a/test/buffer/mutt_buffer_addch.c +++ b/test/buffer/mutt_buffer_addch.c @@ -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); diff --git a/test/buffer/mutt_buffer_addstr.c b/test/buffer/mutt_buffer_addstr.c index 528da0a70..224373aa8 100644 --- a/test/buffer/mutt_buffer_addstr.c +++ b/test/buffer/mutt_buffer_addstr.c @@ -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); diff --git a/test/buffer/mutt_buffer_addstr_n.c b/test/buffer/mutt_buffer_addstr_n.c index 0eb1da501..d3e96db81 100644 --- a/test/buffer/mutt_buffer_addstr_n.c +++ b/test/buffer/mutt_buffer_addstr_n.c @@ -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]))); diff --git a/test/buffer/mutt_buffer_alloc.c b/test/buffer/mutt_buffer_alloc.c index 7c766f202..21f0c3bd1 100644 --- a/test/buffer/mutt_buffer_alloc.c +++ b/test/buffer/mutt_buffer_alloc.c @@ -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]); diff --git a/test/buffer/mutt_buffer_concat_path.c b/test/buffer/mutt_buffer_concat_path.c index 26a4a35a0..5c6dd062d 100644 --- a/test/buffer/mutt_buffer_concat_path.c +++ b/test/buffer/mutt_buffer_concat_path.c @@ -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]) diff --git a/test/buffer/mutt_buffer_fix_dptr.c b/test/buffer/mutt_buffer_fix_dptr.c index a4872942f..285a4665c 100644 --- a/test/buffer/mutt_buffer_fix_dptr.c +++ b/test/buffer/mutt_buffer_fix_dptr.c @@ -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))); diff --git a/test/buffer/mutt_buffer_init.c b/test/buffer/mutt_buffer_init.c index 68ca4b247..3838a9130 100644 --- a/test/buffer/mutt_buffer_init.c +++ b/test/buffer/mutt_buffer_init.c @@ -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); } } diff --git a/test/buffer/mutt_buffer_is_empty.c b/test/buffer/mutt_buffer_is_empty.c index 04be31be3..b93995b58 100644 --- a/test/buffer/mutt_buffer_is_empty.c +++ b/test/buffer/mutt_buffer_is_empty.c @@ -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); diff --git a/test/buffer/mutt_buffer_len.c b/test/buffer/mutt_buffer_len.c index 96caf7fe9..b351945f7 100644 --- a/test/buffer/mutt_buffer_len.c +++ b/test/buffer/mutt_buffer_len.c @@ -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); diff --git a/test/buffer/mutt_buffer_printf.c b/test/buffer/mutt_buffer_printf.c index 32c42adfd..24bd7e492 100644 --- a/test/buffer/mutt_buffer_printf.c +++ b/test/buffer/mutt_buffer_printf.c @@ -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); diff --git a/test/buffer/mutt_buffer_reset.c b/test/buffer/mutt_buffer_reset.c index 23ec13ad6..52b30676c 100644 --- a/test/buffer/mutt_buffer_reset.c +++ b/test/buffer/mutt_buffer_reset.c @@ -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)"); diff --git a/test/buffer/mutt_buffer_strcpy.c b/test/buffer/mutt_buffer_strcpy.c index c4b09cd03..986fe0bb0 100644 --- a/test/buffer/mutt_buffer_strcpy.c +++ b/test/buffer/mutt_buffer_strcpy.c @@ -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); diff --git a/test/buffer/mutt_buffer_strcpy_n.c b/test/buffer/mutt_buffer_strcpy_n.c index e0bc316a9..f09b70df5 100644 --- a/test/buffer/mutt_buffer_strcpy_n.c +++ b/test/buffer/mutt_buffer_strcpy_n.c @@ -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])); diff --git a/test/charset/mutt_ch_lookup_add.c b/test/charset/mutt_ch_lookup_add.c index ddec47631..4a12c97ec 100644 --- a/test/charset/mutt_ch_lookup_add.c +++ b/test/charset/mutt_ch_lookup_add.c @@ -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)); } diff --git a/test/config/dump.c b/test/config/dump.c index 34ca98e5a..ce2bd3e3f 100644 --- a/test/config/dump.c +++ b/test/config/dump.c @@ -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"); diff --git a/test/file/mutt_buffer_file_expand_fmt_quote.c b/test/file/mutt_buffer_file_expand_fmt_quote.c index a7d169c9e..9e8655c49 100644 --- a/test/file/mutt_buffer_file_expand_fmt_quote.c +++ b/test/file/mutt_buffer_file_expand_fmt_quote.c @@ -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); diff --git a/test/file/mutt_buffer_quote_filename.c b/test/file/mutt_buffer_quote_filename.c index 12e7db797..b6c42508b 100644 --- a/test/file/mutt_buffer_quote_filename.c +++ b/test/file/mutt_buffer_quote_filename.c @@ -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)"); } diff --git a/test/file/mutt_file_expand_fmt.c b/test/file/mutt_file_expand_fmt.c index 5758071ae..7a52168be 100644 --- a/test/file/mutt_file_expand_fmt.c +++ b/test/file/mutt_file_expand_fmt.c @@ -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)"); } diff --git a/test/file/mutt_file_sanitize_regex.c b/test/file/mutt_file_sanitize_regex.c index d67c0d7e9..7fa60a5a1 100644 --- a/test/file/mutt_file_sanitize_regex.c +++ b/test/file/mutt_file_sanitize_regex.c @@ -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); } } diff --git a/test/group/mutt_grouplist_add_regex.c b/test/group/mutt_grouplist_add_regex.c index 84cce9193..8e608c80b 100644 --- a/test/group/mutt_grouplist_add_regex.c +++ b/test/group/mutt_grouplist_add_regex.c @@ -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); } diff --git a/test/path/mutt_path_getcwd.c b/test/path/mutt_path_getcwd.c index 2eb63749a..b884dfad8 100644 --- a/test/path/mutt_path_getcwd.c +++ b/test/path/mutt_path_getcwd.c @@ -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); diff --git a/test/pattern/comp.c b/test/pattern/comp.c index 6e2d20ef7..781cbc44a 100644 --- a/test/pattern/comp.c +++ b/test/pattern/comp.c @@ -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 = ""; diff --git a/test/regex/mutt_regex_match.c b/test/regex/mutt_regex_match.c index 1827ec74b..0ec7926f4 100644 --- a/test/regex/mutt_regex_match.c +++ b/test/regex/mutt_regex_match.c @@ -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)) diff --git a/test/regex/mutt_regex_new.c b/test/regex/mutt_regex_new.c index c05b30589..bdf033164 100644 --- a/test/regex/mutt_regex_new.c +++ b/test/regex/mutt_regex_new.c @@ -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)); } diff --git a/test/regex/mutt_regexlist_add.c b/test/regex/mutt_regexlist_add.c index d6abfa2bc..603411925 100644 --- a/test/regex/mutt_regexlist_add.c +++ b/test/regex/mutt_regexlist_add.c @@ -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(®exlist, NULL, 0, &buf) == 0); } diff --git a/test/regex/mutt_replacelist_add.c b/test/regex/mutt_replacelist_add.c index 65d490b29..77bbd7210 100644 --- a/test/regex/mutt_replacelist_add.c +++ b/test/regex/mutt_replacelist_add.c @@ -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); } diff --git a/test/url/url_tobuffer.c b/test/url/url_tobuffer.c index cc7521b24..71f47a397 100644 --- a/test/url/url_tobuffer.c +++ b/test/url/url_tobuffer.c @@ -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); }