home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / wxos2233.zip / wxOS2-2_3_3.zip / wxWindows-2.3.3 / src / regex / regfree.c < prev    next >
C/C++ Source or Header  |  2001-08-15  |  758b  |  38 lines

  1. #include <sys/types.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include "regex.h"
  5.  
  6. #include "utils.h"
  7. #include "regex2.h"
  8.  
  9. /*
  10.  - regfree - free everything
  11.  = extern void regfree(regex_t *);
  12.  */
  13. void
  14. regfree(preg)
  15. regex_t *preg;
  16. {
  17.     register struct re_guts *g;
  18.  
  19.     if (preg->re_magic != MAGIC1)    /* oops */
  20.         return;            /* nice to complain, but hard */
  21.  
  22.     g = preg->re_g;
  23.     if (g == NULL || g->magic != MAGIC2)    /* oops again */
  24.         return;
  25.     preg->re_magic = 0;        /* mark it invalid */
  26.     g->magic = 0;            /* mark it invalid */
  27.  
  28.     if (g->strip != NULL)
  29.         free((char *)g->strip);
  30.     if (g->sets != NULL)
  31.         free((char *)g->sets);
  32.     if (g->setbits != NULL)
  33.         free((char *)g->setbits);
  34.     if (g->must != NULL)
  35.         free(g->must);
  36.     free((char *)g);
  37. }
  38.