Drop support for alloca().

This commit is contained in:
Juan Gomez 1999-06-11 18:56:28 +00:00
parent 2cb228a9ce
commit 34f068f131
2 changed files with 19 additions and 5 deletions

View File

@ -12,6 +12,8 @@
#ifndef _AC_ALLOCA_H
#define _AC_ALLOCA_H
#error "alloca() not supported, use malloc()"
/* AIX requires this to be the first thing in the file. */
#ifdef __GNUC__
# define alloca __builtin_alloca

View File

@ -553,7 +553,6 @@ ldbm_errno( LDBM ldbm )
/* MMAPED DBM HASHING DATABASE */
#include <ac/alloca.h>
#include <ac/string.h>
/* #define MDBM_DEBUG */
@ -690,7 +689,7 @@ ldbm_fetch( LDBM ldbm, Datum key )
#ifdef NO_NULL_KEY
k.key.dsize = key.dsize + 1;
k.key.dptr = alloca(k.key.dsize);
k.key.dptr = malloc(k.key.dsize);
*(k.key.dptr) = 'l';
memcpy( (void *)(k.key.dptr + 1), key.dptr, key.dsize );
#else
@ -730,6 +729,10 @@ ldbm_fetch( LDBM ldbm, Datum key )
/* LDBM_UNLOCK; */
#ifdef NO_NULL_KEY
free(k.key.dptr);
#endif
return d;
}/* Datum ldbm_fetch() */
@ -754,7 +757,7 @@ ldbm_store( LDBM ldbm, Datum key, Datum data, int flags )
#ifdef NO_NULL_KEY
int_key.dsize = key.dsize + 1;
int_key.dptr = alloca( int_key.dsize );
int_key.dptr = malloc( int_key.dsize );
*(int_key.dptr) = 'l'; /* Must not be NULL !*/
memcpy( (void *)(int_key.dptr + 1), key.dptr, key.dsize );
#else
@ -773,6 +776,10 @@ ldbm_store( LDBM ldbm, Datum key, Datum data, int flags )
fflush( stdout );
#endif
#ifdef NO_NULL_KEY
free(int_key.dptr);
#endif
return( rc );
}/* int ldbm_store() */
@ -790,7 +797,7 @@ ldbm_delete( LDBM ldbm, Datum key )
#ifdef NO_NULL_KEY
int_key.dsize = key.dsize + 1;
int_key.dptr = alloca(int_key.dsize);
int_key.dptr = malloc(int_key.dsize);
*(int_key.dptr) = 'l';
memcpy( (void *)(int_key.dptr + 1), key.dptr, key.dsize );
#else
@ -800,6 +807,9 @@ ldbm_delete( LDBM ldbm, Datum key )
rc = mdbm_delete( ldbm, int_key );
/* LDBM_UNLOCK; */
#ifdef NO_NULL_KEY
free(int_key.dptr);
#endif
return( rc );
@ -825,7 +835,7 @@ ldbm_get_next( LDBM ldbm, kvpair (*fptr)(MDBM *, kvpair) )
/* LDBM_LOCK; */
in.key.dsize = sz; /* Assume first key in one pg */
in.key.dptr = alloca(sz);
in.key.dptr = malloc(sz);
in.val.dptr = NULL; /* Don't need data just key */
in.val.dsize = 0;
@ -853,6 +863,8 @@ ldbm_get_next( LDBM ldbm, kvpair (*fptr)(MDBM *, kvpair) )
}
/* LDBM_UNLOCK; */
free(in.key.dptr);
return ret;