From: Howard Chu Date: Thu, 3 Jan 2002 16:22:53 +0000 (+0000) Subject: Use ber_memalloc, not malloc. Shortcuts for pure-ASCII strings. X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~319 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=8c04993cdfddfb58fd37942cf327e8c8226c6fc9;p=openldap Use ber_memalloc, not malloc. Shortcuts for pure-ASCII strings. Still need to add some kind of isNormalized() check to avoid rework on UTF8 strings that are already properly normalized. --- diff --git a/libraries/liblunicode/ucstr.c b/libraries/liblunicode/ucstr.c index 43ab99ddf7..8ec9d2668f 100644 --- a/libraries/liblunicode/ucstr.c +++ b/libraries/liblunicode/ucstr.c @@ -4,6 +4,12 @@ #include #include +#include + +#define malloc(x) ber_memalloc(x) +#define realloc(x,y) ber_memrealloc(x,y) +#define free(x) ber_memfree(x) + #include #include @@ -99,18 +105,35 @@ char * UTF8normalize( s = bv->bv_val; len = bv->bv_len; - if ( len == 0 ) { - out = (char *) malloc( 1 ); - *out = '\0'; + /* See if the string is pure ASCII so we can shortcut */ + for ( i=0; ibv_val, len ); + } else { + for ( j=0; j 0 ? 1 : -1; } + /* See if we can get away with a straight ASCII compare */ + len = (l1 < l2) ? l1 : l2; + for ( i = 0; i l2 ? l1 : l2 ) * sizeof(*ucs) ); if ( ucs == NULL ) { return l1 > l2 ? 1 : -1; /* what to do??? */