Re: Insert and Retrieve unsigned char sequences using C
От | Lew |
---|---|
Тема | Re: Insert and Retrieve unsigned char sequences using C |
Дата | |
Msg-id | i22v9p$6kq$1@news.albasani.net обсуждение исходный текст |
Ответ на | Insert and Retrieve unsigned char sequences using C (vinicius_bra <viniciusams@yahoo.com.br>) |
Список | pgsql-general |
vinicius_bra wrote: > I'm developing a system in C and I have a unsigned char pointer that > represents a struct and I like to store it in a bytea column in postgreSQL. The pointer does not represent the struct. > How can I do it? > Example: > > str_t temp; > unsigned char *ptr; > ptr = (unsigned char *)&temp; > store(ptr); > > I've already tried some examples, but I didnt have success. > Could you help me? You won't have any joy storing the raw pointer value, because when you restore it it'll most likely be into a different memory map and the structure to which it used to point will no longer be at the same address, if anywhere. That's because a C pointer doesn't represent a struct, or anything else other than an address. It *points to* the struct. You need to serialize the struct itself then allocate the pointer when you deserialize the struct. -- Lew -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general
В списке pgsql-general по дате отправления: