diff options
author | Benjamin Barenblat <bbaren@google.com> | 2018-11-07 15:10:40 -0500 |
---|---|---|
committer | Benjamin Barenblat <bbaren@google.com> | 2018-11-07 15:10:40 -0500 |
commit | 765c39bea005eaa49852ac1f877ed042ab5b68e6 (patch) | |
tree | cd73d7eea5432f111d04a4d182c839bf1a8c01c4 /src/c/request.c | |
parent | 096fbda34b67cccd2026c44006bd9bc98d28c98c (diff) |
Systems without memmem(3) are getting rarer every day. We can improve
clarity and efficiency by relying on libc’s memmem whenever possible.
Detect at compile time whether the system supports memmem(3); if it
does, simply reexport its prototype through memmem.h and emit no code.
If it doesn’t, actually build in the memmem code in memmem.c.
Along the way, undo the renaming from commit
6dad7c645d8fdb7b7237c89ff7b34e90adbb86b1. Since we’re only creating a
memmem prototype if libc doesn’t define the symbol, our prototype
should never clash with libc’s.
As before, authors should not assume string.h provides a prototype for
memmem; they should `#include "memmem.h"` if they use the function.
Diffstat (limited to 'src/c/request.c')
-rw-r--r-- | src/c/request.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/c/request.c b/src/c/request.c index 3e7ac34c..195b3cdc 100644 --- a/src/c/request.c +++ b/src/c/request.c @@ -11,13 +11,12 @@ #include <pthread.h> +#include "memmem.h" #include "urweb.h" #include "request.h" #define MAX_RETRIES 5 -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); @@ -422,7 +421,7 @@ request_result uw_request(uw_request_context rc, uw_context ctx, } } - part = urweb_memmem(after_sub_headers, body + body_len - after_sub_headers, boundary, boundary_len); + part = 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; |