*/
msrc = PLy_procedure_munge_source(proc->pyname, src);
crv = PyRun_String(msrc, Py_file_input, proc->globals, NULL);
- free(msrc);
+ pfree(msrc);
if (crv != NULL)
{
*/
mlen = (strlen(src) * 2) + strlen(name) + 16;
- mrc = PLy_malloc(mlen);
+ mrc = palloc(mlen);
plen = snprintf(mrc, mlen, "def %s():\n\t", name);
Assert(plen >= 0 && plen < mlen);
static void *
PLy_malloc(size_t bytes)
{
- void *ptr = malloc(bytes);
-
- if (ptr == NULL)
- ereport(FATAL,
- (errcode(ERRCODE_OUT_OF_MEMORY),
- errmsg("out of memory")));
- return ptr;
+ /* We need our allocations to be long-lived, so use TopMemoryContext */
+ return MemoryContextAlloc(TopMemoryContext, bytes);
}
static void *
static void
PLy_free(void *ptr)
{
- free(ptr);
+ pfree(ptr);
}
/*