memcpy(F_DIR_RELNAMES_P(lastpath_struct), &relname_list, sizeof relname_list);
}
rnpp = EXPAND_ITEM_LIST(relname_list, relnamecache *, 32);
- *rnpp = (relnamecache*)new_array(char, sizeof (relnamecache) + len);
+ *rnpp = (relnamecache*)new_array(char, RELNAMECACHE_LEN + len + 1);
(*rnpp)->name_type = name_type;
strlcpy((*rnpp)->fname, limit+1, len + 1);
if (need_unsorted_flist) {
flist->sorted = new_array(struct file_struct *, flist->used);
- memcpy(flist->sorted, flist->files,
- flist->used * sizeof (struct file_struct*));
+ memcpy(flist->sorted, flist->files, flist->used * PTR_SIZE);
} else
flist->sorted = flist->files;
* send them together in a single file-list. */
if (need_unsorted_flist) {
flist->sorted = new_array(struct file_struct *, flist->used);
- memcpy(flist->sorted, flist->files,
- flist->used * sizeof (struct file_struct*));
+ memcpy(flist->sorted, flist->files, flist->used * PTR_SIZE);
} else
flist->sorted = flist->files;
flist_sort_and_clean(flist, 0);
* list unsorted for our exchange of index numbers with the
* other side (since their names may not sort the same). */
flist->sorted = new_array(struct file_struct *, flist->used);
- memcpy(flist->sorted, flist->files,
- flist->used * sizeof (struct file_struct*));
+ memcpy(flist->sorted, flist->files, flist->used * PTR_SIZE);
if (inc_recurse && dir_flist->used > dstart) {
static int dir_flist_malloced = 0;
if (dir_flist_malloced < dir_flist->malloced) {
dir_flist_malloced = dir_flist->malloced;
}
memcpy(dir_flist->sorted + dstart, dir_flist->files + dstart,
- (dir_flist->used - dstart) * sizeof (struct file_struct*));
+ (dir_flist->used - dstart) * PTR_SIZE);
fsort(dir_flist->sorted + dstart, dir_flist->used - dstart);
}
} else {
# error Character pointers are not 4 or 8 bytes.
#endif
+#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
+#define USE_FLEXIBLE_ARRAY 1
+#endif
+
union file_extras {
int32 num;
uint32 unum;
uint32 len32; /* Lowest 32 bits of the file's length */
uint16 mode; /* The item's type and permissions */
uint16 flags; /* The FLAG_* bits for this item */
- const char basename[1]; /* The basename (AKA filename) follows */
+#ifdef USE_FLEXIBLE_ARRAY
+ const char basename[]; /* The basename (AKA filename) follows */
+#else
+ const char basename[1]; /* A kluge that should work like a flexible array */
+#endif
};
extern int file_extra_cnt;
extern int acls_ndx;
extern int xattrs_ndx;
+#ifdef USE_FLEXIBLE_ARRAY
+#define FILE_STRUCT_LEN (sizeof (struct file_struct))
+#else
#define FILE_STRUCT_LEN (offsetof(struct file_struct, basename))
+#endif
#define EXTRA_LEN (sizeof (union file_extras))
#define DEV_EXTRA_CNT 2
#define DIRNODE_EXTRA_CNT 3
typedef struct {
char name_type;
- char fname[1]; /* has variable size */
+#ifdef USE_FLEXIBLE_ARRAY
+ char fname[]; /* has variable size */
+#else
+ char fname[1]; /* A kluge that should work like a flexible array */
+#endif
} relnamecache;
+#ifdef USE_FLEXIBLE_ARRAY
+#define RELNAMECACHE_LEN (sizeof (relnamecache))
+#else
+#define RELNAMECACHE_LEN (offsetof(relnamecache, fname))
+#endif
+
#include "byteorder.h"
#include "lib/mdigest.h"
#include "lib/wildmatch.h"
uchar *saw;
int saw_len;
int negotiated_num;
- struct name_num_item list[];
+ struct name_num_item list[8]; /* A big-enough len (we'll get a compile error if it is ever too small) */
};
#ifndef __cplusplus