#include "slap.h"
#include "config.h"
+#include "lutil.h"
+
/* This is a cheap hack to implement a collective attribute.
*
* This demonstration overlay looks for a specified attribute in an
* is no effect. If no attribute was configured, there is no effect.
*/
+/* Use C99 flexible array member if supported, C89 "struct hack" otherwise. */
+#define FLEXIBLE_STRUCT_SIZE(stype, mtype, mcount) \
+ (sizeof(stype) + sizeof(mtype) * ((mcount) - (0 FLEXIBLE_ARRAY_MEMBER)))
+#if __STDC_VERSION__>=199901L || (defined __GNUC__ && !defined __STRICT_ANSI__)
+#define FLEXIBLE_ARRAY_MEMBER
+#else
+#define FLEXIBLE_ARRAY_MEMBER +1
+#endif
+
typedef struct collect_info {
struct collect_info *ci_next;
struct berval ci_dn;
int ci_ad_num;
- AttributeDescription *ci_ad[];
+ AttributeDescription *ci_ad[FLEXIBLE_ARRAY_MEMBER];
} collect_info;
/*
}
/* allocate config info with room for attribute array */
- ci = ch_malloc( sizeof( collect_info ) +
- ( sizeof (AttributeDescription *) * (count + 1)));
+ ci = ch_malloc( FLEXIBLE_STRUCT_SIZE( collect_info,
+ AttributeDescription *, count + 1 ));
/* validate and normalize dn */
ber_str2bv( c->argv[1], 0, 0, &bv );
collect_info *ci = on->on_bi.bi_private;
Modifications *ml;
char errMsg[100];
- int rc, idx;
+ int idx;
for ( ml = op->orm_modlist; ml != NULL; ml = ml->sml_next) {
for (; ci; ci=ci->ci_next ) {