summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@csail.mit.edu>2016-06-15 11:55:37 -0400
committerGravatar Adam Chlipala <adamc@csail.mit.edu>2016-06-15 11:55:37 -0400
commit6dad7c645d8fdb7b7237c89ff7b34e90adbb86b1 (patch)
tree4dc4d265c551a12ca52f87a75d3f219bdd3ae322
parent4a95c63b1f9778215c515b8c4f66d0c7672c214f (diff)
Rename memmem() to urweb_memmem(), to avoid unintentionally picking up prototype from libc
-rw-r--r--src/c/memmem.c14
-rw-r--r--src/c/request.c4
2 files changed, 10 insertions, 8 deletions
diff --git a/src/c/memmem.c b/src/c/memmem.c
index 891b2117..da3b4990 100644
--- a/src/c/memmem.c
+++ b/src/c/memmem.c
@@ -38,6 +38,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
+// Function renamed by Adam Chlipala in 2016.
+
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD$");
@@ -53,13 +55,17 @@ __RCSID("$NetBSD$");
#endif
/*
- * memmem() returns the location of the first occurence of data
+ * urweb_memmem() returns the location of the first occurence of data
* pattern b2 of size len2 in memory block b1 of size len1 or
* NULL if none is found.
*/
void *
-memmem(const void *b1, size_t len1, const void *b2, size_t len2)
+urweb_memmem(const void *b1, size_t len1, const void *b2, size_t len2)
{
+ /* Sanity check */
+ if(!(b1 != NULL && b2 != NULL && len1 != 0 && len2 != 0))
+ return NULL;
+
/* Initialize search pointer */
char *sp = (char *) b1;
@@ -69,10 +75,6 @@ memmem(const void *b1, size_t len1, const void *b2, size_t len2)
/* Intialize end of search address space pointer */
char *eos = sp + len1 - len2;
- /* Sanity check */
- if(!(b1 != NULL && b2 != NULL && len1 != 0 && len2 != 0))
- return NULL;
-
while (sp <= eos) {
if (*sp == *pp)
if (memcmp(sp, pp, len2) == 0)
diff --git a/src/c/request.c b/src/c/request.c
index cad84cb2..a7f23851 100644
--- a/src/c/request.c
+++ b/src/c/request.c
@@ -16,7 +16,7 @@
#define MAX_RETRIES 5
-void *memmem(const void *b1, size_t len1, const void *b2, size_t len2);
+void *urweb_memmem(const void *b1, size_t len1, const void *b2, size_t len2);
static int try_rollback(uw_context ctx, int will_retry, void *logger_data, uw_logger log_error) {
int r = uw_rollback(ctx, will_retry);
@@ -418,7 +418,7 @@ request_result uw_request(uw_request_context rc, uw_context ctx,
}
}
- part = memmem(after_sub_headers, body + body_len - after_sub_headers, boundary, boundary_len);
+ part = urweb_memmem(after_sub_headers, body + body_len - after_sub_headers, boundary, boundary_len);
if (!part) {
log_error(logger_data, "Missing boundary after multipart payload\n");
return FAILED;