bug-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Windows Build: lib/regex.c warnings, "free" calls


From: Conrad T. Pino
Subject: RE: Windows Build: lib/regex.c warnings, "free" calls
Date: Wed, 7 Apr 2004 09:46:32 -0700

Hi Derek,

Messages may have passed each other like ships in the night.

> From: Derek Robert Price [mailto:address@hidden
> 
> Well, for now, then, a quick fix may have to do.

Replied in prior message.

> You might not have.  I was just being thorough without anything
> particular in mind.  Sorry.

Replied in prior message.

> That means that the version of regex.c comes from before I started
> maintaining srclist.txt.  srclist.txt will need to be updated after a
> new version is imported.

Replied in prior message.

> Well, if all that needs to be done is to figure out which version the
> GNULIB folks are recommending and insert it into lib then run `make
> check', then it should be easy.  Assuming it works.  If it fails then
> more investigation may need to be done.
> 
> If it works, then the quick-fix should be applied there and submitted
> back to GNULIB at the same time.
> 
> As for encouraging somebody to volunteer, it would certainly get it done
> quicker.  :)

Replied in prior message.

> >I propose a common quick fix on both branches, additional work on other
> >warnings and then a return to updating regex from GNULIB.

Given questions below, I'm assuming a response isn't ready at this time.

> >266     #define REGEX_FREE free
> >299     #define REGEX_FREE(arg) ((void)0) /* Do nothing!  But inhibit gcc 
> >warning.  */
> 
> Did you leave a "free" out here?

No, I did not.  Notice the "Do nothing!" comment.

That definition is used when "alloca" is enabled.

> >4004    #define FREE_VAR(var) if (var) { REGEX_FREE (var); var = NULL;
> } else
> >==========================
> >FREE_VAR has just 1 definition and 9 references:
> >
> >4004    #define FREE_VAR(var) if (var) { REGEX_FREE (var); var = NULL;
> } else
> >
> >4008        FREE_VAR (regstart);                        \
> >4009        FREE_VAR (regend);                            \
> >4010        FREE_VAR (old_regstart);                        \
> >4011        FREE_VAR (old_regend);                        \
> >4012        FREE_VAR (best_regstart);                        \
> >4013        FREE_VAR (best_regend);                        \
> >4014        FREE_VAR (reg_info);                        \
> >4015        FREE_VAR (reg_dummy);                        \
> >4016        FREE_VAR (reg_info_dummy);                        \
> >==========================
> >FREE_VARIABLES has just 2 alternative definitions and 6 references:
> >
> >4005    #define FREE_VARIABLES()                        \
> >4019    #define FREE_VARIABLES() ((void)0) /* Do nothing!  But inhibit
> gcc warning.  */
> >
> >4260          FREE_VARIABLES ();
> >4277          FREE_VARIABLES ();
> >4434                  FREE_VARIABLES ();
> >4450                  FREE_VARIABLES ();
> >4508          FREE_VARIABLES ();
> >5743      FREE_VARIABLES ();
> >==========================
> 
> Huh?  What is this one doing?

Multiple code blocks "{...}" use a common set of variables sharing common
names.  Macro "FREE_VARIABLES" is invoked to free the common set.  The
definition of interest now is:

#define FREE_VARIABLES()                                                \
  do {                                                                  \
    REGEX_FREE_STACK (fail_stack.stack);                                \
    FREE_VAR (regstart);                                                \
    FREE_VAR (regend);                                                  \
    FREE_VAR (old_regstart);                                            \
    FREE_VAR (old_regend);                                              \
    FREE_VAR (best_regstart);                                           \
    FREE_VAR (best_regend);                                             \
    FREE_VAR (reg_info);                                                \
    FREE_VAR (reg_dummy);                                               \
    FREE_VAR (reg_info_dummy);                                          \
  } while (0)

The warnings arise in *some* of the FREE_VAR invokations, arguments with
the "const" qualifier.  Macro "FREE_VAR" definition of interest is:

#define FREE_VAR(var) if (var) { REGEX_FREE (var); var = NULL; } else

Macro "REGEX_FREE" definition of interest is:

#define REGEX_FREE free

The "of interest" qualifier means when "alloca" is NOT used. When "alloca"
IS used then:

#define REGEX_FREE(arg) ((void)0) /* Do nothing!  But inhibit gcc warning.  */

Also note FREE_VARIABLES is conditionally compiled by MATCH_MAY_ALLOCATE.

/* Free everything we malloc.  */
#ifdef MATCH_MAY_ALLOCATE
#define FREE_VAR(var) if (var) { REGEX_FREE (var); var = NULL; } else
#define FREE_VARIABLES()                                                \
  do {                                                                  \
    REGEX_FREE_STACK (fail_stack.stack);                                \
    FREE_VAR (regstart);                                                \
    FREE_VAR (regend);                                                  \
    FREE_VAR (old_regstart);                                            \
    FREE_VAR (old_regend);                                              \
    FREE_VAR (best_regstart);                                           \
    FREE_VAR (best_regend);                                             \
    FREE_VAR (reg_info);                                                \
    FREE_VAR (reg_dummy);                                               \
    FREE_VAR (reg_info_dummy);                                          \
  } while (0)
#else
#define FREE_VARIABLES() ((void)0) /* Do nothing!  But inhibit gcc warning.  */
#endif /* not MATCH_MAY_ALLOCATE */

> Derek

Conrad





reply via email to

[Prev in Thread] Current Thread [Next in Thread]