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@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general