Re: [HACKERS] Bug in user defined types in postgres?! (fwd)
В списке pgsql-hackers по дате отправления:
| От | Tom Ivar Helbekkmo |
|---|---|
| Тема | Re: [HACKERS] Bug in user defined types in postgres?! (fwd) |
| Дата | |
| Msg-id | 86d83c87im.fsf@athene.nhh.no обсуждение исходный текст |
| Ответ на | Bug in user defined types in postgres?! (fwd) (Petr Danecek <petr@ics.cas.cz>) |
| Список | pgsql-hackers |
Petr Danecek <petr@ics.cas.cz> writes:
> #include <stdio.h>
> #include <string.h>
> #include <malloc.h>
You can't use malloc() -- you have to use PostgreSQL's own palloc().
So you want to replace that "#include <malloc.h>" with:
#include <postgres.h> #include <utils/palloc.h>
So, the actual allocation in mytype_in() must be changed:
> mytype *
> mytype_in (char *str)
> {
> mytype *ret;
>
> ret = malloc (sizeof(mytype));
Here, the call should be to palloc() instead of malloc(), thus:
ret = palloc (sizeof(mytype));
The reason for this is that PostgreSQL does its own memory management,
for efficiency reasons, and if you suddenly start calling malloc(),
you screw up its logic.
-tih
--
Popularity is the hallmark of mediocrity. --Niles Crane, "Frasier"
В списке pgsql-hackers по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера