Re: GLIB Hash Data



Hi,

Ruben I Safir <ruben mrbrklyn com> writes:

> The example is very simple.  Take in data from STDIN and use it for hash
> keys and values.  I have to create a new pointer every time to do this
> with the hash functions in glib.  The only way I can think of doing this is 
> with mallac.  The STDIN has to go into a defined buffer which will point
> to the same emmory location  every time.  Even strcpy would be useless
> in this case without mallocing new memory by hand every time.

that's why there's g_strdup() which does just that.

> IF it sees it's a char * it should just take in the data.

there is no way for glib to check if the pointer passed in is pointing
to a character array. Even if there would be a way, how is it supposed
to know if it needs to copy the string or if you are using static
strings?


Salut, Sven




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]