regfree.c
Upload User: tsgydb
Upload Date: 2007-04-14
Package Size: 10674k
Code Size: 1k
Category:

MySQL

Development Platform:

Visual C++

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