#406: convert remaining relevant memchr calls to VMX_MEMCHR/VMX_HASCHR
This commit is contained in:
parent
af74f27ed9
commit
3f66b79183
|
@ -18,6 +18,9 @@
|
||||||
#include "VideoUtils.h"
|
#include "VideoUtils.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
#include "mozilla-config.h"
|
||||||
|
#include "plvmx.h"
|
||||||
|
|
||||||
// On Android JellyBean, the hardware.h header redefines version_major and
|
// On Android JellyBean, the hardware.h header redefines version_major and
|
||||||
// version_minor, which breaks our build. See:
|
// version_minor, which breaks our build. See:
|
||||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=912702#c6
|
// https://bugzilla.mozilla.org/show_bug.cgi?id=912702#c6
|
||||||
|
@ -115,7 +118,7 @@ bool OggCodecState::AddVorbisComment(MetadataTags* aTags,
|
||||||
const char* aComment,
|
const char* aComment,
|
||||||
uint32_t aLength)
|
uint32_t aLength)
|
||||||
{
|
{
|
||||||
const char* div = (const char*)memchr(aComment, '=', aLength);
|
const char* div = (const char*)VMX_MEMCHR(aComment, '=', aLength);
|
||||||
if (!div) {
|
if (!div) {
|
||||||
LOG(LogLevel::Debug, ("Skipping comment: no separator"));
|
LOG(LogLevel::Debug, ("Skipping comment: no separator"));
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -6,6 +6,9 @@
|
||||||
|
|
||||||
#include "maxp.h"
|
#include "maxp.h"
|
||||||
|
|
||||||
|
#include "mozilla-config.h"
|
||||||
|
#include "plvmx.h"
|
||||||
|
|
||||||
// post - PostScript
|
// post - PostScript
|
||||||
// http://www.microsoft.com/typography/otspec/post.htm
|
// http://www.microsoft.com/typography/otspec/post.htm
|
||||||
|
|
||||||
|
@ -95,7 +98,7 @@ bool ots_post_parse(Font *font, const uint8_t *data, size_t length) {
|
||||||
if (strings + 1 + string_length > strings_end) {
|
if (strings + 1 + string_length > strings_end) {
|
||||||
return OTS_FAILURE_MSG("Bad string length %d", string_length);
|
return OTS_FAILURE_MSG("Bad string length %d", string_length);
|
||||||
}
|
}
|
||||||
if (std::memchr(strings + 1, '\0', string_length)) {
|
if (VMX_HASCHR(strings + 1, '\0', string_length)) {
|
||||||
return OTS_FAILURE_MSG("Bad string of length %d", string_length);
|
return OTS_FAILURE_MSG("Bad string of length %d", string_length);
|
||||||
}
|
}
|
||||||
post->names.push_back(
|
post->names.push_back(
|
||||||
|
|
|
@ -91,6 +91,9 @@
|
||||||
#include "evbuffer-internal.h"
|
#include "evbuffer-internal.h"
|
||||||
#include "bufferevent-internal.h"
|
#include "bufferevent-internal.h"
|
||||||
|
|
||||||
|
#include "mozilla-config.h"
|
||||||
|
#include "plvmx.h"
|
||||||
|
|
||||||
/* some systems do not have MAP_FAILED */
|
/* some systems do not have MAP_FAILED */
|
||||||
#ifndef MAP_FAILED
|
#ifndef MAP_FAILED
|
||||||
#define MAP_FAILED ((void *)-1)
|
#define MAP_FAILED ((void *)-1)
|
||||||
|
@ -1299,7 +1302,7 @@ evbuffer_strchr(struct evbuffer_ptr *it, const char chr)
|
||||||
size_t i = it->_internal.pos_in_chain;
|
size_t i = it->_internal.pos_in_chain;
|
||||||
while (chain != NULL) {
|
while (chain != NULL) {
|
||||||
char *buffer = (char *)chain->buffer + chain->misalign;
|
char *buffer = (char *)chain->buffer + chain->misalign;
|
||||||
char *cp = memchr(buffer+i, chr, chain->off-i);
|
char *cp = VMX_MEMCHR(buffer+i, chr, chain->off-i);
|
||||||
if (cp) {
|
if (cp) {
|
||||||
it->_internal.chain = chain;
|
it->_internal.chain = chain;
|
||||||
it->_internal.pos_in_chain = cp - buffer;
|
it->_internal.pos_in_chain = cp - buffer;
|
||||||
|
@ -1317,7 +1320,12 @@ evbuffer_strchr(struct evbuffer_ptr *it, const char chr)
|
||||||
static inline char *
|
static inline char *
|
||||||
find_eol_char(char *s, size_t len)
|
find_eol_char(char *s, size_t len)
|
||||||
{
|
{
|
||||||
|
#if TENFOURFOX_VMX
|
||||||
|
#warning using accelerated VMX libevent
|
||||||
|
#define CHUNK_SZ 1024
|
||||||
|
#else
|
||||||
#define CHUNK_SZ 128
|
#define CHUNK_SZ 128
|
||||||
|
#endif
|
||||||
/* Lots of benchmarking found this approach to be faster in practice
|
/* Lots of benchmarking found this approach to be faster in practice
|
||||||
* than doing two memchrs over the whole buffer, doin a memchr on each
|
* than doing two memchrs over the whole buffer, doin a memchr on each
|
||||||
* char of the buffer, or trying to emulate memchr by hand. */
|
* char of the buffer, or trying to emulate memchr by hand. */
|
||||||
|
@ -1325,8 +1333,8 @@ find_eol_char(char *s, size_t len)
|
||||||
s_end = s+len;
|
s_end = s+len;
|
||||||
while (s < s_end) {
|
while (s < s_end) {
|
||||||
size_t chunk = (s + CHUNK_SZ < s_end) ? CHUNK_SZ : (s_end - s);
|
size_t chunk = (s + CHUNK_SZ < s_end) ? CHUNK_SZ : (s_end - s);
|
||||||
cr = memchr(s, '\r', chunk);
|
cr = VMX_MEMCHR(s, '\r', chunk);
|
||||||
lf = memchr(s, '\n', chunk);
|
lf = VMX_MEMCHR(s, '\n', chunk);
|
||||||
if (cr) {
|
if (cr) {
|
||||||
if (lf && lf < cr)
|
if (lf && lf < cr)
|
||||||
return lf;
|
return lf;
|
||||||
|
@ -2528,7 +2536,7 @@ evbuffer_search_range(struct evbuffer *buffer, const char *what, size_t len, con
|
||||||
const unsigned char *start_at =
|
const unsigned char *start_at =
|
||||||
chain->buffer + chain->misalign +
|
chain->buffer + chain->misalign +
|
||||||
pos._internal.pos_in_chain;
|
pos._internal.pos_in_chain;
|
||||||
p = memchr(start_at, first,
|
p = VMX_MEMCHR(start_at, first,
|
||||||
chain->off - pos._internal.pos_in_chain);
|
chain->off - pos._internal.pos_in_chain);
|
||||||
if (p) {
|
if (p) {
|
||||||
pos.pos += p - start_at;
|
pos.pos += p - start_at;
|
||||||
|
|
|
@ -24,6 +24,9 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ogg/ogg.h>
|
#include <ogg/ogg.h>
|
||||||
|
|
||||||
|
#include "mozilla-config.h"
|
||||||
|
#include "plvmx.h"
|
||||||
|
|
||||||
/* A complete description of Ogg framing exists in docs/framing.html */
|
/* A complete description of Ogg framing exists in docs/framing.html */
|
||||||
|
|
||||||
int ogg_page_version(const ogg_page *og){
|
int ogg_page_version(const ogg_page *og){
|
||||||
|
@ -735,7 +738,7 @@ long ogg_sync_pageseek(ogg_sync_state *oy,ogg_page *og){
|
||||||
oy->bodybytes=0;
|
oy->bodybytes=0;
|
||||||
|
|
||||||
/* search for possible capture */
|
/* search for possible capture */
|
||||||
next=memchr(page+1,'O',bytes-1);
|
next=VMX_MEMCHR(page+1,'O',bytes-1);
|
||||||
if(!next)
|
if(!next)
|
||||||
next=oy->data+oy->fill;
|
next=oy->data+oy->fill;
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,9 @@
|
||||||
|
|
||||||
#include "gzguts.h"
|
#include "gzguts.h"
|
||||||
|
|
||||||
|
#include "mozilla-config.h"
|
||||||
|
#include "plvmx.h"
|
||||||
|
|
||||||
/* Local functions */
|
/* Local functions */
|
||||||
local int gz_load OF((gz_statep, unsigned char *, unsigned, unsigned *));
|
local int gz_load OF((gz_statep, unsigned char *, unsigned, unsigned *));
|
||||||
local int gz_avail OF((gz_statep));
|
local int gz_avail OF((gz_statep));
|
||||||
|
@ -523,7 +526,7 @@ char * ZEXPORT gzgets(file, buf, len)
|
||||||
|
|
||||||
/* look for end-of-line in current output buffer */
|
/* look for end-of-line in current output buffer */
|
||||||
n = state->x.have > left ? left : state->x.have;
|
n = state->x.have > left ? left : state->x.have;
|
||||||
eol = (unsigned char *)memchr(state->x.next, '\n', n);
|
eol = (unsigned char *)VMX_MEMCHR(state->x.next, '\n', n);
|
||||||
if (eol != NULL)
|
if (eol != NULL)
|
||||||
n = (unsigned)(eol - state->x.next) + 1;
|
n = (unsigned)(eol - state->x.next) + 1;
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,9 @@
|
||||||
#include "mozilla/Preferences.h"
|
#include "mozilla/Preferences.h"
|
||||||
#include "prnetdb.h"
|
#include "prnetdb.h"
|
||||||
|
|
||||||
|
#include "mozilla-config.h"
|
||||||
|
#include "plvmx.h"
|
||||||
|
|
||||||
using namespace mozilla;
|
using namespace mozilla;
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
@ -902,7 +905,7 @@ net_ParseMediaType(const nsACString &aMediaTypeStr,
|
||||||
// include a comma, so this check makes us a bit more tolerant.
|
// include a comma, so this check makes us a bit more tolerant.
|
||||||
|
|
||||||
if (type != typeEnd &&
|
if (type != typeEnd &&
|
||||||
memchr(type, '/', typeEnd - type) != nullptr &&
|
VMX_HASCHR(type, '/', typeEnd - type) &&
|
||||||
(aStrict ? (net_FindCharNotInSet(start + consumed, end, HTTP_LWS) == end) :
|
(aStrict ? (net_FindCharNotInSet(start + consumed, end, HTTP_LWS) == end) :
|
||||||
(strncmp(type, "*/*", typeEnd - type) != 0))) {
|
(strncmp(type, "*/*", typeEnd - type) != 0))) {
|
||||||
// Common case here is that aContentType is empty
|
// Common case here is that aContentType is empty
|
||||||
|
|
|
@ -12,6 +12,9 @@
|
||||||
#include "nsString.h"
|
#include "nsString.h"
|
||||||
#include "nsCRT.h"
|
#include "nsCRT.h"
|
||||||
|
|
||||||
|
#include "mozilla-config.h"
|
||||||
|
#include "plvmx.h"
|
||||||
|
|
||||||
using namespace mozilla;
|
using namespace mozilla;
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
@ -524,7 +527,7 @@ nsAuthURLParser::ParseUserInfo(const char *userinfo, int32_t userinfoLen,
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *p = (const char *) memchr(userinfo, ':', userinfoLen);
|
const char *p = (const char *) VMX_MEMCHR(userinfo, ':', userinfoLen);
|
||||||
if (p) {
|
if (p) {
|
||||||
// userinfo = <username:password>
|
// userinfo = <username:password>
|
||||||
if (p == userinfo) {
|
if (p == userinfo) {
|
||||||
|
|
|
@ -9,6 +9,9 @@
|
||||||
#include "nsHttpChunkedDecoder.h"
|
#include "nsHttpChunkedDecoder.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
#include "mozilla-config.h"
|
||||||
|
#include "plvmx.h"
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace net {
|
namespace net {
|
||||||
|
|
||||||
|
@ -92,7 +95,7 @@ nsHttpChunkedDecoder::ParseChunkRemaining(char *buf,
|
||||||
|
|
||||||
*bytesConsumed = 0;
|
*bytesConsumed = 0;
|
||||||
|
|
||||||
char *p = static_cast<char *>(memchr(buf, '\n', count));
|
char *p = static_cast<char *>(VMX_MEMCHR(buf, '\n', count));
|
||||||
if (p) {
|
if (p) {
|
||||||
*p = 0;
|
*p = 0;
|
||||||
count = p - buf; // new length
|
count = p - buf; // new length
|
||||||
|
|
|
@ -38,6 +38,9 @@
|
||||||
#include "nsISchedulingContext.h"
|
#include "nsISchedulingContext.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
#include "mozilla-config.h"
|
||||||
|
#include "plvmx.h"
|
||||||
|
|
||||||
#ifdef MOZ_WIDGET_GONK
|
#ifdef MOZ_WIDGET_GONK
|
||||||
#include "NetStatistics.h"
|
#include "NetStatistics.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -1500,7 +1503,7 @@ nsHttpTransaction::ParseHead(char *buf,
|
||||||
// otherwise we can assume that we don't have a HTTP/0.9 response.
|
// otherwise we can assume that we don't have a HTTP/0.9 response.
|
||||||
|
|
||||||
MOZ_ASSERT (mHttpResponseMatched);
|
MOZ_ASSERT (mHttpResponseMatched);
|
||||||
while ((eol = static_cast<char *>(memchr(buf, '\n', count - *countRead))) != nullptr) {
|
while ((eol = static_cast<char *>(VMX_MEMCHR(buf, '\n', count - *countRead))) != nullptr) {
|
||||||
// found line in range [buf:eol]
|
// found line in range [buf:eol]
|
||||||
len = eol - buf + 1;
|
len = eol - buf + 1;
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,9 @@
|
||||||
#include "nsContentSecurityManager.h"
|
#include "nsContentSecurityManager.h"
|
||||||
#include "nsHttp.h"
|
#include "nsHttp.h"
|
||||||
|
|
||||||
|
#include "mozilla-config.h"
|
||||||
|
#include "plvmx.h"
|
||||||
|
|
||||||
//
|
//
|
||||||
// Helper function for determining the length of data bytes up to
|
// Helper function for determining the length of data bytes up to
|
||||||
// the next multipart token. A token is usually preceded by a LF
|
// the next multipart token. A token is usually preceded by a LF
|
||||||
|
@ -1187,7 +1190,7 @@ nsMultiMixedConv::ParseHeaders(nsIChannel *aChannel, char *&aPtr,
|
||||||
}
|
}
|
||||||
|
|
||||||
mContentLength = UINT64_MAX; // XXX what if we were already called?
|
mContentLength = UINT64_MAX; // XXX what if we were already called?
|
||||||
while (cursorLen && (newLine = (char *) memchr(cursor, nsCRT::LF, cursorLen))) {
|
while (cursorLen && (newLine = (char *) VMX_MEMCHR(cursor, nsCRT::LF, cursorLen))) {
|
||||||
// adjust for linefeeds
|
// adjust for linefeeds
|
||||||
if ((newLine > cursor) && (newLine[-1] == nsCRT::CR) ) { // CRLF
|
if ((newLine > cursor) && (newLine[-1] == nsCRT::CR) ) { // CRLF
|
||||||
lineFeedIncrement = 2;
|
lineFeedIncrement = 2;
|
||||||
|
|
|
@ -30,6 +30,9 @@
|
||||||
|
|
||||||
#include "CNNICHashWhitelist.inc"
|
#include "CNNICHashWhitelist.inc"
|
||||||
|
|
||||||
|
#include "mozilla-config.h"
|
||||||
|
#include "plvmx.h"
|
||||||
|
|
||||||
using namespace mozilla;
|
using namespace mozilla;
|
||||||
using namespace mozilla::pkix;
|
using namespace mozilla::pkix;
|
||||||
|
|
||||||
|
@ -314,7 +317,7 @@ GetOCSPAuthorityInfoAccessLocation(PLArenaPool* arena,
|
||||||
const SECItem& location = current->name.other;
|
const SECItem& location = current->name.other;
|
||||||
// (location.len + 1) must be small enough to fit into a uint32_t,
|
// (location.len + 1) must be small enough to fit into a uint32_t,
|
||||||
// but we limit it to a smaller bound to reduce OOM risk.
|
// but we limit it to a smaller bound to reduce OOM risk.
|
||||||
if (location.len > 1024 || memchr(location.data, 0, location.len)) {
|
if (location.len > 1024 || VMX_HASCHR(location.data, 0, location.len)) {
|
||||||
// Reject embedded nulls. (NSS doesn't do this)
|
// Reject embedded nulls. (NSS doesn't do this)
|
||||||
return Result::ERROR_CERT_BAD_ACCESS_LOCATION;
|
return Result::ERROR_CERT_BAD_ACCESS_LOCATION;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,9 @@
|
||||||
|
|
||||||
#include "gzguts.h"
|
#include "gzguts.h"
|
||||||
|
|
||||||
|
#include "mozilla-config.h"
|
||||||
|
#include "plvmx.h"
|
||||||
|
|
||||||
/* Local functions */
|
/* Local functions */
|
||||||
local int gz_load OF((gz_statep, unsigned char *, unsigned, unsigned *));
|
local int gz_load OF((gz_statep, unsigned char *, unsigned, unsigned *));
|
||||||
local int gz_avail OF((gz_statep));
|
local int gz_avail OF((gz_statep));
|
||||||
|
@ -581,7 +584,7 @@ char * ZEXPORT gzgets(file, buf, len)
|
||||||
|
|
||||||
/* look for end-of-line in current output buffer */
|
/* look for end-of-line in current output buffer */
|
||||||
n = state->have > left ? left : state->have;
|
n = state->have > left ? left : state->have;
|
||||||
eol = memchr(state->next, '\n', n);
|
eol = VMX_MEMCHR(state->next, '\n', n);
|
||||||
if (eol != NULL)
|
if (eol != NULL)
|
||||||
n = (unsigned)(eol - state->next) + 1;
|
n = (unsigned)(eol - state->next) + 1;
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,9 @@
|
||||||
#include "nsCRT.h"
|
#include "nsCRT.h"
|
||||||
#include "plstr.h"
|
#include "plstr.h"
|
||||||
|
|
||||||
|
#include "mozilla-config.h"
|
||||||
|
#include "plvmx.h"
|
||||||
|
|
||||||
static const char hexCharsUpper[] = "0123456789ABCDEF";
|
static const char hexCharsUpper[] = "0123456789ABCDEF";
|
||||||
static const char hexCharsUpperLower[] = "0123456789ABCDEFabcdef";
|
static const char hexCharsUpperLower[] = "0123456789ABCDEFabcdef";
|
||||||
|
|
||||||
|
@ -529,7 +532,7 @@ NS_EscapeURL(const nsAFlatString& aStr, const nsTArray<char16_t>& aForbidden,
|
||||||
return aStr;
|
return aStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ISHEX(c) memchr(hexCharsUpperLower, c, sizeof(hexCharsUpperLower)-1)
|
#define ISHEX(c) VMX_HASCHR(hexCharsUpperLower, c, sizeof(hexCharsUpperLower)-1)
|
||||||
|
|
||||||
bool
|
bool
|
||||||
NS_UnescapeURL(const char* aStr, int32_t aLen, uint32_t aFlags,
|
NS_UnescapeURL(const char* aStr, int32_t aLen, uint32_t aFlags,
|
||||||
|
|
Loading…
Reference in New Issue