On Thu, Apr 25, 2002 at 12:26:10PM -0400, Ruben I Safir wrote:
> > From the API reference:
> > g_strdup ()
> > gchar* g_strdup (const gchar *str);
> > Duplicates a string. The returned string should be freed when no
> > longer needed.
> > str : the string to duplicate.
> > Returns : a newly-allocated copy of str.
> I would just have documented that it creates a newly allocated
> string which safely allocates memory to a new memory location in the
> returned char pointer.
> Why did you paste the documentation which is already on line?
To show that it says exactly what you want it to say, just in a more
terse format.
> I have one more squestion. When compiling I get this warning:
> warning: passing arg 1 of `g_hash_table_new' from incompatible pointer type
> from this line: hTable = g_hash_table_new(HashFunction, HashCompare);
> Should I cast the function pointers to some type?
>From the documentation:
GHashTable* g_hash_table_new (GHashFunc hash_func,
GEqualFunc key_equal_func);
...
guint (*GHashFunc) (gconstpointer key);
...
gboolean (*GEqualFunc) (gconstpointer a,
gconstpointer b);
It looks to me as your functions are defined as:
guint HashFunction (gpointer key);
gint HashCompare (gpointer a, gpointer b);
They need to be:
guint HashFunction (gconstpointer key);
gboolean HashCompare (gconstpointer a, gconstpointer b);
Something you should realize: Almost all technical documentation is
either written by techies, or written by technical writers that may
not understand what the techie actually wants to know. A compromise
always need to be made between too much information (i.e. annoying and
hard to use as 'reference material' for the knowledgable), and too
little information (people that are just getting started throwing
themselves into a project, and realizing they don't understand the
basics).
The reference material online is fairly complete, but it is not
especially verbose. People such as myself actually *prefer* this, as
the other details are usually incorrect, limit further implementation
changes, and take up a lot more room in the documents that could be
spent on other, more complicated subjects.
In this case, strdup() may not officially be ANSI (I'm surprised that
it might not be...), but it has been in most libc.a implementations
for UNIX for at least the last decade.
If you are using UNIX, type "man strdup", and you should find it. It
fits in with strcpy(), strcmp(), etc., which un-coincidentally, is
exactly where GLIB has placed it.
mark
--
[EMAIL PROTECTED][EMAIL PROTECTED][EMAIL PROTECTED] __________________________
. . _ ._ . . .__ . . ._. .__ . . . .__ | Neighbourhood Coder
|\/| |_| |_| |/ |_ |\/| | |_ | |/ |_ |
| | | | | \ | \ |__ . | | .|. |__ |__ | \ |__ | Ottawa, Ontario, Canada
One ring to rule them all, one ring to find them, one ring to bring them all
and in the darkness bind them...
http://mark.mielke.cc/
_______________________________________________
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list