header.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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-2016, 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. #include "postgres.h"
  25. /* Some platforms define MAXINT and/or MININT, causing conflicts */
  26. #ifdef MAXINT
  27. #undef MAXINT
  28. #endif
  29. #ifdef MININT
  30. #undef MININT
  31. #endif
  32. /* Now we can include the original Snowball header.h */
  33. #include "snowball/libstemmer/header.h" /* pgrminclude ignore */
  34. /*
  35. * Redefine standard memory allocation interface to pgsql's one.
  36. * This allows us to control where the Snowball code allocates stuff.
  37. */
  38. #ifdef malloc
  39. #undef malloc
  40. #endif
  41. #define malloc(a) palloc(a)
  42. #ifdef calloc
  43. #undef calloc
  44. #endif
  45. #define calloc(a,b) palloc0((a) * (b))
  46. #ifdef realloc
  47. #undef realloc
  48. #endif
  49. #define realloc(a,b) repalloc(a,b)
  50. #ifdef free
  51. #undef free
  52. #endif
  53. #define free(a) pfree(a)
  54. #endif /* SNOWBALL_HEADR_H */