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

[PATCH v2 4/6] vcs-svn: prefer strstr over memmem

From
David Barr <davidbarr@google.com>
Date
May 31, 2012, 14:41 UTC
Message-ID
<1338475290-22644-5-git-send-email-davidbarr@google.com>
In-Reply-To
<1338475290-22644-1-git-send-email-davidbarr@google.com>

The common pattern is to use strstr to match a fixed needle. As a bonus, elimate dependency on memmem for upstream.

Signed-off-by: David Barr <davidbarr@google.com>
---
 vcs-svn/fast_export.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/vcs-svn/fast_export.c b/vcs-svn/fast_export.c
index b823b85..cda37dd 100644
--- a/vcs-svn/fast_export.c
+++ b/vcs-svn/fast_export.c
@@ -163,7 +163,7 @@ static int parse_cat_response_line(const char *header, off_t *len)
 
 	if (ends_with(header, headerlen, " missing"))
 		return error("cat-blob reports missing blob: %s", header);
-	type = memmem(header, headerlen, " blob ", strlen(" blob "));
+	type = strstr(header, " blob ");
 	if (!type)
 		return error("cat-blob header has wrong object type: %s", header);
 	n = strtoumax(type + strlen(" blob "), (char **) &end, 10);
-- 
1.7.10.2
Previous: David Michael BarrNext: David Barr
Message 7 of 10 in “vcs-svn: housekeeping”
  1. 0/6 vcs-svn: housekeepingDavid Barr, May 31, 2012
  2. 1/6 vcs-svn: fix clang-analyzer errorDavid Barr, May 31, 2012
  3. 2/6 vcs-svn: simplify cleanup in apply_one_window()David Barr, May 31, 2012
  4. 3/6 vcs-svn: prefer constcmp to prefixcmpDavid Barr, May 31, 2012
  5. Junio C HamanoJun 1, 2012
  6. David Michael BarrJun 1, 2012
  7. 4/6 vcs-svn: prefer strstr over memmemDavid Barr, May 31, 2012
  8. 5/6 vcs-svn: fix signedness warningsDavid Barr, May 31, 2012
  9. 6/6 vcs-svn: drop no-op reset methodsDavid Barr, May 31, 2012
  10. David Michael BarrJun 1, 2012

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.