projects
/
apps
/
madmutt.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
use safer p_clear when possible.
[apps/madmutt.git]
/
query.c
diff --git
a/query.c
b/query.c
index
1443bac
..
1e1937d
100644
(file)
--- a/
query.c
+++ b/
query.c
@@
-11,15
+11,16
@@
# include "config.h"
#endif
# include "config.h"
#endif
+#include <lib-lib/mem.h>
+#include <lib-lib/str.h>
+#include <lib-lib/macros.h>
+
#include "mutt.h"
#include "mutt_menu.h"
#include "mutt_idna.h"
#include "mapping.h"
#include "sort.h"
#include "mutt.h"
#include "mutt_menu.h"
#include "mutt_idna.h"
#include "mapping.h"
#include "sort.h"
-#include "lib/mem.h"
-#include "lib/intl.h"
-#include "lib/str.h"
#include "lib/debug.h"
#include <string.h>
#include "lib/debug.h"
#include <string.h>
@@
-62,7
+63,7
@@
static ADDRESS *result_to_addr (QUERY * r)
tmp = rfc822_cpy_adr (r->addr);
if (!tmp->next && !tmp->personal)
tmp = rfc822_cpy_adr (r->addr);
if (!tmp->next && !tmp->personal)
- tmp->personal =
str_dup
(r->name);
+ tmp->personal =
m_strdup
(r->name);
mutt_addrlist_to_idna (tmp, NULL);
return tmp;
mutt_addrlist_to_idna (tmp, NULL);
return tmp;
@@
-100,11
+101,11
@@
static QUERY *run_query (char *s, int quiet)
if (first == NULL) {
FirstColumn = 0;
SecondColumn = 0;
if (first == NULL) {
FirstColumn = 0;
SecondColumn = 0;
- first =
(QUERY *) mem_calloc (1, sizeof (QUERY)
);
+ first =
p_new(QUERY, 1
);
cur = first;
}
else {
cur = first;
}
else {
- cur->next =
(QUERY *) mem_calloc (1, sizeof (QUERY)
);
+ cur->next =
p_new(QUERY, 1
);
cur = cur->next;
}
cur = cur->next;
}
@@
-118,15
+119,15
@@
static QUERY *run_query (char *s, int quiet)
l = mutt_strwidth (p);
if (l > FirstColumn)
FirstColumn = l;
l = mutt_strwidth (p);
if (l > FirstColumn)
FirstColumn = l;
- cur->name =
str_dup
(p);
+ cur->name =
m_strdup
(p);
p = strtok (NULL, "\t\n");
if (p) {
p = strtok (NULL, "\t\n");
if (p) {
- cur->other =
str_dup
(p);
+ cur->other =
m_strdup
(p);
}
}
}
}
}
}
}
}
-
mem_free
(&buf);
+
p_delete
(&buf);
fclose (fp);
if (mutt_wait_filter (thepid)) {
debug_print (1, ("Error: %s\n", msg));
fclose (fp);
if (mutt_wait_filter (thepid)) {
debug_print (1, ("Error: %s\n", msg));
@@
-185,7
+186,7
@@
static void query_entry (char *s, size_t slen, MUTTMENU * m, int num)
mutt_format_string (buf2, sizeof (buf2),
FirstColumn + 2, FirstColumn + 2,
0, ' ', table[num].data->name,
mutt_format_string (buf2, sizeof (buf2),
FirstColumn + 2, FirstColumn + 2,
0, ' ', table[num].data->name,
-
str_len
(table[num].data->name), 0);
+
m_strlen
(table[num].data->name), 0);
snprintf (s, slen, " %c %3d %s %-*.*s %s",
table[num].tagged ? '*' : ' ',
snprintf (s, slen, " %c %3d %s %-*.*s %s",
table[num].tagged ? '*' : ' ',
@@
-287,8
+288,7
@@
static void query_menu (char *buf, size_t buflen, QUERY * results, int retbuf)
for (queryp = results; queryp; queryp = queryp->next)
menu->max++;
for (queryp = results; queryp; queryp = queryp->next)
menu->max++;
- menu->data = QueryTable =
- (ENTRY *) mem_calloc (menu->max, sizeof (ENTRY));
+ menu->data = QueryTable = p_new(ENTRY, menu->max);
for (i = 0, queryp = results; queryp; queryp = queryp->next, i++)
QueryTable[i].data = queryp;
for (i = 0, queryp = results; queryp; queryp = queryp->next, i++)
QueryTable[i].data = queryp;
@@
-310,14
+310,14
@@
static void query_menu (char *buf, size_t buflen, QUERY * results, int retbuf)
queryp = results;
while (queryp) {
rfc822_free_address (&queryp->addr);
queryp = results;
while (queryp) {
rfc822_free_address (&queryp->addr);
-
mem_free
(&queryp->name);
-
mem_free
(&queryp->other);
+
p_delete
(&queryp->name);
+
p_delete
(&queryp->other);
results = queryp->next;
results = queryp->next;
-
mem_free
(&queryp);
+
p_delete
(&queryp);
queryp = results;
}
results = newresults;
queryp = results;
}
results = newresults;
-
mem_free
(&QueryTable);
+
p_delete
(&QueryTable);
}
else {
/* append */
}
else {
/* append */
@@
-344,8
+344,7
@@
static void query_menu (char *buf, size_t buflen, QUERY * results, int retbuf)
menu->max++;
if (op == OP_QUERY) {
menu->max++;
if (op == OP_QUERY) {
- menu->data = QueryTable =
- (ENTRY *) mem_calloc (menu->max, sizeof (ENTRY));
+ menu->data = QueryTable = p_new(ENTRY, menu->max);
for (i = 0, queryp = results; queryp;
queryp = queryp->next, i++)
for (i = 0, queryp = results; queryp;
queryp = queryp->next, i++)
@@
-355,7
+354,7
@@
static void query_menu (char *buf, size_t buflen, QUERY * results, int retbuf)
int clear = 0;
/* append */
int clear = 0;
/* append */
-
mem_realloc (&QueryTable, menu->max * sizeof (ENTRY)
);
+
p_realloc(&QueryTable, menu->max
);
menu->data = QueryTable;
menu->data = QueryTable;
@@
-433,7
+432,7
@@
static void query_menu (char *buf, size_t buflen, QUERY * results, int retbuf)
int tagged = 0;
size_t curpos = 0;
int tagged = 0;
size_t curpos = 0;
-
memset (buf, 0
, buflen);
+
p_clear(buf
, buflen);
/* check for tagged entries */
for (i = 0; i < menu->max; i++) {
/* check for tagged entries */
for (i = 0; i < menu->max; i++) {
@@
-444,7
+443,7
@@
static void query_menu (char *buf, size_t buflen, QUERY * results, int retbuf)
mutt_addrlist_to_local (tmpa);
tagged = 1;
rfc822_write_address (buf, buflen, tmpa, 0);
mutt_addrlist_to_local (tmpa);
tagged = 1;
rfc822_write_address (buf, buflen, tmpa, 0);
- curpos =
str_len
(buf);
+ curpos =
m_strlen
(buf);
rfc822_free_address (&tmpa);
}
else if (curpos + 2 < buflen) {
rfc822_free_address (&tmpa);
}
else if (curpos + 2 < buflen) {
@@
-454,7
+453,7
@@
static void query_menu (char *buf, size_t buflen, QUERY * results, int retbuf)
strcat (buf, ", "); /* __STRCAT_CHECKED__ */
rfc822_write_address ((char *) buf + curpos + 1,
buflen - curpos - 1, tmpa, 0);
strcat (buf, ", "); /* __STRCAT_CHECKED__ */
rfc822_write_address ((char *) buf + curpos + 1,
buflen - curpos - 1, tmpa, 0);
- curpos =
str_len
(buf);
+ curpos =
m_strlen
(buf);
rfc822_free_address (&tmpa);
}
}
rfc822_free_address (&tmpa);
}
}
@@
-473,13
+472,13
@@
static void query_menu (char *buf, size_t buflen, QUERY * results, int retbuf)
queryp = results;
while (queryp) {
rfc822_free_address (&queryp->addr);
queryp = results;
while (queryp) {
rfc822_free_address (&queryp->addr);
-
mem_free
(&queryp->name);
-
mem_free
(&queryp->other);
+
p_delete
(&queryp->name);
+
p_delete
(&queryp->other);
results = queryp->next;
results = queryp->next;
-
mem_free
(&queryp);
+
p_delete
(&queryp);
queryp = results;
}
queryp = results;
}
-
mem_free
(&QueryTable);
+
p_delete
(&QueryTable);
/* tell whoever called me to redraw the screen when I return */
set_option (OPTNEEDREDRAW);
/* tell whoever called me to redraw the screen when I return */
set_option (OPTNEEDREDRAW);