mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-21 15:19:34 -05:00
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.
This commit is contained in:
parent
35455699e7
commit
a2f36ae2d3
3 changed files with 19 additions and 14 deletions
|
|
@ -20,6 +20,7 @@
|
||||||
#include "lutil_ldap.h"
|
#include "lutil_ldap.h"
|
||||||
#include "ldap_defaults.h"
|
#include "ldap_defaults.h"
|
||||||
#include "ldap_pvt.h"
|
#include "ldap_pvt.h"
|
||||||
|
#include "lber_pvt.h"
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
|
|
@ -762,8 +763,8 @@ tool_server_controls( LDAP *ld, LDAPControl *extra_c, int count )
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( assertctl ) {
|
if ( assertctl ) {
|
||||||
char berbuf[LBER_ELEMENT_SIZEOF];
|
BerElementBuffer berbuf;
|
||||||
BerElement *ber = (BerElement *)berbuf;
|
BerElement *ber = (BerElement *)&berbuf;
|
||||||
|
|
||||||
if( assertion == NULL || *assertion == '\0' ) {
|
if( assertion == NULL || *assertion == '\0' ) {
|
||||||
fprintf( stderr, "Assertion=<empty>\n" );
|
fprintf( stderr, "Assertion=<empty>\n" );
|
||||||
|
|
|
||||||
|
|
@ -157,18 +157,6 @@ extern char ber_pvt_opt_on;
|
||||||
#define LBER_OPT_SUCCESS (0)
|
#define LBER_OPT_SUCCESS (0)
|
||||||
#define LBER_OPT_ERROR (-1)
|
#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 berelement BerElement;
|
||||||
typedef struct sockbuf Sockbuf;
|
typedef struct sockbuf Sockbuf;
|
||||||
typedef struct seqorset Seqorset;
|
typedef struct seqorset Seqorset;
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,22 @@
|
||||||
|
|
||||||
LDAP_BEGIN_DECL
|
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 {
|
typedef struct sockbuf_buf {
|
||||||
ber_len_t buf_size;
|
ber_len_t buf_size;
|
||||||
ber_len_t buf_ptr;
|
ber_len_t buf_ptr;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue