put malloc crap directly to scanner.l, parser does not need it
authorMarko Kreen <markokr@gmail.com>
Mon, 29 Oct 2007 20:17:12 +0000 (20:17 +0000)
committerMarko Kreen <markokr@gmail.com>
Mon, 29 Oct 2007 20:17:12 +0000 (20:17 +0000)
Makefile
src/dbgmalloc.h [deleted file]
src/parser.y
src/scanner.l

index 61d4922474402e748cac08ca736cc20f00e049f7..c2521e15bf25fc4c6ef4ed54ae1b70e19670f697 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -21,8 +21,7 @@ SHLIB_LINK = -L$(PQLIB) -lpq
 
 DIST_FILES = Makefile src/plproxy.h src/rowstamp.h src/scanner.l src/parser.y \
             sql/*.sql expected/*.out config/*.sql doc/*.txt doc/Makefile \
-            AUTHORS COPYRIGHT README plproxy.sql.in NEWS debian/packages \
-                src/dbgmalloc.h
+            AUTHORS COPYRIGHT README plproxy.sql.in NEWS debian/packages
 DIST_DIRS = src sql expected config doc debian
 TARNAME = plproxy-$(PLPROXY_VERSION)
 
@@ -46,7 +45,7 @@ src/scanner.c: src/scanner.l
        cd src; $(FLEX) -oscanner.c scanner.l
 
 # dependencies
-$(OBJS): src/plproxy.h src/rowstamp.h src/dbgmalloc.h
+$(OBJS): src/plproxy.h src/rowstamp.h
 
 # utility rules
 
diff --git a/src/dbgmalloc.h b/src/dbgmalloc.h
deleted file mode 100644 (file)
index 1f6caf8..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-
-#define MALLOCLOGx
-
-static inline void *my_malloc(const char *pfx, int len) {
-       void *p = palloc(len);
-#ifdef MALLOCLOG
-       elog(NOTICE, "%s:%s(%d) = %p", pfx, __FUNCTION__, len, p);
-#endif
-       return p;
-}
-static inline void *my_realloc(const char *pfx, void *old, int len) {
-       void *p = repalloc(old, len);
-#ifdef MALLOCLOG
-       elog(NOTICE, "%s:%s(%p, %d) = %p", pfx, __FUNCTION__, old, len, p);
-#endif
-       return p;
-}
-static inline void my_free(const char *pfx, void *p) {
-       pfree(p);
-#ifdef MALLOCLOG
-       elog(NOTICE, "%s:%s(%p)", pfx, __FUNCTION__, p);
-#endif
-}
-
-#define malloc(x)  my_malloc(__FILE__, x)
-#define realloc(x, y)  my_realloc(__FILE__, x, y)
-#define free(x)  my_free(__FILE__, x)
-
index 6becfbaf10bdd3dd0eaebc7f0e27be0f23fcf4e8..ddcd1bd88525409b17442fb91e9e739f37198437 100644 (file)
@@ -20,9 +20,8 @@
 
 #include "plproxy.h"
 
-#include "dbgmalloc.h"
-
-void plproxy_yy_scan_bytes (const char *bytes, int len);
+/* define scanner.c functions */
+void plproxy_yy_scan_bytes(const char *bytes, int len);
 void plproxy_yyset_lineno(int);
 
 /* avoid permanent allocations */
index e7cb65fba72cf6ae2741a482dc6d1687f6318da7..a736d9f07bafda9e62633be6b71d3fb25d0c305d 100644 (file)
@@ -22,8 +22,6 @@
 #include "plproxy.h"
 #include "parser.tab.h"
 
-#include "dbgmalloc.h"
-
 /* shut down crappy flex warnings */
 int yyget_lineno(void);
 int yyget_leng(void);
@@ -43,22 +41,49 @@ int plproxy_yylex_destroy(void);
 /*
  * Allocate in CurrentMemoryContext.  That means plproxy_yylex_destroy()
  * must be called before SPI_finish().
- */
-/*
+ *
  * If we want to support flex 2.5.4, we cannot use
  * options noyyalloc, noyyrealloc, noyyfree.
  *
- * Thus such hack.
+ * Thus such need to hack malloc() et al.
+ */
+#undef FLXMALLOCLOG
+
+static inline void *my_malloc(const char *pfx, int len) {
+       void *p = palloc(len);
+#ifdef FLXMALLOCLOG
+       elog(NOTICE, "%s:%s(%d) = %p", pfx, __FUNCTION__, len, p);
+#endif
+       return p;
+}
+static inline void *my_realloc(const char *pfx, void *old, int len) {
+       void *p = repalloc(old, len);
+#ifdef FLXMALLOCLOG
+       elog(NOTICE, "%s:%s(%p, %d) = %p", pfx, __FUNCTION__, old, len, p);
+#endif
+       return p;
+}
+static inline void my_free(const char *pfx, void *p) {
+       pfree(p);
+#ifdef FLXMALLOCLOG
+       elog(NOTICE, "%s:%s(%p)", pfx, __FUNCTION__, p);
+#endif
+}
+
+#define malloc(x)  my_malloc(__FILE__, x)
+#define realloc(x, y)  my_realloc(__FILE__, x, y)
+#define free(x)  my_free(__FILE__, x)
+
+
+/*
+ * Calculare numeric flex version.
  */
 #if !defined(YY_FLEX_MAJOR_VERSION) || !defined(YY_FLEX_MINOR_VERSION)
 #error Flex required
 #endif
-
 #ifndef YY_FLEX_SUBMINOR_VERSION
 #define YY_FLEX_SUBMINOR_VERSION 0
 #endif
-
-/* calculate single number for ver */
 #define FLXVER ((YY_FLEX_MAJOR_VERSION*1000 + YY_FLEX_MINOR_VERSION)*1000 + YY_FLEX_SUBMINOR_VERSION)
 
 /*
@@ -66,8 +91,6 @@ int plproxy_yylex_destroy(void);
  */
 #if FLXVER < 2005031
 
-#warning Old Flex
-
 /* old flex */
 
 int plproxy_yylex_destroy(void)
@@ -87,10 +110,6 @@ void plproxy_yyset_lineno(int new_lineno)
        yylineno = new_lineno;
 }
 
-#else
-
-#warning New Flex
-
 #endif
 
 /* own error handling */