Commit a2f36ae2 authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

Rework of berbuf allocation:

	Moved BerElementBuffer to lber_pvt.h
	Defined union by macro so it can be easily reused.
Updated client/tools/common.c.
parent 35455699
......@@ -20,6 +20,7 @@
#include "lutil_ldap.h"
#include "ldap_defaults.h"
#include "ldap_pvt.h"
#include "lber_pvt.h"
#include "common.h"
......@@ -762,8 +763,8 @@ tool_server_controls( LDAP *ld, LDAPControl *extra_c, int count )
}
if ( assertctl ) {
char berbuf[LBER_ELEMENT_SIZEOF];
BerElement *ber = (BerElement *)berbuf;
BerElementBuffer berbuf;
BerElement *ber = (BerElement *)&berbuf;
if( assertion == NULL || *assertion == '\0' ) {
fprintf( stderr, "Assertion=<empty>\n" );
......
......@@ -157,18 +157,6 @@ extern char ber_pvt_opt_on;
#define LBER_OPT_SUCCESS (0)
#define LBER_OPT_ERROR (-1)
#define LBER_ELEMENT_SIZEOF (256) /* must be >= sizeof(BerElement) */
typedef union ber_buffer_u {
char charbuf[LBER_ELEMENT_SIZEOF];
/* force alignment */
int intbuf;
long longbuf;
float floatbuf;
double doublebuf;
char* ptrbuf;
} BerElementBuffer;
typedef struct berelement BerElement;
typedef struct sockbuf Sockbuf;
typedef struct seqorset Seqorset;
......
......@@ -21,6 +21,22 @@
LDAP_BEGIN_DECL
/* for allocating aligned buffers (on the stack) */
#define LBER_ALIGN_BUFFER(uname,size) \
union LDAP_CONCAT(lber_,uname) { \
char buffer[size]; \
\
/* force alignment */ \
int ialign; \
long lalign; \
float falign; \
double dalign; \
char* palign; \
}
#define LBER_ELEMENT_SIZEOF (256) /* must be >= sizeof(BerElement) */
typedef LBER_ALIGN_BUFFER(berelement_u,LBER_ELEMENT_SIZEOF) BerElementBuffer;
typedef struct sockbuf_buf {
ber_len_t buf_size;
ber_len_t buf_ptr;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment