git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 02/14] imap-send.c: remove struct msg_data

From
Michael Haggerty <mhagger@alum.mit.edu>
Date
Jan 15, 2013, 08:06 UTC
Message-ID
<1358237193-8887-3-git-send-email-mhagger@alum.mit.edu>
In-Reply-To
<1358237193-8887-1-git-send-email-mhagger@alum.mit.edu>

Now that its flags member has been deleted, all that is left is a strbuf. So use a strbuf directly.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
---
 imap-send.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)
diff --git a/imap-send.c b/imap-send.c
index f1c8f5a..29c10a4 100644
--- a/imap-send.c
+++ b/imap-send.c
@@ -68,10 +68,6 @@ struct store {
 	int recent; /* # of recent messages - don't trust this beyond the initial read */
 };
 
-struct msg_data {
-	struct strbuf data;
-};
-
 static const char imap_send_usage[] = "git imap-send < <mbox>";
 
 #undef DRV_OK
@@ -1279,7 +1275,7 @@ static void lf_to_crlf(struct strbuf *msg)
  * Store msg to IMAP.  Also detach and free the data from msg->data,
  * leaving msg->data empty.
  */
-static int imap_store_msg(struct store *gctx, struct msg_data *msg)
+static int imap_store_msg(struct store *gctx, struct strbuf *msg)
 {
 	struct imap_store *ctx = (struct imap_store *)gctx;
 	struct imap *imap = ctx->imap;
@@ -1287,11 +1283,11 @@ static int imap_store_msg(struct store *gctx, struct msg_data *msg)
 	const char *prefix, *box;
 	int ret;
 
-	lf_to_crlf(&msg->data);
+	lf_to_crlf(msg);
 	memset(&cb, 0, sizeof(cb));
 
-	cb.dlen = msg->data.len;
-	cb.data = strbuf_detach(&msg->data, NULL);
+	cb.dlen = msg->len;
+	cb.data = strbuf_detach(msg, NULL);
 
 	box = gctx->name;
 	prefix = !strcmp(box, "INBOX") ? "" : ctx->prefix;
@@ -1449,7 +1445,7 @@ static int git_imap_config(const char *key, const char *val, void *cb)
 int main(int argc, char **argv)
 {
 	struct strbuf all_msgs = STRBUF_INIT;
-	struct msg_data msg = {STRBUF_INIT};
+	struct strbuf msg = STRBUF_INIT;
 	struct store *ctx = NULL;
 	int ofs = 0;
 	int r;
@@ -1511,10 +1507,10 @@ int main(int argc, char **argv)
 		unsigned percent = n * 100 / total;
 
 		fprintf(stderr, "%4u%% (%d/%d) done\r", percent, n, total);
-		if (!split_msg(&all_msgs, &msg.data, &ofs))
+		if (!split_msg(&all_msgs, &msg, &ofs))
 			break;
 		if (server.use_html)
-			wrap_in_html(&msg.data);
+			wrap_in_html(&msg);
 		r = imap_store_msg(ctx, &msg);
 		if (r != DRV_OK)
 			break;
-- 
1.8.0.3
Previous: Michael HaggertyNext: Michael Haggerty
Message 3 of 25 in “Remove unused code from imap-send.c”
  1. 00/14 Remove unused code from imap-send.cMichael Haggerty, Jan 15, 2013
  2. 01/14 imap-send.c: remove msg_data::flags, which was always zeroMichael Haggerty, Jan 15, 2013
  3. 02/14 imap-send.c: remove struct msg_dataMichael Haggerty, Jan 15, 2013
  4. 03/14 iamp-send.c: remove unused struct imap_store_confMichael Haggerty, Jan 15, 2013
  5. 04/14 imap-send.c: remove struct store_confMichael Haggerty, Jan 15, 2013
  6. 05/14 imap-send.c: remove struct messageMichael Haggerty, Jan 15, 2013
  7. 06/14 imap-send.c: remove some unused fields from struct storeMichael Haggerty, Jan 15, 2013
  8. Jonathan NiederJan 15, 2013
  9. Junio C HamanoJan 15, 2013
  10. Jonathan NiederJan 15, 2013
  11. Michael HaggertyJan 16, 2013
  12. 07/14 imap-send.c: inline imap_parse_list() in imap_list()Michael Haggerty, Jan 15, 2013
  13. Matt KraaiJan 15, 2013
  14. Michael HaggertyJan 16, 2013
  15. Junio C HamanoJan 16, 2013
  16. Michael HaggertyJan 17, 2013
  17. 08/14 imap-send.c: remove struct imap argument to parse_imap_list_l()Michael Haggerty, Jan 15, 2013
  18. 09/14 imap-send.c: remove namespace fields from struct imapMichael Haggerty, Jan 15, 2013
  19. 10/14 imap-send.c: remove unused field imap_store::trashncMichael Haggerty, Jan 15, 2013
  20. 11/14 imap-send.c: use struct imap_store instead of struct storeMichael Haggerty, Jan 15, 2013
  21. 12/14 imap-send.c: remove unused field imap_store::uidvalidityMichael Haggerty, Jan 15, 2013
  22. 13/14 imap-send.c: fold struct store into struct imap_storeMichael Haggerty, Jan 15, 2013
  23. 14/14 imap-send.c: simplify logic in lf_to_crlf()Michael Haggerty, Jan 15, 2013
  24. Jeff KingJan 15, 2013
  25. Jonathan NiederJan 15, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.