1 /* GLIB - Library of useful routines for C programming
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
28 g_memdup (const gpointer mem,
35 new_mem = g_malloc (byte_size);
36 memcpy (new_mem, mem, byte_size);
45 g_strjoin (const gchar *separator,
56 separator_len = strlen (separator);
58 va_start(args, separator);
60 s = va_arg(args, gchar *);
65 while((s = va_arg(args, gchar*)))
67 len += separator_len + strlen(s);
71 string = g_new (gchar, len);
73 va_start(args, separator);
76 s = va_arg(args, gchar*);
79 while((s = va_arg(args, gchar*)))
81 strcat(string, separator);
86 string = g_strdup("");
93 /* this was introduced sometime between glib-1.0.1 and glib-1.0.4 */
95 g_slist_nth_data (GSList *list,
98 while ((n-- > 0) && list)
101 return list ? list->data : NULL;