diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2019-12-19 14:35:59 -0800 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2019-12-19 19:20:53 -0800 |
commit | 6dabeec02d67d824997ce20d186e2d8ee5d91459 (patch) | |
tree | c33f3f1327c40c5a81bb484071cae48c6fedfee1 /lib/dfa.c | |
parent | 5b570e9c35cb5808ca99b455a30c84c93cc59e51 (diff) | |
download | gnulib-6dabeec02d67d824997ce20d186e2d8ee5d91459.tar.gz |
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.
Diffstat (limited to 'lib/dfa.c')
-rw-r--r-- | lib/dfa.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -24,6 +24,8 @@ #include "dfa.h" +#include "flexmember.h" + #include <assert.h> #include <ctype.h> #include <stdint.h> @@ -4272,11 +4274,11 @@ dfamust (struct dfa const *d) 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) @@ -4292,7 +4294,6 @@ dfamust (struct dfa const *d) void dfamustfree (struct dfamust *dm) { - free (dm->must); free (dm); } |