Add memctx to lutil_str2bin()

This commit is contained in:
Howard Chu 2007-12-02 19:11:41 +00:00
parent 283313ba15
commit 304520c113
3 changed files with 11 additions and 9 deletions

View File

@ -305,7 +305,7 @@ lutil_atoulx( unsigned long *v, const char *s, int x );
#define lutil_atoul(v, s) lutil_atoulx((v), (s), 10)
LDAP_LUTIL_F (int)
lutil_str2bin( struct berval *in, struct berval *out );
lutil_str2bin( struct berval *in, struct berval *out, void *ctx );
/* Parse and unparse time intervals */
LDAP_LUTIL_F (int)

View File

@ -35,6 +35,7 @@
#include "lutil.h"
#include "ldap_defaults.h"
#include "ldap_pvt.h"
#include "lber_pvt.h"
#ifdef HAVE_EBCDIC
int _trans_argv = 1;
@ -671,7 +672,7 @@ scale( int new, lutil_int_decnum *prev, unsigned char *tmp )
* any hex input.
*/
int
lutil_str2bin( struct berval *in, struct berval *out )
lutil_str2bin( struct berval *in, struct berval *out, void *ctx )
{
char *pin, *pout, ctmp;
char *end;
@ -747,7 +748,7 @@ lutil_str2bin( struct berval *in, struct berval *out )
/* tmp must be at least as large as outbuf */
if ( out->bv_len > sizeof(tmpbuf)) {
tmp = ber_memalloc( out->bv_len );
tmp = ber_memalloc_x( out->bv_len, ctx );
} else {
tmp = tmpbuf;
}
@ -795,7 +796,7 @@ lutil_str2bin( struct berval *in, struct berval *out )
out->bv_len = num.len;
decfail:
if ( tmp != tmpbuf ) {
ber_memfree( tmp );
ber_memfree_x( tmp, ctx );
}
}
return rc;

View File

@ -2120,7 +2120,8 @@ static int
integerVal2Key(
struct berval val,
struct berval *key,
struct berval itmp
struct berval itmp,
void *ctx
)
{
/* index format:
@ -2150,7 +2151,7 @@ integerVal2Key(
}
}
if ( lutil_str2bin( &val, &itmp )) {
if ( lutil_str2bin( &val, &itmp, ctx )) {
return LDAP_INVALID_SYNTAX;
}
@ -2238,7 +2239,7 @@ integerIndexer(
else if ( itmp.bv_len > maxstrlen )
itmp.bv_len = maxstrlen;
}
rc = integerVal2Key( values[i], &keys[i], itmp );
rc = integerVal2Key( values[i], &keys[i], itmp, ctx );
if ( rc )
goto leave;
}
@ -2284,7 +2285,7 @@ integerFilter(
iv.bv_len = sizeof(ibuf);
}
rc = integerVal2Key( *value, keys, iv );
rc = integerVal2Key( *value, keys, iv, ctx );
if ( rc == 0 )
*keysp = keys;
@ -3141,7 +3142,7 @@ serialNumberAndIssuerNormalize(
}
sn2.bv_val = stmp;
sn2.bv_len = sn.bv_len;
if ( lutil_str2bin( &sn, &sn2 )) {
if ( lutil_str2bin( &sn, &sn2, ctx )) {
rc = LDAP_INVALID_SYNTAX;
goto leave;
}