File tree 1 file changed +5
-10
lines changed
1 file changed +5
-10
lines changed Original file line number Diff line number Diff line change @@ -1605,7 +1605,7 @@ PLy_procedure_compile(PLyProcedure *proc, const char *src)
1605
1605
*/
1606
1606
msrc = PLy_procedure_munge_source (proc -> pyname , src );
1607
1607
crv = PyRun_String (msrc , Py_file_input , proc -> globals , NULL );
1608
- free (msrc );
1608
+ pfree (msrc );
1609
1609
1610
1610
if (crv != NULL )
1611
1611
{
@@ -1642,7 +1642,7 @@ PLy_procedure_munge_source(const char *name, const char *src)
1642
1642
*/
1643
1643
mlen = (strlen (src ) * 2 ) + strlen (name ) + 16 ;
1644
1644
1645
- mrc = PLy_malloc (mlen );
1645
+ mrc = palloc (mlen );
1646
1646
plen = snprintf (mrc , mlen , "def %s():\n\t" , name );
1647
1647
Assert (plen >= 0 && plen < mlen );
1648
1648
@@ -3664,13 +3664,8 @@ PLy_traceback(int *xlevel)
3664
3664
static void *
3665
3665
PLy_malloc (size_t bytes )
3666
3666
{
3667
- void * ptr = malloc (bytes );
3668
-
3669
- if (ptr == NULL )
3670
- ereport (FATAL ,
3671
- (errcode (ERRCODE_OUT_OF_MEMORY ),
3672
- errmsg ("out of memory" )));
3673
- return ptr ;
3667
+ /* We need our allocations to be long-lived, so use TopMemoryContext */
3668
+ return MemoryContextAlloc (TopMemoryContext , bytes );
3674
3669
}
3675
3670
3676
3671
static void *
@@ -3699,7 +3694,7 @@ PLy_strdup(const char *str)
3699
3694
static void
3700
3695
PLy_free (void * ptr )
3701
3696
{
3702
- free (ptr );
3697
+ pfree (ptr );
3703
3698
}
3704
3699
3705
3700
/*
You can’t perform that action at this time.
0 commit comments