[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 7/9] dfa: move nalloc to position_set structure
From: |
Jim Meyering |
Subject: |
Re: [PATCH 7/9] dfa: move nalloc to position_set structure |
Date: |
Tue, 03 Jan 2012 10:57:51 +0100 |
Paolo Bonzini wrote:
> * src/dfa.c (position_set): Add alloc.
> (alloc_posset): Initialize it.
> (dfaanalyze): Use it instead of the nalloc array or nelem.
> ---
> src/dfa.c | 16 +++++++---------
> 1 files changed, 7 insertions(+), 9 deletions(-)
>
> diff --git a/src/dfa.c b/src/dfa.c
> index 4644cab..03676b0 100644
> --- a/src/dfa.c
> +++ b/src/dfa.c
> @@ -247,6 +247,7 @@ typedef struct
> {
> position *elems; /* Elements of this position set. */
> int nelem; /* Number of elements in this set. */
> + size_t alloc; /* Number of elements allocated in
> ELEMS. */
> } position_set;
>
> /* Sets of leaves are also stored as arrays. */
> @@ -1835,6 +1836,7 @@ static void
> alloc_posset (position_set *s, size_t size)
> {
> MALLOC(s->elems, size);
> + s->alloc = size;
> s->nelem = 0;
> }
>
> @@ -2103,7 +2105,6 @@ dfaanalyze (struct dfa *d, int searchflag)
> position *firstpos; /* Array where firstpos elements are
> stored. */
> int *nlastpos; /* Element count stack for lastpos sets. */
> position *lastpos; /* Array where lastpos elements are stored. */
> - int *nalloc; /* Sizes of arrays allocated to follow
> sets. */
Nice (I see what's coming :-).
Having a separate array of lengths like that was fragile.
ACK.
- Re: [PATCH 3/9] dfa: use MALLOC/REALLOC always, (continued)
- [PATCH 4/9] dfa: use a separate data type for grps, Paolo Bonzini, 2012/01/03
- [PATCH 5/9] dfa: introduce alloc_posset, Paolo Bonzini, 2012/01/03
- [PATCH 6/9] dfa: remove dead assignment, Paolo Bonzini, 2012/01/03
- [PATCH 7/9] dfa: move nalloc to position_set structure, Paolo Bonzini, 2012/01/03
- Re: [PATCH 7/9] dfa: move nalloc to position_set structure,
Jim Meyering <=
- [PATCH 8/9] dfa: change position_set nelem to size_t, Paolo Bonzini, 2012/01/03
- [PATCH 9/9] dfa: automatically resize position_sets, Paolo Bonzini, 2012/01/03