return NULL;
}
- dp = (DIR *) calloc(1, sizeof(DIR));
+ dp = (DIR *) calloc(1, sizeof(DIR) + MAXPATHLEN*sizeof(char));
if (dp == NULL) {
return NULL;
}
/* wide to utf8 failed, should never happen. */
return NULL;
}
- if (dp->dent.d_name)
- free(dp->dent.d_name);
- dp->dent.d_name = _tmp;
+ memmove(dp->dent.d_name, _tmp, reclen + 1);
+ free(_tmp);
dp->dent.d_reclen = (unsigned short)reclen;
dp->offset++;
result = NULL;
return 0;
}
- if (dp->dent.d_name)
- free(dp->dent.d_name);
- dp->dent.d_name = _tmp;
+ memmove(dp->dent.d_name, _tmp, reclen + 1);
+ free(_tmp);
dp->dent.d_reclen = (unsigned short)reclen;
dp->offset++;
}
if (dp->dirw)
free(dp->dirw);
- if (dp->dent.d_name)
- free(dp->dent.d_name);
if (dp)
free(dp);
long d_ino; /* inode (always 1 in WIN32) */
off_t d_off; /* offset to this dirent */
unsigned short d_reclen; /* length of d_name */
- char *d_name; /* null terminated filename in the current encoding, glyph number <= 255 wchar_t's + \0 byte */
+ unsigned short pad0;
+#if defined(_WIN64)
+ uint32_t pad1;
+#endif
+ char d_name[1]; /* null terminated filename in the current encoding, glyph number <= 255 wchar_t's + \0 byte */
};
/* typedef DIR - not the same as Unix */