Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
imap-send: store all_msgs as a strbuf
author
Michael Haggerty
<mhagger@alum.mit.edu>
Sun, 25 Nov 2012 11:08:37 +0000
(12:08 +0100)
committer
Junio C Hamano
<gitster@pobox.com>
Mon, 26 Nov 2012 21:32:13 +0000
(13:32 -0800)
all_msgs is only used as a glorified string, therefore there is no
reason to declare it as a struct msg_data.
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
imap-send.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
32a8569
)
diff --git
a/imap-send.c
b/imap-send.c
index c818b0c7ea226599d43f2611d77a88acf308df1d..50e223a2a44e94bc3b62734519e0896aabc6e655 100644
(file)
--- a/
imap-send.c
+++ b/
imap-send.c
@@
-1391,26
+1391,20
@@
static void wrap_in_html(struct msg_data *msg)
#define CHUNKSIZE 0x1000
#define CHUNKSIZE 0x1000
-static int read_message(FILE *f, struct
msg_data *msg
)
+static int read_message(FILE *f, struct
strbuf *all_msgs
)
{
{
- struct strbuf buf = STRBUF_INIT;
-
- memset(msg, 0, sizeof(*msg));
-
do {
do {
- if (strbuf_fread(
&buf
, CHUNKSIZE, f) <= 0)
+ if (strbuf_fread(
all_msgs
, CHUNKSIZE, f) <= 0)
break;
} while (!feof(f));
break;
} while (!feof(f));
- msg->len = buf.len;
- msg->data = strbuf_detach(&buf, NULL);
- return msg->len;
+ return all_msgs->len;
}
}
-static int count_messages(struct
msg_data *msg
)
+static int count_messages(struct
strbuf *all_msgs
)
{
int count = 0;
{
int count = 0;
- char *p =
msg->data
;
+ char *p =
all_msgs->buf
;
while (1) {
if (!prefixcmp(p, "From ")) {
while (1) {
if (!prefixcmp(p, "From ")) {
@@
-1431,7
+1425,7
@@
static int count_messages(struct msg_data *msg)
return count;
}
return count;
}
-static int split_msg(struct
msg_data
*all_msgs, struct msg_data *msg, int *ofs)
+static int split_msg(struct
strbuf
*all_msgs, struct msg_data *msg, int *ofs)
{
char *p, *data;
{
char *p, *data;
@@
-1439,7
+1433,7
@@
static int split_msg(struct msg_data *all_msgs, struct msg_data *msg, int *ofs)
if (*ofs >= all_msgs->len)
return 0;
if (*ofs >= all_msgs->len)
return 0;
- data = &all_msgs->
data
[*ofs];
+ data = &all_msgs->
buf
[*ofs];
msg->len = all_msgs->len - *ofs;
if (msg->len < 5 || prefixcmp(data, "From "))
msg->len = all_msgs->len - *ofs;
if (msg->len < 5 || prefixcmp(data, "From "))
@@
-1509,7
+1503,8
@@
static int git_imap_config(const char *key, const char *val, void *cb)
int main(int argc, char **argv)
{
int main(int argc, char **argv)
{
- struct msg_data all_msgs, msg;
+ struct strbuf all_msgs = STRBUF_INIT;
+ struct msg_data msg;
struct store *ctx = NULL;
int ofs = 0;
int r;
struct store *ctx = NULL;
int ofs = 0;
int r;