1999-09-09 03:06:24 +08:00
|
|
|
/* $OpenLDAP$ */
|
1999-05-29 09:19:14 +08:00
|
|
|
/*
|
|
|
|
* Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
|
|
|
|
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
|
|
|
|
*/
|
|
|
|
#include "portable.h"
|
|
|
|
|
1999-06-03 08:37:44 +08:00
|
|
|
#include <ac/stdlib.h>
|
1999-05-30 02:57:23 +08:00
|
|
|
#include <ac/string.h>
|
1999-05-29 09:19:14 +08:00
|
|
|
|
|
|
|
#include "lber-int.h"
|
|
|
|
|
1999-06-08 02:48:22 +08:00
|
|
|
#if LDAP_MEMORY_DEBUG
|
1999-06-03 05:34:34 +08:00
|
|
|
struct ber_mem_hdr {
|
|
|
|
union bmu_align_u {
|
1999-06-19 07:53:05 +08:00
|
|
|
ber_len_t bmu_len_t;
|
|
|
|
ber_tag_t bmu_tag_t;
|
|
|
|
ber_int_t bmu_int_t;
|
|
|
|
|
1999-06-03 05:34:34 +08:00
|
|
|
size_t bmu_size_t;
|
|
|
|
void * bmu_voidp;
|
|
|
|
double bmu_double;
|
|
|
|
long bmu_long;
|
1999-07-13 11:54:42 +08:00
|
|
|
long (*bmu_funcp)( double );
|
1999-06-08 02:48:22 +08:00
|
|
|
char bmu_char[4];
|
1999-06-03 05:34:34 +08:00
|
|
|
} ber_align;
|
1999-06-19 07:53:05 +08:00
|
|
|
#define bm_junk ber_align.bmu_len_t
|
1999-06-08 02:48:22 +08:00
|
|
|
#define bm_data ber_align.bmu_char[1]
|
1999-06-03 05:34:34 +08:00
|
|
|
};
|
2000-01-23 05:09:24 +08:00
|
|
|
#define BER_MEM_JUNK 0xdeaddadaU
|
1999-06-08 02:48:22 +08:00
|
|
|
static const struct ber_mem_hdr ber_int_mem_hdr = { BER_MEM_JUNK };
|
|
|
|
#define BER_MEM_BADADDR ((void *) &ber_int_mem_hdr.bm_data)
|
1999-06-08 03:33:08 +08:00
|
|
|
#define BER_MEM_VALID(p) do { \
|
|
|
|
assert( (p) != BER_MEM_BADADDR ); \
|
|
|
|
assert( (p) != (void *) &ber_int_mem_hdr ); \
|
1999-06-08 09:37:47 +08:00
|
|
|
} while(0)
|
1999-06-08 03:33:08 +08:00
|
|
|
#else
|
|
|
|
#define BER_MEM_VALID(p) /* no-op */
|
1999-06-03 05:34:34 +08:00
|
|
|
#endif
|
1999-05-31 07:00:52 +08:00
|
|
|
|
1999-06-03 05:34:34 +08:00
|
|
|
BerMemoryFunctions *ber_int_memory_fns = NULL;
|
1999-06-02 03:01:05 +08:00
|
|
|
|
1999-06-08 02:48:22 +08:00
|
|
|
#if 0 && defined( LDAP_MEMORY_DEBUG )
|
|
|
|
void
|
|
|
|
ber_int_memfree( void **p )
|
|
|
|
{
|
|
|
|
assert( p != NULL );
|
1999-06-08 09:41:38 +08:00
|
|
|
BER_MEM_VALID( *p );
|
1999-06-08 02:48:22 +08:00
|
|
|
|
|
|
|
ber_memfree( p );
|
|
|
|
|
|
|
|
*p = BER_MEM_BADADDR;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1999-05-29 09:19:14 +08:00
|
|
|
void
|
|
|
|
ber_memfree( void *p )
|
|
|
|
{
|
1999-05-29 13:16:31 +08:00
|
|
|
ber_int_options.lbo_valid = LBER_INITIALIZED;
|
1999-05-31 07:00:52 +08:00
|
|
|
|
1999-06-01 01:30:22 +08:00
|
|
|
if( p == NULL ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1999-06-08 09:41:38 +08:00
|
|
|
BER_MEM_VALID( p );
|
1999-06-08 03:33:08 +08:00
|
|
|
|
1999-05-31 07:00:52 +08:00
|
|
|
if( ber_int_memory_fns == NULL ) {
|
1999-06-03 05:34:34 +08:00
|
|
|
#ifdef LDAP_MEMORY_DEBUG
|
|
|
|
struct ber_mem_hdr *mh = (struct ber_mem_hdr *)
|
|
|
|
((char *)p - sizeof(struct ber_mem_hdr));
|
1999-06-08 02:48:22 +08:00
|
|
|
|
|
|
|
assert( mh->bm_junk == BER_MEM_JUNK );
|
|
|
|
mh->bm_junk = ~BER_MEM_JUNK;
|
1999-06-03 05:34:34 +08:00
|
|
|
free( mh );
|
|
|
|
#else
|
1999-05-31 07:00:52 +08:00
|
|
|
free( p );
|
1999-06-03 05:34:34 +08:00
|
|
|
#endif
|
1999-05-31 07:00:52 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
assert( ber_int_memory_fns->bmf_free );
|
|
|
|
|
|
|
|
(*ber_int_memory_fns->bmf_free)( p );
|
1999-05-29 09:19:14 +08:00
|
|
|
}
|
|
|
|
|
1999-06-02 03:01:05 +08:00
|
|
|
|
|
|
|
void
|
|
|
|
ber_memvfree( void **vec )
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
1999-06-08 03:33:08 +08:00
|
|
|
ber_int_options.lbo_valid = LBER_INITIALIZED;
|
1999-06-08 02:48:22 +08:00
|
|
|
|
|
|
|
if( vec == NULL ) {
|
|
|
|
return;
|
|
|
|
}
|
1999-06-02 03:01:05 +08:00
|
|
|
|
1999-06-08 09:41:38 +08:00
|
|
|
BER_MEM_VALID( vec );
|
1999-06-08 03:33:08 +08:00
|
|
|
|
1999-06-02 03:01:05 +08:00
|
|
|
for ( i = 0; vec[i] != NULL; i++ ) {
|
|
|
|
LBER_FREE( vec[i] );
|
|
|
|
}
|
|
|
|
|
|
|
|
LBER_FREE( vec );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-05-29 09:19:14 +08:00
|
|
|
void *
|
1999-06-19 07:53:05 +08:00
|
|
|
ber_memalloc( ber_len_t s )
|
1999-05-29 09:19:14 +08:00
|
|
|
{
|
2000-01-09 02:42:11 +08:00
|
|
|
void *new;
|
1999-05-29 13:16:31 +08:00
|
|
|
ber_int_options.lbo_valid = LBER_INITIALIZED;
|
1999-05-31 07:00:52 +08:00
|
|
|
|
1999-06-08 02:48:22 +08:00
|
|
|
#ifdef LDAP_MEMORY_DEBUG
|
1999-06-08 07:12:34 +08:00
|
|
|
assert( s != 0 );
|
1999-06-08 02:48:22 +08:00
|
|
|
#endif
|
1999-05-31 07:00:52 +08:00
|
|
|
|
1999-06-01 01:30:22 +08:00
|
|
|
if( s == 0 ) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
1999-05-31 07:00:52 +08:00
|
|
|
if( ber_int_memory_fns == NULL ) {
|
1999-06-03 05:34:34 +08:00
|
|
|
#ifdef LDAP_MEMORY_DEBUG
|
|
|
|
struct ber_mem_hdr *mh = malloc(s + sizeof(struct ber_mem_hdr));
|
|
|
|
|
|
|
|
if( mh == NULL ) return NULL;
|
|
|
|
|
|
|
|
mh->bm_junk = BER_MEM_JUNK;
|
|
|
|
|
1999-06-08 09:41:38 +08:00
|
|
|
BER_MEM_VALID( &mh[1] );
|
2000-01-09 02:42:11 +08:00
|
|
|
new = &mh[1];
|
1999-06-03 05:34:34 +08:00
|
|
|
#else
|
2000-01-09 02:42:11 +08:00
|
|
|
new = malloc( s );
|
1999-06-03 05:34:34 +08:00
|
|
|
#endif
|
2000-01-09 02:42:11 +08:00
|
|
|
} else {
|
|
|
|
new = (*ber_int_memory_fns->bmf_malloc)( s );
|
1999-05-31 07:00:52 +08:00
|
|
|
}
|
|
|
|
|
2000-01-09 02:42:11 +08:00
|
|
|
if( new == NULL ) {
|
|
|
|
ber_errno = LBER_ERROR_MEMORY;
|
|
|
|
}
|
1999-05-31 07:00:52 +08:00
|
|
|
|
2000-01-09 02:42:11 +08:00
|
|
|
return new;
|
1999-05-29 09:19:14 +08:00
|
|
|
}
|
|
|
|
|
1999-06-02 03:01:05 +08:00
|
|
|
|
1999-05-29 09:19:14 +08:00
|
|
|
void *
|
1999-06-19 07:53:05 +08:00
|
|
|
ber_memcalloc( ber_len_t n, ber_len_t s )
|
1999-05-29 09:19:14 +08:00
|
|
|
{
|
2000-01-09 02:42:11 +08:00
|
|
|
void *new;
|
1999-05-29 13:16:31 +08:00
|
|
|
ber_int_options.lbo_valid = LBER_INITIALIZED;
|
1999-05-31 07:00:52 +08:00
|
|
|
|
1999-06-08 02:48:22 +08:00
|
|
|
#ifdef LDAP_MEMORY_DEBUG
|
1999-06-08 07:12:34 +08:00
|
|
|
assert( n != 0 && s != 0);
|
1999-06-08 02:48:22 +08:00
|
|
|
#endif
|
1999-05-31 07:00:52 +08:00
|
|
|
|
1999-06-01 01:30:22 +08:00
|
|
|
if( n == 0 || s == 0 ) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
1999-05-31 07:00:52 +08:00
|
|
|
if( ber_int_memory_fns == NULL ) {
|
1999-06-03 05:34:34 +08:00
|
|
|
#ifdef LDAP_MEMORY_DEBUG
|
|
|
|
struct ber_mem_hdr *mh = calloc(1,
|
|
|
|
(n * s) + sizeof(struct ber_mem_hdr) );
|
|
|
|
|
|
|
|
mh->bm_junk = BER_MEM_JUNK;
|
1999-06-08 03:33:08 +08:00
|
|
|
|
1999-06-08 09:41:38 +08:00
|
|
|
BER_MEM_VALID( &mh[1] );
|
2000-01-09 02:42:11 +08:00
|
|
|
new = &mh[1];
|
1999-06-03 05:34:34 +08:00
|
|
|
#else
|
2000-01-09 02:42:11 +08:00
|
|
|
new = calloc( n, s );
|
1999-06-03 05:34:34 +08:00
|
|
|
#endif
|
2000-01-09 02:42:11 +08:00
|
|
|
|
|
|
|
} else {
|
|
|
|
new = (*ber_int_memory_fns->bmf_calloc)( n, s );
|
1999-05-31 07:00:52 +08:00
|
|
|
}
|
|
|
|
|
2000-01-09 02:42:11 +08:00
|
|
|
if( new == NULL ) {
|
|
|
|
ber_errno = LBER_ERROR_MEMORY;
|
|
|
|
}
|
1999-05-31 07:00:52 +08:00
|
|
|
|
2000-01-09 02:42:11 +08:00
|
|
|
return new;
|
1999-05-29 09:19:14 +08:00
|
|
|
}
|
|
|
|
|
1999-06-02 03:01:05 +08:00
|
|
|
|
1999-05-29 09:19:14 +08:00
|
|
|
void *
|
1999-06-19 07:53:05 +08:00
|
|
|
ber_memrealloc( void* p, ber_len_t s )
|
1999-05-29 09:19:14 +08:00
|
|
|
{
|
2000-01-09 02:42:11 +08:00
|
|
|
void *new;
|
1999-05-29 13:16:31 +08:00
|
|
|
ber_int_options.lbo_valid = LBER_INITIALIZED;
|
|
|
|
|
1999-06-01 01:30:22 +08:00
|
|
|
/* realloc(NULL,s) -> malloc(s) */
|
1999-05-31 07:00:52 +08:00
|
|
|
if( p == NULL ) {
|
|
|
|
return ber_memalloc( s );
|
|
|
|
}
|
|
|
|
|
1999-06-01 01:30:22 +08:00
|
|
|
/* realloc(p,0) -> free(p) */
|
1999-05-31 07:00:52 +08:00
|
|
|
if( s == 0 ) {
|
|
|
|
ber_memfree( p );
|
|
|
|
return NULL;
|
|
|
|
}
|
1999-05-29 13:16:31 +08:00
|
|
|
|
1999-06-08 09:41:38 +08:00
|
|
|
BER_MEM_VALID( p );
|
1999-06-08 03:33:08 +08:00
|
|
|
|
1999-05-31 07:00:52 +08:00
|
|
|
if( ber_int_memory_fns == NULL ) {
|
1999-06-03 05:34:34 +08:00
|
|
|
#ifdef LDAP_MEMORY_DEBUG
|
|
|
|
struct ber_mem_hdr *mh = (struct ber_mem_hdr *)
|
|
|
|
((char *)p - sizeof(struct ber_mem_hdr));
|
|
|
|
assert( mh->bm_junk == BER_MEM_JUNK );
|
|
|
|
|
1999-06-10 08:56:00 +08:00
|
|
|
p = realloc( mh, s + sizeof(struct ber_mem_hdr) );
|
1999-06-03 05:34:34 +08:00
|
|
|
|
2000-01-09 02:42:11 +08:00
|
|
|
if( p != NULL ) {
|
|
|
|
mh = p;
|
1999-06-03 05:34:34 +08:00
|
|
|
|
2000-01-09 02:42:11 +08:00
|
|
|
assert( mh->bm_junk == BER_MEM_JUNK );
|
1999-06-03 05:34:34 +08:00
|
|
|
|
2000-01-09 02:42:11 +08:00
|
|
|
BER_MEM_VALID( &mh[1] );
|
|
|
|
new = &mh[1];
|
|
|
|
}
|
1999-06-03 05:34:34 +08:00
|
|
|
#else
|
2000-01-09 02:42:11 +08:00
|
|
|
new = realloc( p, s );
|
1999-06-03 05:34:34 +08:00
|
|
|
#endif
|
2000-01-09 02:42:11 +08:00
|
|
|
} else {
|
|
|
|
new = (*ber_int_memory_fns->bmf_realloc)( p, s );
|
1999-05-29 13:16:31 +08:00
|
|
|
}
|
1999-05-31 07:00:52 +08:00
|
|
|
|
2000-01-09 02:42:11 +08:00
|
|
|
if( new == NULL ) {
|
|
|
|
ber_errno = LBER_ERROR_MEMORY;
|
|
|
|
}
|
1999-05-31 07:00:52 +08:00
|
|
|
|
2000-01-09 02:42:11 +08:00
|
|
|
return new;
|
1999-05-29 13:16:31 +08:00
|
|
|
}
|
|
|
|
|
1999-06-02 03:01:05 +08:00
|
|
|
|
|
|
|
void
|
|
|
|
ber_bvfree( struct berval *bv )
|
|
|
|
{
|
1999-06-08 03:33:08 +08:00
|
|
|
ber_int_options.lbo_valid = LBER_INITIALIZED;
|
1999-06-08 02:48:22 +08:00
|
|
|
|
|
|
|
if( bv == NULL ) {
|
|
|
|
return;
|
|
|
|
}
|
1999-06-02 03:01:05 +08:00
|
|
|
|
1999-06-08 09:41:38 +08:00
|
|
|
BER_MEM_VALID( bv );
|
1999-06-02 03:01:05 +08:00
|
|
|
|
|
|
|
if ( bv->bv_val != NULL )
|
|
|
|
LBER_FREE( bv->bv_val );
|
|
|
|
|
|
|
|
LBER_FREE( (char *) bv );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
ber_bvecfree( struct berval **bv )
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
1999-06-08 03:33:08 +08:00
|
|
|
ber_int_options.lbo_valid = LBER_INITIALIZED;
|
1999-06-08 02:48:22 +08:00
|
|
|
|
|
|
|
if( bv == NULL ) {
|
|
|
|
return;
|
|
|
|
}
|
1999-06-02 03:01:05 +08:00
|
|
|
|
1999-06-08 09:41:38 +08:00
|
|
|
BER_MEM_VALID( bv );
|
1999-06-02 03:01:05 +08:00
|
|
|
|
|
|
|
for ( i = 0; bv[i] != NULL; i++ )
|
|
|
|
ber_bvfree( bv[i] );
|
|
|
|
|
|
|
|
LBER_FREE( (char *) bv );
|
|
|
|
}
|
|
|
|
|
2000-02-15 04:57:34 +08:00
|
|
|
int
|
|
|
|
ber_bvecadd( struct berval ***bvec, struct berval *bv )
|
|
|
|
{
|
|
|
|
ber_len_t i;
|
|
|
|
struct berval **new;
|
|
|
|
|
|
|
|
ber_int_options.lbo_valid = LBER_INITIALIZED;
|
|
|
|
|
|
|
|
if( bvec == NULL ) {
|
|
|
|
if( bv == NULL ) {
|
|
|
|
/* nothing to add */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
*bvec = ber_memalloc( 2 * sizeof(struct berval *) );
|
|
|
|
|
|
|
|
if( *bvec == NULL ) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
(*bvec)[0] = bv;
|
|
|
|
(*bvec)[1] = NULL;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
BER_MEM_VALID( bvec );
|
|
|
|
|
|
|
|
/* count entries */
|
|
|
|
for ( i = 0; bvec[i] != NULL; i++ ) {
|
|
|
|
/* EMPTY */;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( bv == NULL ) {
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
new = ber_memrealloc( *bvec, (i+2) * sizeof(struct berval *));
|
|
|
|
|
|
|
|
if( new == NULL ) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
*bvec = new;
|
|
|
|
|
|
|
|
(*bvec)[i++] = bv;
|
|
|
|
(*bvec)[i] = NULL;
|
|
|
|
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
1999-06-02 03:01:05 +08:00
|
|
|
|
|
|
|
struct berval *
|
|
|
|
ber_bvdup(
|
|
|
|
LDAP_CONST struct berval *bv )
|
|
|
|
{
|
|
|
|
struct berval *new;
|
|
|
|
|
|
|
|
ber_int_options.lbo_valid = LBER_INITIALIZED;
|
|
|
|
|
|
|
|
if( bv == NULL ) {
|
1999-12-06 14:33:26 +08:00
|
|
|
ber_errno = LBER_ERROR_PARAM;
|
1999-06-02 03:01:05 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(( new = LBER_MALLOC( sizeof(struct berval) )) == NULL ) {
|
1999-12-06 14:33:26 +08:00
|
|
|
ber_errno = LBER_ERROR_MEMORY;
|
1999-06-02 03:01:05 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( bv->bv_val == NULL ) {
|
|
|
|
new->bv_val = NULL;
|
|
|
|
new->bv_len = 0;
|
|
|
|
return new;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(( new->bv_val = LBER_MALLOC( bv->bv_len + 1 )) == NULL ) {
|
1999-12-06 14:33:26 +08:00
|
|
|
ber_errno = LBER_ERROR_MEMORY;
|
1999-06-02 03:01:05 +08:00
|
|
|
LBER_FREE( new );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
1999-06-19 07:53:05 +08:00
|
|
|
SAFEMEMCPY( new->bv_val, bv->bv_val, bv->bv_len );
|
1999-06-02 03:01:05 +08:00
|
|
|
new->bv_val[bv->bv_len] = '\0';
|
|
|
|
new->bv_len = bv->bv_len;
|
|
|
|
|
|
|
|
return( new );
|
|
|
|
}
|
1999-06-03 06:28:22 +08:00
|
|
|
|
1999-12-17 13:37:33 +08:00
|
|
|
struct berval *
|
|
|
|
ber_bvstr(
|
|
|
|
LDAP_CONST char *s )
|
|
|
|
{
|
|
|
|
struct berval *new;
|
|
|
|
|
|
|
|
ber_int_options.lbo_valid = LBER_INITIALIZED;
|
|
|
|
|
|
|
|
if( s == NULL ) {
|
|
|
|
ber_errno = LBER_ERROR_PARAM;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(( new = LBER_MALLOC( sizeof(struct berval) )) == NULL ) {
|
|
|
|
ber_errno = LBER_ERROR_MEMORY;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( *s == '\0' ) {
|
|
|
|
new->bv_val = NULL;
|
|
|
|
new->bv_len = 0;
|
|
|
|
return new;
|
|
|
|
}
|
|
|
|
|
|
|
|
new->bv_val = (char *) s;
|
|
|
|
new->bv_len = strlen( s );
|
|
|
|
|
|
|
|
return( new );
|
|
|
|
}
|
|
|
|
|
|
|
|
struct berval *
|
|
|
|
ber_bvstrdup(
|
|
|
|
LDAP_CONST char *s )
|
|
|
|
{
|
|
|
|
struct berval *new;
|
|
|
|
char *p;
|
|
|
|
|
|
|
|
ber_int_options.lbo_valid = LBER_INITIALIZED;
|
|
|
|
|
|
|
|
if( s == NULL ) {
|
|
|
|
ber_errno = LBER_ERROR_PARAM;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
p = LBER_STRDUP( s );
|
|
|
|
|
|
|
|
if( p == NULL ) {
|
|
|
|
ber_errno = LBER_ERROR_MEMORY;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
new = ber_bvstr( p );
|
|
|
|
|
|
|
|
if( new == NULL || *p == '\0' ) {
|
|
|
|
LBER_FREE( p );
|
|
|
|
}
|
|
|
|
|
|
|
|
return( new );
|
|
|
|
}
|
|
|
|
|
1999-06-03 06:28:22 +08:00
|
|
|
char *
|
1999-06-08 02:48:22 +08:00
|
|
|
ber_strdup( LDAP_CONST char *s )
|
1999-06-03 06:28:22 +08:00
|
|
|
{
|
|
|
|
char *p;
|
1999-06-08 02:48:22 +08:00
|
|
|
size_t len;
|
|
|
|
|
1999-06-08 03:33:08 +08:00
|
|
|
ber_int_options.lbo_valid = LBER_INITIALIZED;
|
|
|
|
|
1999-06-08 02:48:22 +08:00
|
|
|
#ifdef LDAP_MEMORY_DEBUG
|
|
|
|
assert(s != NULL); /* bv damn better point to something */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if( s == NULL ) {
|
2000-01-09 02:42:11 +08:00
|
|
|
ber_errno = LBER_ERROR_PARAM;
|
1999-06-08 02:48:22 +08:00
|
|
|
return( NULL );
|
|
|
|
}
|
|
|
|
|
|
|
|
len = strlen( s ) + 1;
|
1999-06-03 06:28:22 +08:00
|
|
|
|
1999-06-08 07:12:34 +08:00
|
|
|
if ( (p = LBER_MALLOC( len )) == NULL ) {
|
1999-12-06 14:33:26 +08:00
|
|
|
ber_errno = LBER_ERROR_MEMORY;
|
1999-06-03 06:28:22 +08:00
|
|
|
return( NULL );
|
|
|
|
}
|
|
|
|
|
|
|
|
SAFEMEMCPY( p, s, len );
|
|
|
|
return( p );
|
1999-06-08 03:33:08 +08:00
|
|
|
}
|