Re: GLIB Hash Data



In regards to g_strdup, do I need to allocate the memory for the returned string.  It's not
clear in the documentation.  Or do I still need to allocate the memory seperately

Ruben

On 2002.04.25 11:28 Ruben I Safir wrote:
> Thanks
> 
> Is it common practice to use GStrings in this circumstance?
> 
> 
> Ruben
> 
> On 2002.04.25 07:33 Sven Neumann wrote:
> > 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
> > 
> -- 
> __________________________
> 
> Brooklyn Linux Solutions
> __________________________
> http://www.mrbrklyn.com - Consulting
> http://www.brooklynonline.com - For the love of Brooklyn
> http://www.nylxs.com - Leadership Development in Free Software
> http://www.nyfairuse.org - The foundation of Democracy
> http://www2.mrbrklyn.com/resources - Unpublished Archive or stories and articles from around the net
> http://www2.mrbrklyn.com/mp3/dr.mp3 - Imagine my surprise when I saw you...
> http://www2.mrbrklyn.com/downtown.html - See the New Downtown Brooklyn....
> 
> 1-718-382-5752
> 
> 
> 
-- 
__________________________

Brooklyn Linux Solutions
__________________________
http://www.mrbrklyn.com - Consulting
http://www.brooklynonline.com - For the love of Brooklyn
http://www.nylxs.com - Leadership Development in Free Software
http://www.nyfairuse.org - The foundation of Democracy
http://www2.mrbrklyn.com/resources - Unpublished Archive or stories and articles from around the net
http://www2.mrbrklyn.com/mp3/dr.mp3 - Imagine my surprise when I saw you...
http://www2.mrbrklyn.com/downtown.html - See the New Downtown Brooklyn....

1-718-382-5752






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