header.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*-------------------------------------------------------------------------
  2. *
  3. * header.h
  4. * Replacement header file for Snowball stemmer modules
  5. *
  6. * The Snowball stemmer modules do #include "header.h", and think they
  7. * are including snowball/libstemmer/header.h. We adjust the CPPFLAGS
  8. * so that this file is found instead, and thereby we can modify the
  9. * headers they see. The main point here is to ensure that pg_config.h
  10. * is included before any system headers such as <stdio.h>; without that,
  11. * we have portability issues on some platforms due to variation in
  12. * largefile options across different modules in the backend.
  13. *
  14. * NOTE: this file should not be included into any non-snowball sources!
  15. *
  16. * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
  17. *
  18. * src/include/snowball/header.h
  19. *
  20. *-------------------------------------------------------------------------
  21. */
  22. #ifndef SNOWBALL_HEADR_H
  23. #define SNOWBALL_HEADR_H
  24. /*
  25. * It's against Postgres coding conventions to include postgres.h in a
  26. * header file, but we allow the violation here because the alternative is
  27. * to modify the machine-generated .c files provided by the Snowball project.
  28. */
  29. #include "postgres.h"
  30. /* Some platforms define MAXINT and/or MININT, causing conflicts */
  31. #ifdef MAXINT
  32. #undef MAXINT
  33. #endif
  34. #ifdef MININT
  35. #undef MININT
  36. #endif
  37. /* Now we can include the original Snowball header.h */
  38. #include "snowball/libstemmer/header.h" /* pgrminclude ignore */
  39. /*
  40. * Redefine standard memory allocation interface to pgsql's one.
  41. * This allows us to control where the Snowball code allocates stuff.
  42. */
  43. #ifdef malloc
  44. #undef malloc
  45. #endif
  46. #define malloc(a) palloc(a)
  47. #ifdef calloc
  48. #undef calloc
  49. #endif
  50. #define calloc(a,b) palloc0((a) * (b))
  51. #ifdef realloc
  52. #undef realloc
  53. #endif
  54. #define realloc(a,b) repalloc(a,b)
  55. #ifdef free
  56. #undef free
  57. #endif
  58. #define free(a) pfree(a)
  59. #endif /* SNOWBALL_HEADR_H */