# include "config.h"
#endif
+#include <lib-lib/mem.h>
+
#include "mutt.h"
#include "enter.h"
#include "mx.h"
#endif
#include "sidebar.h"
-#include "lib/mem.h"
#include "lib/intl.h"
#include "lib/str.h"
#include "lib/list.h"
{N_("Chdir"), OP_CHANGE_DIRECTORY},
{N_("Mask"), OP_ENTER_MASK},
{N_("Help"), OP_HELP},
- {NULL}
+ {NULL, OP_NULL}
};
#ifdef USE_NNTP
{N_("Catchup"), OP_CATCHUP},
{N_("Mask"), OP_ENTER_MASK},
{N_("Help"), OP_HELP},
- {NULL}
+ {NULL, OP_NULL}
};
#endif
int c;
for (c = 0; c < state->entrylen; c++) {
- mem_free (&((state->entry)[c].name));
- mem_free (&((state->entry)[c].desc));
- mem_free (&((state->entry)[c].st));
+ p_delete(&((state->entry)[c].name));
+ p_delete(&((state->entry)[c].desc));
+ p_delete(&((state->entry)[c].st));
}
#ifdef USE_IMAP
- mem_free (&state->folder);
+ p_delete(&state->folder);
#endif
- mem_free (&state->entry);
+ p_delete(&state->entry);
}
static int browser_compare_subject (const void *a, const void *b)
const char *elsestring,
unsigned long data, format_flag flags)
{
- char fn[SHORT_STRING], tmp[SHORT_STRING], permission[11];
- char date[16], *t_fmt;
+ char fn[SHORT_STRING], tmp[SHORT_STRING], permission[11], date[16];
+ const char *t_fmt;
time_t tnow;
FOLDER *folder = (FOLDER *) data;
struct passwd *pw;
case 'f':
{
- char *s;
+ const char *s;
#ifdef USE_IMAP
if (folder->ff->imap)
{
if (state->entrylen == state->entrymax) {
/* need to allocate more space */
- mem_realloc (&state->entry,
- sizeof (struct folder_file) * (state->entrymax += 256));
- memset (&state->entry[state->entrylen], 0,
- sizeof (struct folder_file) * 256);
+ p_realloc(&state->entry, state->entrymax += 256);
+ p_clear(&state->entry[state->entrylen], 256);
if (m)
m->data = state->entry;
}
if (s != NULL) {
- (state->entry)[state->entrylen].mode = s->st_mode;
+ (state->entry)[state->entrylen].mode = s->st_mode;
(state->entry)[state->entrylen].mtime = s->st_mtime;
- (state->entry)[state->entrylen].size = s->st_size;
-
- (state->entry)[state->entrylen].st = mem_malloc (sizeof (struct stat));
- memcpy ((state->entry)[state->entrylen].st, s, sizeof (struct stat));
+ (state->entry)[state->entrylen].size = s->st_size;
+ (state->entry)[state->entrylen].st = p_dup(s, 1);
}
(state->entry)[state->entrylen].new = new;
{
state->entrylen = 0;
state->entrymax = 256;
- state->entry =
- (struct folder_file *) mem_calloc (state->entrymax,
- sizeof (struct folder_file));
+ state->entry = p_new(struct folder_file, state->entrymax);
#ifdef USE_IMAP
state->imap_browse = 0;
#endif
init_state (&state, NULL);
state.imap_browse = 1;
imap_browse (LastDir, &state);
+ browser_sort (&state);
}
#endif
}
init_state (&state, NULL);
state.imap_browse = 1;
imap_browse (LastDir, &state);
+ browser_sort (&state);
menu->data = state.entry;
}
else
if (menu->tagged) {
*numfiles = menu->tagged;
- tfiles = mem_calloc (*numfiles, sizeof (char *));
+ tfiles = p_new(char *, *numfiles);
for (i = 0, j = 0; i < state.entrylen; i++) {
struct folder_file ff = state.entry[i];
char full[_POSIX_PATH_MAX];
}
else if (f[0]) { /* no tagged entries. return selected entry */
*numfiles = 1;
- tfiles = mem_calloc (*numfiles, sizeof (char *));
+ tfiles = p_new(char *, *numfiles);
mutt_expand_path (f, flen);
tfiles[0] = str_dup (f);
*files = tfiles;
init_state (&state, NULL);
state.imap_browse = 1;
imap_browse (LastDir, &state);
+ browser_sort (&state);
menu->data = state.entry;
menu->current = 0;
menu->top = 0;
init_state (&state, NULL);
state.imap_browse = 1;
imap_browse (LastDir, &state);
+ browser_sort (&state);
menu->data = state.entry;
menu->current = 0;
menu->top = 0;
if (mutt_yesorno (msg, M_NO) == M_YES) {
if (!imap_delete_mailbox (Context, mx)) {
/* free the mailbox from the browser */
- mem_free (&((state.entry)[nentry].name));
- mem_free (&((state.entry)[nentry].desc));
+ p_delete(&((state.entry)[nentry].name));
+ p_delete(&((state.entry)[nentry].desc));
/* and move all other entries up */
if (nentry + 1 < state.entrylen)
memmove (state.entry + nentry, state.entry + nentry + 1,
}
else
mutt_message _("Mailbox not deleted.");
- mem_free (&mx.mbox);
+ p_delete(&mx.mbox);
}
break;
#endif
init_state (&state, NULL);
state.imap_browse = 1;
imap_browse (LastDir, &state);
+ browser_sort (&state);
menu->data = state.entry;
menu->current = 0;
menu->top = 0;
strfcpy (buf, NONULL (Mask.pattern), sizeof (buf));
if (mutt_get_field (_("File Mask: "), buf, sizeof (buf), 0) == 0) {
- regex_t *rx = (regex_t *) mem_malloc (sizeof (regex_t));
+ regex_t *rx = p_new(regex_t, 1);
char *s = buf;
int not = 0, err;
if ((err = REGCOMP (rx, s, REG_NOSUB)) != 0) {
regerror (err, rx, buf, sizeof (buf));
regfree (rx);
- mem_free (&rx);
+ p_delete(&rx);
mutt_error ("%s", buf);
}
else {
str_replace (&Mask.pattern, buf);
regfree (Mask.rx);
- mem_free (&Mask.rx);
+ p_delete(&Mask.rx);
Mask.rx = rx;
Mask.not = not;
init_state (&state, NULL);
state.imap_browse = 1;
imap_browse (LastDir, &state);
+ browser_sort (&state);
menu->data = state.entry;
init_menu (&state, menu, title, sizeof (title), buffy);
}
init_state (&state, NULL);
state.imap_browse = 1;
imap_browse (LastDir, &state);
+ browser_sort (&state);
menu->data = state.entry;
}
#endif
folder.ff->st = NULL;
folder.ff->is_new = nd->new;
folder.ff->nd = nd;
- mem_free (&f->desc);
+ p_delete(&f->desc);
mutt_FormatString (buffer, sizeof (buffer), NONULL(GroupFormat),
newsgroup_format_str, (unsigned long) &folder,
M_FORMAT_ARROWCURSOR);
case OP_SUBSCRIBE_PATTERN:
case OP_UNSUBSCRIBE_PATTERN:
if (option (OPTNEWS)) {
- regex_t *rx = (regex_t *) mem_malloc (sizeof (regex_t));
+ regex_t *rx = p_new(regex_t, 1);
char *s = buf;
int j = menu->current;
NNTP_DATA *nd;
else
snprintf (tmp, sizeof (tmp), _("Unsubscribe pattern: "));
if (mutt_get_field (tmp, buf, sizeof (buf), 0) != 0 || !buf[0]) {
- mem_free (&rx);
+ p_delete(&rx);
break;
}
if ((err = REGCOMP (rx, s, REG_NOSUB)) != 0) {
regerror (err, rx, buf, sizeof (buf));
regfree (rx);
- mem_free (&rx);
+ p_delete(&rx);
mutt_error ("%s", buf);
break;
}
folder.f = NULL;
folder.new = nd->new;
folder.nd = nd;
- mem_free (&f->desc);
+ p_delete(&f->desc);
mutt_FormatString (buffer, sizeof (buffer), NONULL(GroupFormat),
newsgroup_format_str, (unsigned long) &folder,
M_FORMAT_ARROWCURSOR);
nntp_clear_cacheindex (news);
if (i != OP_BROWSER_SUBSCRIBE && i != OP_BROWSER_UNSUBSCRIBE)
regfree (rx);
- mem_free (&rx);
+ p_delete(&rx);
}
#ifdef USE_IMAP
else