* lib/dfa.c: Include flexmember.h.
(dfamust, dfamustfree): Adjust to struct dfamust change.
This saves a call to malloc+free.
* lib/dfa.h (struct dfamust): Make the final member a
flexible array member.
* modules/dfa (Depends-on): Add flexmember.
2019-12-19 Paul Eggert <eggert@cs.ucla.edu>
+ dfa: struct dfamust now uses flexible array
+ * lib/dfa.c: Include flexmember.h.
+ (dfamust, dfamustfree): Adjust to struct dfamust change.
+ This saves a call to malloc+free.
+ * lib/dfa.h (struct dfamust): Make the final member a
+ flexible array member.
+ * modules/dfa (Depends-on): Add flexmember.
+
dfa: fast->small for array elements
* lib/dfa.c (charclass_word): Use uint_least64_t not uint_fast64_t,
since this type is used in arrays. This change is more for
#include "dfa.h"
+#include "flexmember.h"
+
#include <assert.h>
#include <ctype.h>
#include <stdint.h>
struct dfamust *dm = NULL;
if (*result)
{
- dm = xmalloc (sizeof *dm);
+ dm = xmalloc (FLEXSIZEOF (struct dfamust, must, strlen (result) + 1));
dm->exact = exact;
dm->begline = begline;
dm->endline = endline;
- dm->must = xstrdup (result);
+ strcpy (dm->must, result);
}
while (mp)
void
dfamustfree (struct dfamust *dm)
{
- free (dm->must);
free (dm);
}
bool exact;
bool begline;
bool endline;
- char *must;
+ char must[FLEXIBLE_ARRAY_MEMBER];
};
/* The dfa structure. It is completely opaque. */
assert
c99
ctype
+flexmember
intprops
isblank
locale