From: | "Marko Kreen" <markokr(at)gmail(dot)com> |
---|---|
To: | "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | josh(at)agliodbs(dot)com, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: [rfc,patch] PL/Proxy in core |
Date: | 2008-05-15 08:18:39 |
Message-ID: | e51f66da0805150118t6f0b30fdud73927d6d4395c06@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 5/15/08, Marko Kreen <markokr(at)gmail(dot)com> wrote:
> On 5/15/08, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> > "Marko Kreen" <markokr(at)gmail(dot)com> writes:
> > > Hmm.. Now that I think about it, in my effort to remove malloc() calls
> > > in both scanner and parser I told bison to use alloca(). Is it portability
> > > concern?
> >
> > Yes.
>
>
> How about following patch? I have bison 2.3 and it seems not to do
> global allocation, so it should be fine. There may be early exit
> with elog(ERRROR) inside so I'd like to avoid malloc() itself.
>
> Is there some older bison that keeps allocations around?
> They would need bit more work...
>
> --- src/parser.y 14 May 2008 12:25:00 -0000 1.7
> +++ src/parser.y 15 May 2008 07:34:53 -0000
> @@ -24,7 +24,9 @@
> void plproxy_yy_scan_bytes(const char *bytes, int len);
>
> /* avoid permanent allocations */
> -#define YYSTACK_USE_ALLOCA 1
> +#define YYMALLOC palloc
> +#define YYFREE pfree
> +
> /* remove unused code */
> #define YY_LOCATION_PRINT(File, Loc) (0)
> #define YY_(x) (x)
>
> I will roll new full patch when more comments have appeared.
Checked bison 1.875, and it does not use YYMALLOC/YYFREE.
But luckily its allocation pattern seems sane, so following should work:
--- src/parser.y 14 May 2008 12:25:00 -0000 1.7
+++ src/parser.y 15 May 2008 08:18:14 -0000
@@ -24,7 +24,9 @@
void plproxy_yy_scan_bytes(const char *bytes, int len);
/* avoid permanent allocations */
-#define YYSTACK_USE_ALLOCA 1
+#define malloc palloc
+#define free pfree
+
/* remove unused code */
#define YY_LOCATION_PRINT(File, Loc) (0)
#define YY_(x) (x)
--
marko
From | Date | Subject | |
---|---|---|---|
Next Message | Nikhils | 2008-05-15 08:41:34 | Re: Can't t compile current HEAD |
Previous Message | Marko Kreen | 2008-05-15 07:44:37 | Re: [rfc,patch] PL/Proxy in core |