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-2019, 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 | /* |
26 | * It's against Postgres coding conventions to include postgres.h in a |
27 | * header file, but we allow the violation here because the alternative is |
28 | * to modify the machine-generated .c files provided by the Snowball project. |
29 | */ |
30 | #include "postgres.h" |
31 | |
32 | /* Some platforms define MAXINT and/or MININT, causing conflicts */ |
33 | #ifdef MAXINT |
34 | #undef MAXINT |
35 | #endif |
36 | #ifdef MININT |
37 | #undef MININT |
38 | #endif |
39 | |
40 | /* Now we can include the original Snowball header.h */ |
41 | #include "snowball/libstemmer/header.h" /* pgrminclude ignore */ |
42 | |
43 | /* |
44 | * Redefine standard memory allocation interface to pgsql's one. |
45 | * This allows us to control where the Snowball code allocates stuff. |
46 | */ |
47 | #ifdef malloc |
48 | #undef malloc |
49 | #endif |
50 | #define malloc(a) palloc(a) |
51 | |
52 | #ifdef calloc |
53 | #undef calloc |
54 | #endif |
55 | #define calloc(a,b) palloc0((a) * (b)) |
56 | |
57 | #ifdef realloc |
58 | #undef realloc |
59 | #endif |
60 | #define realloc(a,b) repalloc(a,b) |
61 | |
62 | #ifdef free |
63 | #undef free |
64 | #endif |
65 | #define free(a) pfree(a) |
66 | |
67 | #endif /* SNOWBALL_HEADR_H */ |
68 | |