Skip to content
Snippets Groups Projects
Commit 34f068f1 authored by Juan Gomez's avatar Juan Gomez
Browse files

Drop support for alloca().

parent 2cb228a9
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment