using palloc in extension functions in c

From: Kjetil Haaland <kjetil(dot)haaland(at)student(dot)uib(dot)no>
To: pgsql-novice(at)postgresql(dot)org
Subject: using palloc in extension functions in c
Date: 2004-10-27 11:59:56
Message-ID: 200410271359.56352.kjetil.haaland@student.uib.no
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hello

I am trying to write an extension function to postgres in c. In the
documentation it is said that i should use palloc instead of malloc when i do
this. I try to use it like they have done in the documentation but when i try
to compile it i get an error. Here is some of the code and the error:

#include <postgresql/server/postgres.h>
#include <postgresql/server/fmgr.h>

char *scoreChar;

void readScoreMatrix(char *filename) {
scoreChar = palloc(20*VARHDRSZ);

}

error message:
bash-2.05b$ gcc smith-waterman.c
/tmp/cc0X3Urq.o(.text+0x4dd): In function `readScoreMatrix':
: undefined reference to `CurrentMemoryContext'
/tmp/cc0X3Urq.o(.text+0x4e5): In function `readScoreMatrix':
: undefined reference to `MemoryContextAlloc'
collect2: ld returned 1 exit status

Best regards
Kjetil Haaland

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Bruno Wolff III 2004-10-27 13:25:25 Re: Simple function question
Previous Message Colin Gillespie 2004-10-27 09:47:44 adding missing FROM-clause