summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHavoc Pennington <hp@pobox.com>2001-02-17 23:30:48 +0000
committerHavoc Pennington <hp@src.gnome.org>2001-02-17 23:30:48 +0000
commit1c391cc69846713b0406545146ea232efc5f34e2 (patch)
tree2941b3344e0111ac049df088fae03216ce473245
parentadfafc0872a0d787eb46b8a487fcd8db91ec34fb (diff)
include string.h
2001-02-17 Havoc Pennington <hp@pobox.com> * gthread.c: include string.h Applied patch from Soeren Sandmann: * testglib.c: const fixes * gwin32.h: format cleanups * gutils.c (g_atexit): constify a variable (g_find_program_in_path): constification (g_basename): G_CONST_RETURN (g_path_skip_root): G_CONST_RETURN (g_getenv): G_CONST_RETURN (g_get_user_name): G_CONST_RETURN (g_get_real_name): G_CONST_RETURN (g_get_home_dir): G_CONST_RETURN (g_get_tmp_dir): G_CONST_RETURN (g_get_prgname): G_CONST_RETURN (_glib_gettext): G_CONST_RETURN * gunicode.h: formatting cleanups * gstrfuncs.c (g_strerror): G_CONST_RETURN (g_strsignal): G_CONST_RETURN * gspawn.c (g_execute): const on variables * gmessages.c (printf_string_upper_bound): fix const on a variable * gmem.c (g_mem_chunk_new): make the "name" arg const (struct _GRealMemChunk): make the "name" field const * gfileutils.c (g_file_open_tmp): store const return in a const gchar* variable * gdataset.c (g_quark_to_string): G_CONST_RETURN 2001-02-17 Havoc Pennington <hp@pobox.com> Applied patch from Soeren Sandmann: * gvaluetypes.c (g_value_get_string): G_CONST_RETURN * gtype.c (g_type_name): G_CONST_RETURN * gsignal.c (g_signal_name): G_CONST_RETURN * gobject-query.c (main): const fix 2001-02-17 Havoc Pennington <hp@pobox.com> Applied patch from Soeren Sandmann: * gmodule.c (g_module_error): G_CONST_RETURN (g_module_name): G_CONST_RETURN
-rw-r--r--ChangeLog39
-rw-r--r--ChangeLog.pre-2-039
-rw-r--r--ChangeLog.pre-2-1039
-rw-r--r--ChangeLog.pre-2-1239
-rw-r--r--ChangeLog.pre-2-239
-rw-r--r--ChangeLog.pre-2-439
-rw-r--r--ChangeLog.pre-2-639
-rw-r--r--ChangeLog.pre-2-839
-rw-r--r--gdataset.c2
-rw-r--r--gfileutils.c2
-rw-r--r--glib/gdataset.c2
-rw-r--r--glib/gfileutils.c2
-rw-r--r--glib/gmem.c22
-rw-r--r--glib/gmem.h26
-rw-r--r--glib/gmessages.c2
-rw-r--r--glib/gquark.h8
-rw-r--r--glib/gspawn.c3
-rw-r--r--glib/gstrfuncs.c4
-rw-r--r--glib/gstrfuncs.h102
-rw-r--r--glib/gthread.c2
-rw-r--r--glib/gunicode.h20
-rw-r--r--glib/gutils.c29
-rw-r--r--glib/gutils.h52
-rw-r--r--glib/gwin32.h8
-rw-r--r--gmem.c22
-rw-r--r--gmem.h26
-rw-r--r--gmessages.c2
-rw-r--r--gmodule/ChangeLog7
-rw-r--r--gmodule/gmodule.c6
-rw-r--r--gmodule/gmodule.h24
-rw-r--r--gobject/ChangeLog12
-rw-r--r--gobject/gobject-query.c2
-rw-r--r--gobject/gsignal.c4
-rw-r--r--gobject/gsignal.h99
-rw-r--r--gobject/gtype.c12
-rw-r--r--gobject/gtype.h54
-rw-r--r--gobject/gvaluetypes.c2
-rw-r--r--gobject/gvaluetypes.h87
-rw-r--r--gquark.h8
-rw-r--r--gspawn.c3
-rw-r--r--gstrfuncs.c4
-rw-r--r--gstrfuncs.h102
-rw-r--r--gthread.c2
-rw-r--r--gunicode.h20
-rw-r--r--gutils.c29
-rw-r--r--gutils.h52
-rw-r--r--gwin32.h8
-rw-r--r--testglib.c2
-rw-r--r--tests/testglib.c2
49 files changed, 766 insertions, 423 deletions
diff --git a/ChangeLog b/ChangeLog
index 5b2bb85bc..57798514a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,42 @@
+2001-02-17 Havoc Pennington <hp@pobox.com>
+
+ * gthread.c: include string.h
+
+ Applied patch from Soeren Sandmann:
+
+ * testglib.c: const fixes
+
+ * gwin32.h: format cleanups
+
+ * gutils.c (g_atexit): constify a variable
+ (g_find_program_in_path): constification
+ (g_basename): G_CONST_RETURN
+ (g_path_skip_root): G_CONST_RETURN
+ (g_getenv): G_CONST_RETURN
+ (g_get_user_name): G_CONST_RETURN
+ (g_get_real_name): G_CONST_RETURN
+ (g_get_home_dir): G_CONST_RETURN
+ (g_get_tmp_dir): G_CONST_RETURN
+ (g_get_prgname): G_CONST_RETURN
+ (_glib_gettext): G_CONST_RETURN
+
+ * gunicode.h: formatting cleanups
+
+ * gstrfuncs.c (g_strerror): G_CONST_RETURN
+ (g_strsignal): G_CONST_RETURN
+
+ * gspawn.c (g_execute): const on variables
+
+ * gmessages.c (printf_string_upper_bound): fix const on a variable
+
+ * gmem.c (g_mem_chunk_new): make the "name" arg const
+ (struct _GRealMemChunk): make the "name" field const
+
+ * gfileutils.c (g_file_open_tmp): store const return in a const
+ gchar* variable
+
+ * gdataset.c (g_quark_to_string): G_CONST_RETURN
+
Sat Feb 17 07:26:33 2001 Tim Janik <timj@gtk.org>
* configure.in (G_MODULE_HAVE_DLERROR): add check for broken RTLD_GLOBAL
diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0
index 5b2bb85bc..57798514a 100644
--- a/ChangeLog.pre-2-0
+++ b/ChangeLog.pre-2-0
@@ -1,3 +1,42 @@
+2001-02-17 Havoc Pennington <hp@pobox.com>
+
+ * gthread.c: include string.h
+
+ Applied patch from Soeren Sandmann:
+
+ * testglib.c: const fixes
+
+ * gwin32.h: format cleanups
+
+ * gutils.c (g_atexit): constify a variable
+ (g_find_program_in_path): constification
+ (g_basename): G_CONST_RETURN
+ (g_path_skip_root): G_CONST_RETURN
+ (g_getenv): G_CONST_RETURN
+ (g_get_user_name): G_CONST_RETURN
+ (g_get_real_name): G_CONST_RETURN
+ (g_get_home_dir): G_CONST_RETURN
+ (g_get_tmp_dir): G_CONST_RETURN
+ (g_get_prgname): G_CONST_RETURN
+ (_glib_gettext): G_CONST_RETURN
+
+ * gunicode.h: formatting cleanups
+
+ * gstrfuncs.c (g_strerror): G_CONST_RETURN
+ (g_strsignal): G_CONST_RETURN
+
+ * gspawn.c (g_execute): const on variables
+
+ * gmessages.c (printf_string_upper_bound): fix const on a variable
+
+ * gmem.c (g_mem_chunk_new): make the "name" arg const
+ (struct _GRealMemChunk): make the "name" field const
+
+ * gfileutils.c (g_file_open_tmp): store const return in a const
+ gchar* variable
+
+ * gdataset.c (g_quark_to_string): G_CONST_RETURN
+
Sat Feb 17 07:26:33 2001 Tim Janik <timj@gtk.org>
* configure.in (G_MODULE_HAVE_DLERROR): add check for broken RTLD_GLOBAL
diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10
index 5b2bb85bc..57798514a 100644
--- a/ChangeLog.pre-2-10
+++ b/ChangeLog.pre-2-10
@@ -1,3 +1,42 @@
+2001-02-17 Havoc Pennington <hp@pobox.com>
+
+ * gthread.c: include string.h
+
+ Applied patch from Soeren Sandmann:
+
+ * testglib.c: const fixes
+
+ * gwin32.h: format cleanups
+
+ * gutils.c (g_atexit): constify a variable
+ (g_find_program_in_path): constification
+ (g_basename): G_CONST_RETURN
+ (g_path_skip_root): G_CONST_RETURN
+ (g_getenv): G_CONST_RETURN
+ (g_get_user_name): G_CONST_RETURN
+ (g_get_real_name): G_CONST_RETURN
+ (g_get_home_dir): G_CONST_RETURN
+ (g_get_tmp_dir): G_CONST_RETURN
+ (g_get_prgname): G_CONST_RETURN
+ (_glib_gettext): G_CONST_RETURN
+
+ * gunicode.h: formatting cleanups
+
+ * gstrfuncs.c (g_strerror): G_CONST_RETURN
+ (g_strsignal): G_CONST_RETURN
+
+ * gspawn.c (g_execute): const on variables
+
+ * gmessages.c (printf_string_upper_bound): fix const on a variable
+
+ * gmem.c (g_mem_chunk_new): make the "name" arg const
+ (struct _GRealMemChunk): make the "name" field const
+
+ * gfileutils.c (g_file_open_tmp): store const return in a const
+ gchar* variable
+
+ * gdataset.c (g_quark_to_string): G_CONST_RETURN
+
Sat Feb 17 07:26:33 2001 Tim Janik <timj@gtk.org>
* configure.in (G_MODULE_HAVE_DLERROR): add check for broken RTLD_GLOBAL
diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12
index 5b2bb85bc..57798514a 100644
--- a/ChangeLog.pre-2-12
+++ b/ChangeLog.pre-2-12
@@ -1,3 +1,42 @@
+2001-02-17 Havoc Pennington <hp@pobox.com>
+
+ * gthread.c: include string.h
+
+ Applied patch from Soeren Sandmann:
+
+ * testglib.c: const fixes
+
+ * gwin32.h: format cleanups
+
+ * gutils.c (g_atexit): constify a variable
+ (g_find_program_in_path): constification
+ (g_basename): G_CONST_RETURN
+ (g_path_skip_root): G_CONST_RETURN
+ (g_getenv): G_CONST_RETURN
+ (g_get_user_name): G_CONST_RETURN
+ (g_get_real_name): G_CONST_RETURN
+ (g_get_home_dir): G_CONST_RETURN
+ (g_get_tmp_dir): G_CONST_RETURN
+ (g_get_prgname): G_CONST_RETURN
+ (_glib_gettext): G_CONST_RETURN
+
+ * gunicode.h: formatting cleanups
+
+ * gstrfuncs.c (g_strerror): G_CONST_RETURN
+ (g_strsignal): G_CONST_RETURN
+
+ * gspawn.c (g_execute): const on variables
+
+ * gmessages.c (printf_string_upper_bound): fix const on a variable
+
+ * gmem.c (g_mem_chunk_new): make the "name" arg const
+ (struct _GRealMemChunk): make the "name" field const
+
+ * gfileutils.c (g_file_open_tmp): store const return in a const
+ gchar* variable
+
+ * gdataset.c (g_quark_to_string): G_CONST_RETURN
+
Sat Feb 17 07:26:33 2001 Tim Janik <timj@gtk.org>
* configure.in (G_MODULE_HAVE_DLERROR): add check for broken RTLD_GLOBAL
diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2
index 5b2bb85bc..57798514a 100644
--- a/ChangeLog.pre-2-2
+++ b/ChangeLog.pre-2-2
@@ -1,3 +1,42 @@
+2001-02-17 Havoc Pennington <hp@pobox.com>
+
+ * gthread.c: include string.h
+
+ Applied patch from Soeren Sandmann:
+
+ * testglib.c: const fixes
+
+ * gwin32.h: format cleanups
+
+ * gutils.c (g_atexit): constify a variable
+ (g_find_program_in_path): constification
+ (g_basename): G_CONST_RETURN
+ (g_path_skip_root): G_CONST_RETURN
+ (g_getenv): G_CONST_RETURN
+ (g_get_user_name): G_CONST_RETURN
+ (g_get_real_name): G_CONST_RETURN
+ (g_get_home_dir): G_CONST_RETURN
+ (g_get_tmp_dir): G_CONST_RETURN
+ (g_get_prgname): G_CONST_RETURN
+ (_glib_gettext): G_CONST_RETURN
+
+ * gunicode.h: formatting cleanups
+
+ * gstrfuncs.c (g_strerror): G_CONST_RETURN
+ (g_strsignal): G_CONST_RETURN
+
+ * gspawn.c (g_execute): const on variables
+
+ * gmessages.c (printf_string_upper_bound): fix const on a variable
+
+ * gmem.c (g_mem_chunk_new): make the "name" arg const
+ (struct _GRealMemChunk): make the "name" field const
+
+ * gfileutils.c (g_file_open_tmp): store const return in a const
+ gchar* variable
+
+ * gdataset.c (g_quark_to_string): G_CONST_RETURN
+
Sat Feb 17 07:26:33 2001 Tim Janik <timj@gtk.org>
* configure.in (G_MODULE_HAVE_DLERROR): add check for broken RTLD_GLOBAL
diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4
index 5b2bb85bc..57798514a 100644
--- a/ChangeLog.pre-2-4
+++ b/ChangeLog.pre-2-4
@@ -1,3 +1,42 @@
+2001-02-17 Havoc Pennington <hp@pobox.com>
+
+ * gthread.c: include string.h
+
+ Applied patch from Soeren Sandmann:
+
+ * testglib.c: const fixes
+
+ * gwin32.h: format cleanups
+
+ * gutils.c (g_atexit): constify a variable
+ (g_find_program_in_path): constification
+ (g_basename): G_CONST_RETURN
+ (g_path_skip_root): G_CONST_RETURN
+ (g_getenv): G_CONST_RETURN
+ (g_get_user_name): G_CONST_RETURN
+ (g_get_real_name): G_CONST_RETURN
+ (g_get_home_dir): G_CONST_RETURN
+ (g_get_tmp_dir): G_CONST_RETURN
+ (g_get_prgname): G_CONST_RETURN
+ (_glib_gettext): G_CONST_RETURN
+
+ * gunicode.h: formatting cleanups
+
+ * gstrfuncs.c (g_strerror): G_CONST_RETURN
+ (g_strsignal): G_CONST_RETURN
+
+ * gspawn.c (g_execute): const on variables
+
+ * gmessages.c (printf_string_upper_bound): fix const on a variable
+
+ * gmem.c (g_mem_chunk_new): make the "name" arg const
+ (struct _GRealMemChunk): make the "name" field const
+
+ * gfileutils.c (g_file_open_tmp): store const return in a const
+ gchar* variable
+
+ * gdataset.c (g_quark_to_string): G_CONST_RETURN
+
Sat Feb 17 07:26:33 2001 Tim Janik <timj@gtk.org>
* configure.in (G_MODULE_HAVE_DLERROR): add check for broken RTLD_GLOBAL
diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6
index 5b2bb85bc..57798514a 100644
--- a/ChangeLog.pre-2-6
+++ b/ChangeLog.pre-2-6
@@ -1,3 +1,42 @@
+2001-02-17 Havoc Pennington <hp@pobox.com>
+
+ * gthread.c: include string.h
+
+ Applied patch from Soeren Sandmann:
+
+ * testglib.c: const fixes
+
+ * gwin32.h: format cleanups
+
+ * gutils.c (g_atexit): constify a variable
+ (g_find_program_in_path): constification
+ (g_basename): G_CONST_RETURN
+ (g_path_skip_root): G_CONST_RETURN
+ (g_getenv): G_CONST_RETURN
+ (g_get_user_name): G_CONST_RETURN
+ (g_get_real_name): G_CONST_RETURN
+ (g_get_home_dir): G_CONST_RETURN
+ (g_get_tmp_dir): G_CONST_RETURN
+ (g_get_prgname): G_CONST_RETURN
+ (_glib_gettext): G_CONST_RETURN
+
+ * gunicode.h: formatting cleanups
+
+ * gstrfuncs.c (g_strerror): G_CONST_RETURN
+ (g_strsignal): G_CONST_RETURN
+
+ * gspawn.c (g_execute): const on variables
+
+ * gmessages.c (printf_string_upper_bound): fix const on a variable
+
+ * gmem.c (g_mem_chunk_new): make the "name" arg const
+ (struct _GRealMemChunk): make the "name" field const
+
+ * gfileutils.c (g_file_open_tmp): store const return in a const
+ gchar* variable
+
+ * gdataset.c (g_quark_to_string): G_CONST_RETURN
+
Sat Feb 17 07:26:33 2001 Tim Janik <timj@gtk.org>
* configure.in (G_MODULE_HAVE_DLERROR): add check for broken RTLD_GLOBAL
diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8
index 5b2bb85bc..57798514a 100644
--- a/ChangeLog.pre-2-8
+++ b/ChangeLog.pre-2-8
@@ -1,3 +1,42 @@
+2001-02-17 Havoc Pennington <hp@pobox.com>
+
+ * gthread.c: include string.h
+
+ Applied patch from Soeren Sandmann:
+
+ * testglib.c: const fixes
+
+ * gwin32.h: format cleanups
+
+ * gutils.c (g_atexit): constify a variable
+ (g_find_program_in_path): constification
+ (g_basename): G_CONST_RETURN
+ (g_path_skip_root): G_CONST_RETURN
+ (g_getenv): G_CONST_RETURN
+ (g_get_user_name): G_CONST_RETURN
+ (g_get_real_name): G_CONST_RETURN
+ (g_get_home_dir): G_CONST_RETURN
+ (g_get_tmp_dir): G_CONST_RETURN
+ (g_get_prgname): G_CONST_RETURN
+ (_glib_gettext): G_CONST_RETURN
+
+ * gunicode.h: formatting cleanups
+
+ * gstrfuncs.c (g_strerror): G_CONST_RETURN
+ (g_strsignal): G_CONST_RETURN
+
+ * gspawn.c (g_execute): const on variables
+
+ * gmessages.c (printf_string_upper_bound): fix const on a variable
+
+ * gmem.c (g_mem_chunk_new): make the "name" arg const
+ (struct _GRealMemChunk): make the "name" field const
+
+ * gfileutils.c (g_file_open_tmp): store const return in a const
+ gchar* variable
+
+ * gdataset.c (g_quark_to_string): G_CONST_RETURN
+
Sat Feb 17 07:26:33 2001 Tim Janik <timj@gtk.org>
* configure.in (G_MODULE_HAVE_DLERROR): add check for broken RTLD_GLOBAL
diff --git a/gdataset.c b/gdataset.c
index 020b1e70d..136141ec5 100644
--- a/gdataset.c
+++ b/gdataset.c
@@ -595,7 +595,7 @@ g_quark_from_static_string (const gchar *string)
return quark;
}
-gchar*
+G_CONST_RETURN gchar*
g_quark_to_string (GQuark quark)
{
gchar* result = NULL;
diff --git a/gfileutils.c b/gfileutils.c
index 7a03315f8..7ea229f0d 100644
--- a/gfileutils.c
+++ b/gfileutils.c
@@ -618,7 +618,7 @@ g_file_open_tmp (const char *tmpl,
GError **error)
{
int retval;
- char *tmpdir;
+ const char *tmpdir;
char *sep;
char *fulltemplate;
diff --git a/glib/gdataset.c b/glib/gdataset.c
index 020b1e70d..136141ec5 100644
--- a/glib/gdataset.c
+++ b/glib/gdataset.c
@@ -595,7 +595,7 @@ g_quark_from_static_string (const gchar *string)
return quark;
}
-gchar*
+G_CONST_RETURN gchar*
g_quark_to_string (GQuark quark)
{
gchar* result = NULL;
diff --git a/glib/gfileutils.c b/glib/gfileutils.c
index 7a03315f8..7ea229f0d 100644
--- a/glib/gfileutils.c
+++ b/glib/gfileutils.c
@@ -618,7 +618,7 @@ g_file_open_tmp (const char *tmpl,
GError **error)
{
int retval;
- char *tmpdir;
+ const char *tmpdir;
char *sep;
char *fulltemplate;
diff --git a/glib/gmem.c b/glib/gmem.c
index 52d376530..a7d715341 100644
--- a/glib/gmem.c
+++ b/glib/gmem.c
@@ -591,7 +591,7 @@ struct _GMemArea
struct _GRealMemChunk
{
- gchar *name; /* name of this MemChunk...used for debugging output */
+ const gchar *name; /* name of this MemChunk...used for debugging output */
gint type; /* the type of MemChunk: ALLOC_ONLY or ALLOC_AND_FREE */
gint num_mem_areas; /* the number of memory areas */
gint num_marked_areas; /* the number of areas marked for deletion */
@@ -622,10 +622,10 @@ static GMutex *mem_chunks_lock = NULL;
static GRealMemChunk *mem_chunks = NULL;
GMemChunk*
-g_mem_chunk_new (gchar *name,
- gint atom_size,
- gulong area_size,
- gint type)
+g_mem_chunk_new (const gchar *name,
+ gint atom_size,
+ gulong area_size,
+ gint type)
{
GRealMemChunk *mem_chunk;
gulong rarea_size;
@@ -705,8 +705,8 @@ g_mem_chunk_destroy (GMemChunk *mem_chunk)
g_mutex_unlock (mem_chunks_lock);
if (rmem_chunk->type == G_ALLOC_AND_FREE)
- g_tree_destroy (rmem_chunk->mem_tree);
-
+ g_tree_destroy (rmem_chunk->mem_tree);
+
g_free (rmem_chunk);
LEAVE_MEM_CHUNK_ROUTINE ();
@@ -1135,10 +1135,10 @@ typedef struct {
} GMinimalMemChunk;
GMemChunk*
-g_mem_chunk_new (gchar *name,
- gint atom_size,
- gulong area_size,
- gint type)
+g_mem_chunk_new (const gchar *name,
+ gint atom_size,
+ gulong area_size,
+ gint type)
{
GMinimalMemChunk *mem_chunk;
diff --git a/glib/gmem.h b/glib/gmem.h
index a96e372e1..014326c6b 100644
--- a/glib/gmem.h
+++ b/glib/gmem.h
@@ -132,19 +132,19 @@ void g_mem_profile (void);
#define G_ALLOC_ONLY 1
#define G_ALLOC_AND_FREE 2
-GMemChunk* g_mem_chunk_new (gchar *name,
- gint atom_size,
- gulong area_size,
- gint type);
-void g_mem_chunk_destroy (GMemChunk *mem_chunk);
-gpointer g_mem_chunk_alloc (GMemChunk *mem_chunk);
-gpointer g_mem_chunk_alloc0 (GMemChunk *mem_chunk);
-void g_mem_chunk_free (GMemChunk *mem_chunk,
- gpointer mem);
-void g_mem_chunk_clean (GMemChunk *mem_chunk);
-void g_mem_chunk_reset (GMemChunk *mem_chunk);
-void g_mem_chunk_print (GMemChunk *mem_chunk);
-void g_mem_chunk_info (void);
+GMemChunk* g_mem_chunk_new (const gchar *name,
+ gint atom_size,
+ gulong area_size,
+ gint type);
+void g_mem_chunk_destroy (GMemChunk *mem_chunk);
+gpointer g_mem_chunk_alloc (GMemChunk *mem_chunk);
+gpointer g_mem_chunk_alloc0 (GMemChunk *mem_chunk);
+void g_mem_chunk_free (GMemChunk *mem_chunk,
+ gpointer mem);
+void g_mem_chunk_clean (GMemChunk *mem_chunk);
+void g_mem_chunk_reset (GMemChunk *mem_chunk);
+void g_mem_chunk_print (GMemChunk *mem_chunk);
+void g_mem_chunk_info (void);
/* Ah yes...we have a "g_blow_chunks" function.
* "g_blow_chunks" simply compresses all the chunks. This operation
diff --git a/glib/gmessages.c b/glib/gmessages.c
index f63777881..ced7149ec 100644
--- a/glib/gmessages.c
+++ b/glib/gmessages.c
@@ -879,7 +879,7 @@ printf_string_upper_bound (const gchar *format,
GDoubleIEEE754 u_double;
guint v_uint;
gint v_int;
- gchar *v_string;
+ const gchar *v_string;
/* beware of positional parameters
*/
diff --git a/glib/gquark.h b/glib/gquark.h
index 08dd9e4d4..e8756ef61 100644
--- a/glib/gquark.h
+++ b/glib/gquark.h
@@ -35,10 +35,10 @@ typedef guint32 GQuark;
/* Quarks (string<->id association)
*/
-GQuark g_quark_try_string (const gchar *string);
-GQuark g_quark_from_static_string (const gchar *string);
-GQuark g_quark_from_string (const gchar *string);
-gchar* g_quark_to_string (GQuark quark) G_GNUC_CONST;
+GQuark g_quark_try_string (const gchar *string);
+GQuark g_quark_from_static_string (const gchar *string);
+GQuark g_quark_from_string (const gchar *string);
+G_CONST_RETURN gchar* g_quark_to_string (GQuark quark) G_GNUC_CONST;
G_END_DECLS
diff --git a/glib/gspawn.c b/glib/gspawn.c
index fdb8752da..c8208f6ca 100644
--- a/glib/gspawn.c
+++ b/glib/gspawn.c
@@ -1288,7 +1288,8 @@ g_execute (const gchar *file,
else
{
gboolean got_eacces = 0;
- char *path, *p, *name, *freeme;
+ const gchar *path, *p;
+ gchar *name, *freeme;
size_t len;
size_t pathlen;
diff --git a/glib/gstrfuncs.c b/glib/gstrfuncs.c
index 619d20f13..cf9defb7c 100644
--- a/glib/gstrfuncs.c
+++ b/glib/gstrfuncs.c
@@ -226,7 +226,7 @@ g_strtod (const gchar *nptr,
}
}
-gchar*
+G_CONST_RETURN gchar*
g_strerror (gint errnum)
{
static GStaticPrivate msg_private = G_STATIC_PRIVATE_INIT;
@@ -669,7 +669,7 @@ g_strerror (gint errnum)
return msg;
}
-gchar*
+G_CONST_RETURN gchar*
g_strsignal (gint signum)
{
static GStaticPrivate msg_private = G_STATIC_PRIVATE_INIT;
diff --git a/glib/gstrfuncs.h b/glib/gstrfuncs.h
index 4d33272fc..11064c327 100644
--- a/glib/gstrfuncs.h
+++ b/glib/gstrfuncs.h
@@ -36,58 +36,58 @@ G_BEGIN_DECLS
* return a constant string that must not be freed.
*/
#define G_STR_DELIMITERS "_-|> <."
-gchar* g_strdelimit (gchar *string,
- const gchar *delimiters,
- gchar new_delimiter);
-gchar* g_strcanon (gchar *string,
- const gchar *valid_chars,
- gchar subsitutor);
-gdouble g_strtod (const gchar *nptr,
- gchar **endptr);
-gchar* g_strerror (gint errnum) G_GNUC_CONST;
-gchar* g_strsignal (gint signum) G_GNUC_CONST;
-gint g_strcasecmp (const gchar *s1,
- const gchar *s2);
-gint g_strncasecmp (const gchar *s1,
- const gchar *s2,
- guint n);
-gchar* g_strdown (gchar *string);
-gchar* g_strup (gchar *string);
-gchar* g_strreverse (gchar *string);
-gsize g_strlcpy (gchar *dest,
- const gchar *src,
- gsize dest_size);
-gsize g_strlcat (gchar *dest,
- const gchar *src,
- gsize dest_size);
+gchar* g_strdelimit (gchar *string,
+ const gchar *delimiters,
+ gchar new_delimiter);
+gchar* g_strcanon (gchar *string,
+ const gchar *valid_chars,
+ gchar subsitutor);
+gdouble g_strtod (const gchar *nptr,
+ gchar **endptr);
+G_CONST_RETURN gchar* g_strerror (gint errnum) G_GNUC_CONST;
+G_CONST_RETURN gchar* g_strsignal (gint signum) G_GNUC_CONST;
+gint g_strcasecmp (const gchar *s1,
+ const gchar *s2);
+gint g_strncasecmp (const gchar *s1,
+ const gchar *s2,
+ guint n);
+gchar* g_strdown (gchar *string);
+gchar* g_strup (gchar *string);
+gchar* g_strreverse (gchar *string);
+gsize g_strlcpy (gchar *dest,
+ const gchar *src,
+ gsize dest_size);
+gsize g_strlcat (gchar *dest,
+ const gchar *src,
+ gsize dest_size);
/* removes leading spaces */
-gchar* g_strchug (gchar *string);
+gchar* g_strchug (gchar *string);
/* removes trailing spaces */
-gchar* g_strchomp (gchar *string);
+gchar* g_strchomp (gchar *string);
/* removes leading & trailing spaces */
#define g_strstrip( string ) g_strchomp (g_strchug (string))
/* String utility functions that return a newly allocated string which
* ought to be freed with g_free from the caller at some point.
*/
-gchar* g_strdup (const gchar *str);
-gchar* g_strdup_printf (const gchar *format,
- ...) G_GNUC_PRINTF (1, 2);
-gchar* g_strdup_vprintf (const gchar *format,
- va_list args);
-gchar* g_strndup (const gchar *str,
- guint n);
-gchar* g_strnfill (guint length,
- gchar fill_char);
-gchar* g_strconcat (const gchar *string1,
- ...); /* NULL terminated */
-gchar* g_strjoin (const gchar *separator,
- ...); /* NULL terminated */
+gchar* g_strdup (const gchar *str);
+gchar* g_strdup_printf (const gchar *format,
+ ...) G_GNUC_PRINTF (1, 2);
+gchar* g_strdup_vprintf (const gchar *format,
+ va_list args);
+gchar* g_strndup (const gchar *str,
+ guint n);
+gchar* g_strnfill (guint length,
+ gchar fill_char);
+gchar* g_strconcat (const gchar *string1,
+ ...); /* NULL terminated */
+gchar* g_strjoin (const gchar *separator,
+ ...); /* NULL terminated */
/* Make a copy of a string interpreting C string -style escape
* sequences. Inverse of g_strescape. The recognized sequences are \b
* \f \n \r \t \\ \" and the octal format.
*/
-gchar* g_strcompress (const gchar *source);
+gchar* g_strcompress (const gchar *source);
/* Copy a string escaping nonprintable characters like in C strings.
* Inverse of g_strcompress. The exceptions parameter, if non-NULL, points
@@ -97,11 +97,11 @@ gchar* g_strcompress (const gchar *source);
* Luckily this function wasn't used much, using NULL as second parameter
* provides mostly identical semantics.
*/
-gchar* g_strescape (const gchar *source,
- const gchar *exceptions);
+gchar* g_strescape (const gchar *source,
+ const gchar *exceptions);
-gpointer g_memdup (gconstpointer mem,
- guint byte_size);
+gpointer g_memdup (gconstpointer mem,
+ guint byte_size);
/* NULL terminated string arrays.
* g_strsplit() splits up string into max_tokens tokens at delim and
@@ -111,13 +111,13 @@ gpointer g_memdup (gconstpointer mem,
* g_strfreev() frees the array itself and all of its strings.
* g_strdupv() copies a NULL-terminated array of strings
*/
-gchar** g_strsplit (const gchar *string,
- const gchar *delimiter,
- gint max_tokens);
-gchar* g_strjoinv (const gchar *separator,
- gchar **str_array);
-void g_strfreev (gchar **str_array);
-gchar** g_strdupv (gchar **str_array);
+gchar** g_strsplit (const gchar *string,
+ const gchar *delimiter,
+ gint max_tokens);
+gchar* g_strjoinv (const gchar *separator,
+ gchar **str_array);
+void g_strfreev (gchar **str_array);
+gchar** g_strdupv (gchar **str_array);
G_END_DECLS
diff --git a/glib/gthread.c b/glib/gthread.c
index aa3741236..dfa484630 100644
--- a/glib/gthread.c
+++ b/glib/gthread.c
@@ -46,6 +46,8 @@
#include <unistd.h>
#endif
+#include <string.h>
+
#if GLIB_SIZEOF_SYSTEM_THREAD == SIZEOF_VOID_P
# define g_system_thread_equal(thread1, thread2) \
(thread1.dummy_pointer == thread2.dummy_pointer)
diff --git a/glib/gunicode.h b/glib/gunicode.h
index db4800a63..2c43900af 100644
--- a/glib/gunicode.h
+++ b/glib/gunicode.h
@@ -180,30 +180,30 @@ GLIB_VAR char g_utf8_skip[256];
#define g_utf8_next_char(p) (char *)((p) + g_utf8_skip[*(guchar *)(p)])
gunichar g_utf8_get_char (const gchar *p);
-gchar * g_utf8_offset_to_pointer (const gchar *str,
- gint offset);
+gchar* g_utf8_offset_to_pointer (const gchar *str,
+ gint offset);
gint g_utf8_pointer_to_offset (const gchar *str,
const gchar *pos);
-gchar * g_utf8_prev_char (const gchar *p);
-gchar * g_utf8_find_next_char (const gchar *p,
+gchar* g_utf8_prev_char (const gchar *p);
+gchar* g_utf8_find_next_char (const gchar *p,
const gchar *end);
-gchar * g_utf8_find_prev_char (const gchar *str,
+gchar* g_utf8_find_prev_char (const gchar *str,
const gchar *p);
gint g_utf8_strlen (const gchar *p,
gint max);
/* Copies n characters from src to dest */
-gchar *g_utf8_strncpy (gchar *dest,
+gchar* g_utf8_strncpy (gchar *dest,
const gchar *src,
size_t n);
/* Find the UTF-8 character corresponding to ch, in string p. These
functions are equivalants to strchr and strrchr */
-gchar *g_utf8_strchr (const gchar *p,
+gchar* g_utf8_strchr (const gchar *p,
gunichar c);
-gchar *g_utf8_strrchr (const gchar *p,
+gchar* g_utf8_strrchr (const gchar *p,
gunichar c);
gunichar2 *g_utf8_to_utf16 (const gchar *str,
@@ -224,7 +224,7 @@ gunichar * g_utf16_to_ucs4 (const gunichar2 *str,
gint *items_read,
gint *items_written,
GError **error);
-gchar * g_utf16_to_utf8 (const gunichar2 *str,
+gchar* g_utf16_to_utf8 (const gunichar2 *str,
gint len,
gint *items_read,
gint *items_written,
@@ -234,7 +234,7 @@ gunichar2 *g_ucs4_to_utf16 (const gunichar *str,
gint *items_read,
gint *items_written,
GError **error);
-gchar * g_ucs4_to_utf8 (const gunichar *str,
+gchar* g_ucs4_to_utf8 (const gunichar *str,
gint len,
gint *items_read,
gint *items_written,
diff --git a/glib/gutils.c b/glib/gutils.c
index 61cdcf520..456be3450 100644
--- a/glib/gutils.c
+++ b/glib/gutils.c
@@ -111,7 +111,7 @@ void
g_atexit (GVoidFunc func)
{
gint result;
- gchar *error = NULL;
+ const gchar *error = NULL;
/* keep this in sync with glib.h */
@@ -171,7 +171,8 @@ my_strchrnul (const gchar *str, gchar c)
gchar*
g_find_program_in_path (const gchar *program)
{
- gchar *path, *p, *name, *freeme;
+ const gchar *path, *p;
+ gchar *name, *freeme;
size_t len;
size_t pathlen;
@@ -373,7 +374,7 @@ g_parse_debug_string (const gchar *string,
return result;
}
-gchar*
+G_CONST_RETURN gchar*
g_basename (const gchar *file_name)
{
register gchar *base;
@@ -465,8 +466,8 @@ g_path_is_absolute (const gchar *file_name)
return FALSE;
}
-gchar*
-g_path_skip_root (gchar *file_name)
+G_CONST_RETURN gchar*
+g_path_skip_root (const gchar *file_name)
{
g_return_val_if_fail (file_name != NULL, NULL);
@@ -490,7 +491,7 @@ g_path_skip_root (gchar *file_name)
if (file_name[0] == G_DIR_SEPARATOR)
file_name++;
- return file_name;
+ return (gchar *)file_name;
}
}
#endif
@@ -500,13 +501,13 @@ g_path_skip_root (gchar *file_name)
{
while (file_name[0] == G_DIR_SEPARATOR)
file_name++;
- return file_name;
+ return (gchar *)file_name;
}
#ifdef G_OS_WIN32
/* Skip X:\ */
if (isalpha (file_name[0]) && file_name[1] == ':' && file_name[2] == G_DIR_SEPARATOR)
- return file_name + 3;
+ return (gchar *)file_name + 3;
#endif
return NULL;
@@ -597,7 +598,7 @@ g_get_current_dir (void)
return dir;
}
-gchar*
+G_CONST_RETURN gchar*
g_getenv (const gchar *variable)
{
#ifndef G_OS_WIN32
@@ -864,7 +865,7 @@ g_get_any_init (void)
}
}
-gchar*
+G_CONST_RETURN gchar*
g_get_user_name (void)
{
G_LOCK (g_utils_global);
@@ -875,7 +876,7 @@ g_get_user_name (void)
return g_user_name;
}
-gchar*
+G_CONST_RETURN gchar*
g_get_real_name (void)
{
G_LOCK (g_utils_global);
@@ -892,7 +893,7 @@ g_get_real_name (void)
* deduced, return NULL.
*/
-gchar*
+G_CONST_RETURN gchar*
g_get_home_dir (void)
{
G_LOCK (g_utils_global);
@@ -910,7 +911,7 @@ g_get_home_dir (void)
* and C:\ on Windows.
*/
-gchar*
+G_CONST_RETURN gchar*
g_get_tmp_dir (void)
{
G_LOCK (g_utils_global);
@@ -1014,7 +1015,7 @@ g_get_codeset (void)
#endif /* G_OS_WIN32 */
-gchar *
+G_CONST_RETURN gchar *
_glib_gettext (const gchar *str)
{
gboolean _glib_gettext_initialized = FALSE;
diff --git a/glib/gutils.h b/glib/gutils.h
index 523af02c7..2da2048a1 100644
--- a/glib/gutils.h
+++ b/glib/gutils.h
@@ -113,12 +113,12 @@ G_BEGIN_DECLS
/* Retrive static string info
*/
-gchar* g_get_user_name (void);
-gchar* g_get_real_name (void);
-gchar* g_get_home_dir (void);
-gchar* g_get_tmp_dir (void);
-gchar* g_get_prgname (void);
-void g_set_prgname (const gchar *prgname);
+G_CONST_RETURN gchar* g_get_user_name (void);
+G_CONST_RETURN gchar* g_get_real_name (void);
+G_CONST_RETURN gchar* g_get_home_dir (void);
+G_CONST_RETURN gchar* g_get_tmp_dir (void);
+gchar* g_get_prgname (void);
+void g_set_prgname (const gchar *prgname);
typedef struct _GDebugKey GDebugKey;
@@ -130,40 +130,42 @@ struct _GDebugKey
/* Miscellaneous utility functions
*/
-guint g_parse_debug_string (const gchar *string,
- GDebugKey *keys,
- guint nkeys);
-gint g_snprintf (gchar *string,
- gulong n,
- gchar const *format,
- ...) G_GNUC_PRINTF (3, 4);
-gint g_vsnprintf (gchar *string,
- gulong n,
- gchar const *format,
- va_list args);
+guint g_parse_debug_string (const gchar *string,
+ GDebugKey *keys,
+ guint nkeys);
+gint g_snprintf (gchar *string,
+ gulong n,
+ gchar const *format,
+ ...) G_GNUC_PRINTF (3, 4);
+gint g_vsnprintf (gchar *string,
+ gulong n,
+ gchar const *format,
+ va_list args);
+
/* Check if a file name is an absolute path */
-gboolean g_path_is_absolute (const gchar *file_name);
+gboolean g_path_is_absolute (const gchar *file_name);
+
/* In case of absolute paths, skip the root part */
-gchar* g_path_skip_root (gchar *file_name);
+G_CONST_RETURN gchar* g_path_skip_root (const gchar *file_name);
/* These two functions are deprecated and will be removed in the next
* major release of GLib. Use g_path_get_dirname/g_path_get_basename
* instead. Whatch out! The string returned by g_path_get_basename
* must be g_freed, while the string returned by g_basename must not.*/
-gchar* g_basename (const gchar *file_name);
-gchar* g_dirname (const gchar *file_name);
+G_CONST_RETURN gchar* g_basename (const gchar *file_name);
+gchar* g_dirname (const gchar *file_name);
/* The returned strings are newly allocated with g_malloc() */
-gchar* g_get_current_dir (void);
-gchar* g_path_get_basename (const gchar *file_name);
-gchar* g_path_get_dirname (const gchar *file_name);
+gchar* g_get_current_dir (void);
+gchar* g_path_get_basename (const gchar *file_name);
+gchar* g_path_get_dirname (const gchar *file_name);
/* Get the codeset for the current locale */
/* gchar * g_get_codeset (void); */
/* return the environment string for the variable. The returned memory
* must not be freed. */
-gchar* g_getenv (const gchar *variable);
+G_CONST_RETURN gchar* g_getenv (const gchar *variable);
/* we try to provide a usefull equivalent for ATEXIT if it is
diff --git a/glib/gwin32.h b/glib/gwin32.h
index b30ab1587..3168e08b9 100644
--- a/glib/gwin32.h
+++ b/glib/gwin32.h
@@ -102,18 +102,18 @@ gint g_win32_closedir (DIR *dir);
* returns it as a string of the above form for use in forming file
* names etc. The returned string should be deallocated with g_free().
*/
-gchar * g_win32_getlocale (void);
+gchar* g_win32_getlocale (void);
/* Translate a Win32 error code (as returned by GetLastError()) into
* the corresponding message. The returned string should be deallocated
* with g_free().
*/
-gchar * g_win32_error_message (gint error);
+gchar* g_win32_error_message (gint error);
-gchar * g_win32_get_package_installation_directory (gchar *package,
+gchar* g_win32_get_package_installation_directory (gchar *package,
gchar *dll_name);
-gchar * g_win32_get_package_installation_subdirectory (gchar *package,
+gchar* g_win32_get_package_installation_subdirectory (gchar *package,
gchar *dll_name,
gchar *subdir);
diff --git a/gmem.c b/gmem.c
index 52d376530..a7d715341 100644
--- a/gmem.c
+++ b/gmem.c
@@ -591,7 +591,7 @@ struct _GMemArea
struct _GRealMemChunk
{
- gchar *name; /* name of this MemChunk...used for debugging output */
+ const gchar *name; /* name of this MemChunk...used for debugging output */
gint type; /* the type of MemChunk: ALLOC_ONLY or ALLOC_AND_FREE */
gint num_mem_areas; /* the number of memory areas */
gint num_marked_areas; /* the number of areas marked for deletion */
@@ -622,10 +622,10 @@ static GMutex *mem_chunks_lock = NULL;
static GRealMemChunk *mem_chunks = NULL;
GMemChunk*
-g_mem_chunk_new (gchar *name,
- gint atom_size,
- gulong area_size,
- gint type)
+g_mem_chunk_new (const gchar *name,
+ gint atom_size,
+ gulong area_size,
+ gint type)
{
GRealMemChunk *mem_chunk;
gulong rarea_size;
@@ -705,8 +705,8 @@ g_mem_chunk_destroy (GMemChunk *mem_chunk)
g_mutex_unlock (mem_chunks_lock);
if (rmem_chunk->type == G_ALLOC_AND_FREE)
- g_tree_destroy (rmem_chunk->mem_tree);
-
+ g_tree_destroy (rmem_chunk->mem_tree);
+
g_free (rmem_chunk);
LEAVE_MEM_CHUNK_ROUTINE ();
@@ -1135,10 +1135,10 @@ typedef struct {
} GMinimalMemChunk;
GMemChunk*
-g_mem_chunk_new (gchar *name,
- gint atom_size,
- gulong area_size,
- gint type)
+g_mem_chunk_new (const gchar *name,
+ gint atom_size,
+ gulong area_size,
+ gint type)
{
GMinimalMemChunk *mem_chunk;
diff --git a/gmem.h b/gmem.h
index a96e372e1..014326c6b 100644
--- a/gmem.h
+++ b/gmem.h
@@ -132,19 +132,19 @@ void g_mem_profile (void);
#define G_ALLOC_ONLY 1
#define G_ALLOC_AND_FREE 2
-GMemChunk* g_mem_chunk_new (gchar *name,
- gint atom_size,
- gulong area_size,
- gint type);
-void g_mem_chunk_destroy (GMemChunk *mem_chunk);
-gpointer g_mem_chunk_alloc (GMemChunk *mem_chunk);
-gpointer g_mem_chunk_alloc0 (GMemChunk *mem_chunk);
-void g_mem_chunk_free (GMemChunk *mem_chunk,
- gpointer mem);
-void g_mem_chunk_clean (GMemChunk *mem_chunk);
-void g_mem_chunk_reset (GMemChunk *mem_chunk);
-void g_mem_chunk_print (GMemChunk *mem_chunk);
-void g_mem_chunk_info (void);
+GMemChunk* g_mem_chunk_new (const gchar *name,
+ gint atom_size,
+ gulong area_size,
+ gint type);
+void g_mem_chunk_destroy (GMemChunk *mem_chunk);
+gpointer g_mem_chunk_alloc (GMemChunk *mem_chunk);
+gpointer g_mem_chunk_alloc0 (GMemChunk *mem_chunk);
+void g_mem_chunk_free (GMemChunk *mem_chunk,
+ gpointer mem);
+void g_mem_chunk_clean (GMemChunk *mem_chunk);
+void g_mem_chunk_reset (GMemChunk *mem_chunk);
+void g_mem_chunk_print (GMemChunk *mem_chunk);
+void g_mem_chunk_info (void);
/* Ah yes...we have a "g_blow_chunks" function.
* "g_blow_chunks" simply compresses all the chunks. This operation
diff --git a/gmessages.c b/gmessages.c
index f63777881..ced7149ec 100644
--- a/gmessages.c
+++ b/gmessages.c
@@ -879,7 +879,7 @@ printf_string_upper_bound (const gchar *format,
GDoubleIEEE754 u_double;
guint v_uint;
gint v_int;
- gchar *v_string;
+ const gchar *v_string;
/* beware of positional parameters
*/
diff --git a/gmodule/ChangeLog b/gmodule/ChangeLog
index ff1e640fb..2e8192087 100644
--- a/gmodule/ChangeLog
+++ b/gmodule/ChangeLog
@@ -1,3 +1,10 @@
+2001-02-17 Havoc Pennington <hp@pobox.com>
+
+ Applied patch from Soeren Sandmann:
+
+ * gmodule.c (g_module_error): G_CONST_RETURN
+ (g_module_name): G_CONST_RETURN
+
Sat Feb 17 07:27:15 2001 Tim Janik <timj@gtk.org>
* gmodule.c: work around platforms that have broken RTLD_GLOBAL.
diff --git a/gmodule/gmodule.c b/gmodule/gmodule.c
index 25a6b3758..29848a369 100644
--- a/gmodule/gmodule.c
+++ b/gmodule/gmodule.c
@@ -477,7 +477,7 @@ g_module_make_resident (GModule *module)
module->is_resident = TRUE;
}
-gchar*
+G_CONST_RETURN gchar*
g_module_error (void)
{
return g_static_private_get (&module_error_private);
@@ -488,7 +488,7 @@ g_module_symbol (GModule *module,
const gchar *symbol_name,
gpointer *symbol)
{
- gchar *module_error;
+ const gchar *module_error;
if (symbol)
*symbol = NULL;
@@ -527,7 +527,7 @@ g_module_symbol (GModule *module,
return !module_error;
}
-gchar*
+G_CONST_RETURN gchar*
g_module_name (GModule *module)
{
g_return_val_if_fail (module != NULL, NULL);
diff --git a/gmodule/gmodule.h b/gmodule/gmodule.h
index 6bc75064a..18d0353ab 100644
--- a/gmodule/gmodule.h
+++ b/gmodule/gmodule.h
@@ -58,26 +58,25 @@ typedef void (*GModuleUnload) (GModule *module);
gboolean g_module_supported (void) G_GNUC_CONST;
/* open a module `file_name' and return handle, which is NULL on error */
-GModule* g_module_open (const gchar *file_name,
- GModuleFlags flags);
+GModule* g_module_open (const gchar *file_name,
+ GModuleFlags flags);
/* close a previously opened module, returns TRUE on success */
-gboolean g_module_close (GModule *module);
+gboolean g_module_close (GModule *module);
/* make a module resident so g_module_close on it will be ignored */
-void g_module_make_resident (GModule *module);
+void g_module_make_resident (GModule *module);
/* query the last module error as a string */
-gchar* g_module_error (void);
+G_CONST_RETURN gchar* g_module_error (void);
/* retrive a symbol pointer from `module', returns TRUE on success */
-gboolean g_module_symbol (GModule *module,
- const gchar *symbol_name,
- gpointer *symbol);
+gboolean g_module_symbol (GModule *module,
+ const gchar *symbol_name,
+ gpointer *symbol);
/* retrive the file name from an existing module */
-gchar* g_module_name (GModule *module);
-
+G_CONST_RETURN gchar* g_module_name (GModule *module);
/* Build the actual file name containing a module. `directory' is the
* directory where the module file is supposed to be, or NULL or empty
@@ -90,8 +89,9 @@ gchar* g_module_name (GModule *module);
*
* No checks are made that the file exists, or is of correct type.
*/
-gchar* g_module_build_path (const gchar *directory,
- const gchar *module_name);
+gchar* g_module_build_path (const gchar *directory,
+ const gchar *module_name);
+
#ifdef __cplusplus
}
diff --git a/gobject/ChangeLog b/gobject/ChangeLog
index 6d8f04fbe..a97faf0e1 100644
--- a/gobject/ChangeLog
+++ b/gobject/ChangeLog
@@ -1,3 +1,15 @@
+2001-02-17 Havoc Pennington <hp@pobox.com>
+
+ Applied patch from Soeren Sandmann:
+
+ * gvaluetypes.c (g_value_get_string): G_CONST_RETURN
+
+ * gtype.c (g_type_name): G_CONST_RETURN
+
+ * gsignal.c (g_signal_name): G_CONST_RETURN
+
+ * gobject-query.c (main): const fix
+
Sat Feb 17 07:58:46 2001 Tim Janik <timj@gtk.org>
* genums.h (G_TYPE_IS_FLAGS): patch from sven to fixup
diff --git a/gobject/gobject-query.c b/gobject/gobject-query.c
index 8a440db3a..37f87980c 100644
--- a/gobject/gobject-query.c
+++ b/gobject/gobject-query.c
@@ -213,7 +213,7 @@ main (gint argc,
root = ~0;
for (i = 0; i < 256; i++)
{
- gchar *name = g_type_name (i);
+ const gchar *name = g_type_name (i);
if (name)
show_nodes (i, 0, iindent);
diff --git a/gobject/gsignal.c b/gobject/gsignal.c
index 3c91c679d..14a9cea36 100644
--- a/gobject/gsignal.c
+++ b/gobject/gsignal.c
@@ -813,7 +813,7 @@ g_signal_lookup (const gchar *name,
return signal_id;
}
-gchar*
+G_CONST_RETURN gchar*
g_signal_name (guint signal_id)
{
SignalNode *node;
@@ -873,7 +873,7 @@ g_signal_list_ids (GType itype,
for (i = 0; i < n_nodes; i++)
if (keys[i].itype == itype)
{
- gchar *name = g_quark_to_string (keys[i].quark);
+ const gchar *name = g_quark_to_string (keys[i].quark);
/* Signal names with "_" in them are aliases to the same
* name with "-" instead of "_".
diff --git a/gobject/gsignal.h b/gobject/gsignal.h
index b81a92aab..312c5e055 100644
--- a/gobject/gsignal.h
+++ b/gobject/gsignal.h
@@ -88,55 +88,56 @@ struct _GSignalQuery
/* --- signals --- */
-guint g_signal_newv (const gchar *signal_name,
- GType itype,
- GSignalFlags signal_flags,
- GClosure *class_closure,
- GSignalAccumulator accumulator,
- GSignalCMarshaller c_marshaller,
- GType return_type,
- guint n_params,
- GType *param_types);
-guint g_signal_new_valist (const gchar *signal_name,
- GType itype,
- GSignalFlags signal_flags,
- GClosure *class_closure,
- GSignalAccumulator accumulator,
- GSignalCMarshaller c_marshaller,
- GType return_type,
- guint n_params,
- va_list args);
-guint g_signal_newc (const gchar *signal_name,
- GType itype,
- GSignalFlags signal_flags,
- guint class_offset,
- GSignalAccumulator accumulator,
- GSignalCMarshaller c_marshaller,
- GType return_type,
- guint n_params,
- ...);
-void g_signal_emitv (const GValue *instance_and_params,
- guint signal_id,
- GQuark detail,
- GValue *return_value);
-void g_signal_emit_valist (gpointer instance,
- guint signal_id,
- GQuark detail,
- va_list var_args);
-void g_signal_emit (gpointer instance,
- guint signal_id,
- GQuark detail,
- ...);
-void g_signal_emit_by_name (gpointer instance,
- const gchar *detailed_signal,
- ...);
-guint g_signal_lookup (const gchar *name,
- GType itype);
-gchar* g_signal_name (guint signal_id);
-void g_signal_query (guint signal_id,
- GSignalQuery *query);
-guint* g_signal_list_ids (GType itype,
- guint *n_ids);
+guint g_signal_newv (const gchar *signal_name,
+ GType itype,
+ GSignalFlags signal_flags,
+ GClosure *class_closure,
+ GSignalAccumulator accumulator,
+ GSignalCMarshaller c_marshaller,
+ GType return_type,
+ guint n_params,
+ GType *param_types);
+guint g_signal_new_valist (const gchar *signal_name,
+ GType itype,
+ GSignalFlags signal_flags,
+ GClosure *class_closure,
+ GSignalAccumulator accumulator,
+ GSignalCMarshaller c_marshaller,
+ GType return_type,
+ guint n_params,
+ va_list args);
+guint g_signal_newc (const gchar *signal_name,
+ GType itype,
+ GSignalFlags signal_flags,
+ guint class_offset,
+ GSignalAccumulator accumulator,
+ GSignalCMarshaller c_marshaller,
+ GType return_type,
+ guint n_params,
+ ...);
+void g_signal_emitv (const GValue *instance_and_params,
+ guint signal_id,
+ GQuark detail,
+ GValue *return_value);
+void g_signal_emit_valist (gpointer instance,
+ guint signal_id,
+ GQuark detail,
+ va_list var_args);
+void g_signal_emit (gpointer instance,
+ guint signal_id,
+ GQuark detail,
+ ...);
+void g_signal_emit_by_name (gpointer instance,
+ const gchar *detailed_signal,
+ ...);
+guint g_signal_lookup (const gchar *name,
+ GType itype);
+G_CONST_RETURN gchar* g_signal_name (guint signal_id);
+void g_signal_query (guint signal_id,
+ GSignalQuery *query);
+guint* g_signal_list_ids (GType itype,
+ guint *n_ids);
+
/* --- signal emissions --- */
void g_signal_stop_emission (gpointer instance,
diff --git a/gobject/gtype.c b/gobject/gtype.c
index 4e4096f36..bcbed34f8 100644
--- a/gobject/gtype.c
+++ b/gobject/gtype.c
@@ -68,7 +68,7 @@ static GStaticRWLock type_rw_lock = G_STATIC_RW_LOCK_INIT;
#define G_WRITE_UNLOCK(rw_lock) g_static_rw_lock_writer_unlock (rw_lock)
#define INVALID_RECURSION(func, arg, type_name) G_STMT_START{ \
static const gchar *_action = " invalidly modified type "; \
- gpointer _arg = (gpointer) (arg); gchar *_tname = (type_name), *_fname = (func); \
+ gpointer _arg = (gpointer) (arg); const gchar *_tname = (type_name), *_fname = (func); \
if (_arg) \
g_error ("%s(%p)%s`%s'", _fname, _arg, _action, _tname); \
else \
@@ -145,7 +145,7 @@ struct _TypeNode
#define MAX_N_IFACES (511)
#define NODE_TYPE(node) (node->supers[0])
#define NODE_PARENT_TYPE(node) (node->supers[1])
-#define NODE_NAME(node) (g_quark_to_string (node->qname))
+#define NODE_NAME(node) ((gchar*)g_quark_to_string (node->qname))
struct _IFaceHolder
{
@@ -431,13 +431,13 @@ type_descriptive_name_L (GType type)
static inline gchar*
type_descriptive_name_U (GType type)
{
- gchar *name;
+ const gchar *name;
G_READ_LOCK (&type_rw_lock);
name = type_descriptive_name_L (type);
G_READ_UNLOCK (&type_rw_lock);
- return name;
+ return (gchar *)name;
}
@@ -1816,7 +1816,7 @@ g_type_value_table_peek (GType type)
return vtable;
}
-gchar*
+G_CONST_RETURN gchar*
g_type_name (GType type)
{
TypeNode *node;
@@ -2409,7 +2409,7 @@ g_type_init (GTypeDebugFlags debug_flags)
{
G_LOCK_DEFINE_STATIC (type_init_lock);
static TypeNode *type0_node = NULL;
- gchar *env_string;
+ const gchar *env_string;
GTypeInfo info;
TypeNode *node;
GType type;
diff --git a/gobject/gtype.h b/gobject/gtype.h
index b0a0c503d..d3604e398 100644
--- a/gobject/gtype.h
+++ b/gobject/gtype.h
@@ -179,34 +179,36 @@ typedef enum /*< skip >*/
/* --- prototypes --- */
-void g_type_init (GTypeDebugFlags debug_flags);
-gchar* g_type_name (GType type);
-GQuark g_type_qname (GType type);
-GType g_type_from_name (const gchar *name);
-GType g_type_parent (GType type);
-GType g_type_next_base (GType type,
- GType base_type);
-gboolean g_type_is_a (GType type,
- GType is_a_type);
-guint g_type_fundamental_branch_last (GType type);
-gpointer g_type_class_ref (GType type);
-gpointer g_type_class_peek (GType type);
-void g_type_class_unref (gpointer g_class);
-gpointer g_type_class_peek_parent (gpointer g_class);
-gpointer g_type_interface_peek (gpointer instance_class,
- GType iface_type);
+void g_type_init (GTypeDebugFlags debug_flags);
+G_CONST_RETURN gchar* g_type_name (GType type);
+GQuark g_type_qname (GType type);
+GType g_type_from_name (const gchar *name);
+GType g_type_parent (GType type);
+GType g_type_next_base (GType type,
+ GType base_type);
+gboolean g_type_is_a (GType type,
+ GType is_a_type);
+guint g_type_fundamental_branch_last (GType type);
+gpointer g_type_class_ref (GType type);
+gpointer g_type_class_peek (GType type);
+void g_type_class_unref (gpointer g_class);
+gpointer g_type_class_peek_parent (gpointer g_class);
+gpointer g_type_interface_peek (gpointer instance_class,
+ GType iface_type);
+
/* g_free() the returned arrays */
-GType* g_type_children (GType type,
- guint *n_children);
-GType* g_type_interfaces (GType type,
- guint *n_interfaces);
+GType* g_type_children (GType type,
+ guint *n_children);
+GType* g_type_interfaces (GType type,
+ guint *n_interfaces);
+
/* per-type _static_ data */
-void g_type_set_qdata (GType type,
- GQuark quark,
- gpointer data);
-gpointer g_type_get_qdata (GType type,
- GQuark quark);
-
+void g_type_set_qdata (GType type,
+ GQuark quark,
+ gpointer data);
+gpointer g_type_get_qdata (GType type,
+ GQuark quark);
+
/* --- type registration --- */
typedef void (*GBaseInitFunc) (gpointer g_class);
diff --git a/gobject/gvaluetypes.c b/gobject/gvaluetypes.c
index 42193b2f6..1e8ae92cd 100644
--- a/gobject/gvaluetypes.c
+++ b/gobject/gvaluetypes.c
@@ -735,7 +735,7 @@ g_value_set_static_string (GValue *value,
value->data[0].v_pointer = (gchar*) v_string;
}
-gchar*
+G_CONST_RETURN gchar*
g_value_get_string (const GValue *value)
{
g_return_val_if_fail (G_IS_VALUE_STRING (value), NULL);
diff --git a/gobject/gvaluetypes.h b/gobject/gvaluetypes.h
index a7405cc78..5cf5b8865 100644
--- a/gobject/gvaluetypes.h
+++ b/gobject/gvaluetypes.h
@@ -46,51 +46,48 @@ extern "C" {
/* --- prototypes --- */
-void g_value_set_char (GValue *value,
- gint8 v_char);
-gint8 g_value_get_char (const GValue *value);
-void g_value_set_uchar (GValue *value,
- guint8 v_uchar);
-guint8 g_value_get_uchar (const GValue *value);
-void g_value_set_boolean (GValue *value,
- gboolean v_boolean);
-gboolean g_value_get_boolean (const GValue *value);
-void g_value_set_int (GValue *value,
- gint v_int);
-gint g_value_get_int (const GValue *value);
-void g_value_set_uint (GValue *value,
- guint v_uint);
-guint g_value_get_uint (const GValue *value);
-void g_value_set_long (GValue *value,
- glong v_long);
-glong g_value_get_long (const GValue *value);
-void g_value_set_ulong (GValue *value,
- gulong v_ulong);
-gulong g_value_get_ulong (const GValue *value);
-void g_value_set_float (GValue *value,
- gfloat v_float);
-gfloat g_value_get_float (const GValue *value);
-void g_value_set_double (GValue *value,
- gdouble v_double);
-gdouble g_value_get_double (const GValue *value);
-void g_value_set_string (GValue *value,
- const gchar *v_string);
-void g_value_set_static_string (GValue *value,
- const gchar *v_string);
-gchar* g_value_get_string (const GValue *value);
-gchar* g_value_dup_string (const GValue *value);
-void g_value_set_pointer (GValue *value,
- gpointer v_pointer);
-gpointer g_value_get_pointer (const GValue *value);
-void g_value_set_ccallback (GValue *value,
- gpointer callback_func,
- gpointer callback_data);
-void g_value_get_ccallback (const GValue *value,
- gpointer *callback_func,
- gpointer *callback_data);
-
-
-
+void g_value_set_char (GValue *value,
+ gint8 v_char);
+gint8 g_value_get_char (const GValue *value);
+void g_value_set_uchar (GValue *value,
+ guint8 v_uchar);
+guint8 g_value_get_uchar (const GValue *value);
+void g_value_set_boolean (GValue *value,
+ gboolean v_boolean);
+gboolean g_value_get_boolean (const GValue *value);
+void g_value_set_int (GValue *value,
+ gint v_int);
+gint g_value_get_int (const GValue *value);
+void g_value_set_uint (GValue *value,
+ guint v_uint);
+guint g_value_get_uint (const GValue *value);
+void g_value_set_long (GValue *value,
+ glong v_long);
+glong g_value_get_long (const GValue *value);
+void g_value_set_ulong (GValue *value,
+ gulong v_ulong);
+gulong g_value_get_ulong (const GValue *value);
+void g_value_set_float (GValue *value,
+ gfloat v_float);
+gfloat g_value_get_float (const GValue *value);
+void g_value_set_double (GValue *value,
+ gdouble v_double);
+gdouble g_value_get_double (const GValue *value);
+void g_value_set_string (GValue *value,
+ const gchar *v_string);
+void g_value_set_static_string (GValue *value,
+ const gchar *v_string);
+G_CONST_RETURN gchar* g_value_get_string (const GValue *value);
+gchar* g_value_dup_string (const GValue *value);
+void g_value_set_pointer (GValue *value,
+ gpointer v_pointer);
+gpointer g_value_get_pointer (const GValue *value);
+void g_value_set_ccallback (GValue *value,
+ gpointer callback_func,
+ gpointer callback_data);
+void g_value_get_ccallback (const GValue *value,
+ gpointer *callback_func,
+ gpointer *callback_data);
#ifdef __cplusplus
}
diff --git a/gquark.h b/gquark.h
index 08dd9e4d4..e8756ef61 100644
--- a/gquark.h
+++ b/gquark.h
@@ -35,10 +35,10 @@ typedef guint32 GQuark;
/* Quarks (string<->id association)
*/
-GQuark g_quark_try_string (const gchar *string);
-GQuark g_quark_from_static_string (const gchar *string);
-GQuark g_quark_from_string (const gchar *string);
-gchar* g_quark_to_string (GQuark quark) G_GNUC_CONST;
+GQuark g_quark_try_string (const gchar *string);
+GQuark g_quark_from_static_string (const gchar *string);
+GQuark g_quark_from_string (const gchar *string);
+G_CONST_RETURN gchar* g_quark_to_string (GQuark quark) G_GNUC_CONST;
G_END_DECLS
diff --git a/gspawn.c b/gspawn.c
index fdb8752da..c8208f6ca 100644
--- a/gspawn.c
+++ b/gspawn.c
@@ -1288,7 +1288,8 @@ g_execute (const gchar *file,
else
{
gboolean got_eacces = 0;
- char *path, *p, *name, *freeme;
+ const gchar *path, *p;
+ gchar *name, *freeme;
size_t len;
size_t pathlen;
diff --git a/gstrfuncs.c b/gstrfuncs.c
index 619d20f13..cf9defb7c 100644
--- a/gstrfuncs.c
+++ b/gstrfuncs.c
@@ -226,7 +226,7 @@ g_strtod (const gchar *nptr,
}
}
-gchar*
+G_CONST_RETURN gchar*
g_strerror (gint errnum)
{
static GStaticPrivate msg_private = G_STATIC_PRIVATE_INIT;
@@ -669,7 +669,7 @@ g_strerror (gint errnum)
return msg;
}
-gchar*
+G_CONST_RETURN gchar*
g_strsignal (gint signum)
{
static GStaticPrivate msg_private = G_STATIC_PRIVATE_INIT;
diff --git a/gstrfuncs.h b/gstrfuncs.h
index 4d33272fc..11064c327 100644
--- a/gstrfuncs.h
+++ b/gstrfuncs.h
@@ -36,58 +36,58 @@ G_BEGIN_DECLS
* return a constant string that must not be freed.
*/
#define G_STR_DELIMITERS "_-|> <."
-gchar* g_strdelimit (gchar *string,
- const gchar *delimiters,
- gchar new_delimiter);
-gchar* g_strcanon (gchar *string,
- const gchar *valid_chars,
- gchar subsitutor);
-gdouble g_strtod (const gchar *nptr,
- gchar **endptr);
-gchar* g_strerror (gint errnum) G_GNUC_CONST;
-gchar* g_strsignal (gint signum) G_GNUC_CONST;
-gint g_strcasecmp (const gchar *s1,
- const gchar *s2);
-gint g_strncasecmp (const gchar *s1,
- const gchar *s2,
- guint n);
-gchar* g_strdown (gchar *string);
-gchar* g_strup (gchar *string);
-gchar* g_strreverse (gchar *string);
-gsize g_strlcpy (gchar *dest,
- const gchar *src,
- gsize dest_size);
-gsize g_strlcat (gchar *dest,
- const gchar *src,
- gsize dest_size);
+gchar* g_strdelimit (gchar *string,
+ const gchar *delimiters,
+ gchar new_delimiter);
+gchar* g_strcanon (gchar *string,
+ const gchar *valid_chars,
+ gchar subsitutor);
+gdouble g_strtod (const gchar *nptr,
+ gchar **endptr);
+G_CONST_RETURN gchar* g_strerror (gint errnum) G_GNUC_CONST;
+G_CONST_RETURN gchar* g_strsignal (gint signum) G_GNUC_CONST;
+gint g_strcasecmp (const gchar *s1,
+ const gchar *s2);
+gint g_strncasecmp (const gchar *s1,
+ const gchar *s2,
+ guint n);
+gchar* g_strdown (gchar *string);
+gchar* g_strup (gchar *string);
+gchar* g_strreverse (gchar *string);
+gsize g_strlcpy (gchar *dest,
+ const gchar *src,
+ gsize dest_size);
+gsize g_strlcat (gchar *dest,
+ const gchar *src,
+ gsize dest_size);
/* removes leading spaces */
-gchar* g_strchug (gchar *string);
+gchar* g_strchug (gchar *string);
/* removes trailing spaces */
-gchar* g_strchomp (gchar *string);
+gchar* g_strchomp (gchar *string);
/* removes leading & trailing spaces */
#define g_strstrip( string ) g_strchomp (g_strchug (string))
/* String utility functions that return a newly allocated string which
* ought to be freed with g_free from the caller at some point.
*/
-gchar* g_strdup (const gchar *str);
-gchar* g_strdup_printf (const gchar *format,
- ...) G_GNUC_PRINTF (1, 2);
-gchar* g_strdup_vprintf (const gchar *format,
- va_list args);
-gchar* g_strndup (const gchar *str,
- guint n);
-gchar* g_strnfill (guint length,
- gchar fill_char);
-gchar* g_strconcat (const gchar *string1,
- ...); /* NULL terminated */
-gchar* g_strjoin (const gchar *separator,
- ...); /* NULL terminated */
+gchar* g_strdup (const gchar *str);
+gchar* g_strdup_printf (const gchar *format,
+ ...) G_GNUC_PRINTF (1, 2);
+gchar* g_strdup_vprintf (const gchar *format,
+ va_list args);
+gchar* g_strndup (const gchar *str,
+ guint n);
+gchar* g_strnfill (guint length,
+ gchar fill_char);
+gchar* g_strconcat (const gchar *string1,
+ ...); /* NULL terminated */
+gchar* g_strjoin (const gchar *separator,
+ ...); /* NULL terminated */
/* Make a copy of a string interpreting C string -style escape
* sequences. Inverse of g_strescape. The recognized sequences are \b
* \f \n \r \t \\ \" and the octal format.
*/
-gchar* g_strcompress (const gchar *source);
+gchar* g_strcompress (const gchar *source);
/* Copy a string escaping nonprintable characters like in C strings.
* Inverse of g_strcompress. The exceptions parameter, if non-NULL, points
@@ -97,11 +97,11 @@ gchar* g_strcompress (const gchar *source);
* Luckily this function wasn't used much, using NULL as second parameter
* provides mostly identical semantics.
*/
-gchar* g_strescape (const gchar *source,
- const gchar *exceptions);
+gchar* g_strescape (const gchar *source,
+ const gchar *exceptions);
-gpointer g_memdup (gconstpointer mem,
- guint byte_size);
+gpointer g_memdup (gconstpointer mem,
+ guint byte_size);
/* NULL terminated string arrays.
* g_strsplit() splits up string into max_tokens tokens at delim and
@@ -111,13 +111,13 @@ gpointer g_memdup (gconstpointer mem,
* g_strfreev() frees the array itself and all of its strings.
* g_strdupv() copies a NULL-terminated array of strings
*/
-gchar** g_strsplit (const gchar *string,
- const gchar *delimiter,
- gint max_tokens);
-gchar* g_strjoinv (const gchar *separator,
- gchar **str_array);
-void g_strfreev (gchar **str_array);
-gchar** g_strdupv (gchar **str_array);
+gchar** g_strsplit (const gchar *string,
+ const gchar *delimiter,
+ gint max_tokens);
+gchar* g_strjoinv (const gchar *separator,
+ gchar **str_array);
+void g_strfreev (gchar **str_array);
+gchar** g_strdupv (gchar **str_array);
G_END_DECLS
diff --git a/gthread.c b/gthread.c
index aa3741236..dfa484630 100644
--- a/gthread.c
+++ b/gthread.c
@@ -46,6 +46,8 @@
#include <unistd.h>
#endif
+#include <string.h>
+
#if GLIB_SIZEOF_SYSTEM_THREAD == SIZEOF_VOID_P
# define g_system_thread_equal(thread1, thread2) \
(thread1.dummy_pointer == thread2.dummy_pointer)
diff --git a/gunicode.h b/gunicode.h
index db4800a63..2c43900af 100644
--- a/gunicode.h
+++ b/gunicode.h
@@ -180,30 +180,30 @@ GLIB_VAR char g_utf8_skip[256];
#define g_utf8_next_char(p) (char *)((p) + g_utf8_skip[*(guchar *)(p)])
gunichar g_utf8_get_char (const gchar *p);
-gchar * g_utf8_offset_to_pointer (const gchar *str,
- gint offset);
+gchar* g_utf8_offset_to_pointer (const gchar *str,
+ gint offset);
gint g_utf8_pointer_to_offset (const gchar *str,
const gchar *pos);
-gchar * g_utf8_prev_char (const gchar *p);
-gchar * g_utf8_find_next_char (const gchar *p,
+gchar* g_utf8_prev_char (const gchar *p);
+gchar* g_utf8_find_next_char (const gchar *p,
const gchar *end);
-gchar * g_utf8_find_prev_char (const gchar *str,
+gchar* g_utf8_find_prev_char (const gchar *str,
const gchar *p);
gint g_utf8_strlen (const gchar *p,
gint max);
/* Copies n characters from src to dest */
-gchar *g_utf8_strncpy (gchar *dest,
+gchar* g_utf8_strncpy (gchar *dest,
const gchar *src,
size_t n);
/* Find the UTF-8 character corresponding to ch, in string p. These
functions are equivalants to strchr and strrchr */
-gchar *g_utf8_strchr (const gchar *p,
+gchar* g_utf8_strchr (const gchar *p,
gunichar c);
-gchar *g_utf8_strrchr (const gchar *p,
+gchar* g_utf8_strrchr (const gchar *p,
gunichar c);
gunichar2 *g_utf8_to_utf16 (const gchar *str,
@@ -224,7 +224,7 @@ gunichar * g_utf16_to_ucs4 (const gunichar2 *str,
gint *items_read,
gint *items_written,
GError **error);
-gchar * g_utf16_to_utf8 (const gunichar2 *str,
+gchar* g_utf16_to_utf8 (const gunichar2 *str,
gint len,
gint *items_read,
gint *items_written,
@@ -234,7 +234,7 @@ gunichar2 *g_ucs4_to_utf16 (const gunichar *str,
gint *items_read,
gint *items_written,
GError **error);
-gchar * g_ucs4_to_utf8 (const gunichar *str,
+gchar* g_ucs4_to_utf8 (const gunichar *str,
gint len,
gint *items_read,
gint *items_written,
diff --git a/gutils.c b/gutils.c
index 61cdcf520..456be3450 100644
--- a/gutils.c
+++ b/gutils.c
@@ -111,7 +111,7 @@ void
g_atexit (GVoidFunc func)
{
gint result;
- gchar *error = NULL;
+ const gchar *error = NULL;
/* keep this in sync with glib.h */
@@ -171,7 +171,8 @@ my_strchrnul (const gchar *str, gchar c)
gchar*
g_find_program_in_path (const gchar *program)
{
- gchar *path, *p, *name, *freeme;
+ const gchar *path, *p;
+ gchar *name, *freeme;
size_t len;
size_t pathlen;
@@ -373,7 +374,7 @@ g_parse_debug_string (const gchar *string,
return result;
}
-gchar*
+G_CONST_RETURN gchar*
g_basename (const gchar *file_name)
{
register gchar *base;
@@ -465,8 +466,8 @@ g_path_is_absolute (const gchar *file_name)
return FALSE;
}
-gchar*
-g_path_skip_root (gchar *file_name)
+G_CONST_RETURN gchar*
+g_path_skip_root (const gchar *file_name)
{
g_return_val_if_fail (file_name != NULL, NULL);
@@ -490,7 +491,7 @@ g_path_skip_root (gchar *file_name)
if (file_name[0] == G_DIR_SEPARATOR)
file_name++;
- return file_name;
+ return (gchar *)file_name;
}
}
#endif
@@ -500,13 +501,13 @@ g_path_skip_root (gchar *file_name)
{
while (file_name[0] == G_DIR_SEPARATOR)
file_name++;
- return file_name;
+ return (gchar *)file_name;
}
#ifdef G_OS_WIN32
/* Skip X:\ */
if (isalpha (file_name[0]) && file_name[1] == ':' && file_name[2] == G_DIR_SEPARATOR)
- return file_name + 3;
+ return (gchar *)file_name + 3;
#endif
return NULL;
@@ -597,7 +598,7 @@ g_get_current_dir (void)
return dir;
}
-gchar*
+G_CONST_RETURN gchar*
g_getenv (const gchar *variable)
{
#ifndef G_OS_WIN32
@@ -864,7 +865,7 @@ g_get_any_init (void)
}
}
-gchar*
+G_CONST_RETURN gchar*
g_get_user_name (void)
{
G_LOCK (g_utils_global);
@@ -875,7 +876,7 @@ g_get_user_name (void)
return g_user_name;
}
-gchar*
+G_CONST_RETURN gchar*
g_get_real_name (void)
{
G_LOCK (g_utils_global);
@@ -892,7 +893,7 @@ g_get_real_name (void)
* deduced, return NULL.
*/
-gchar*
+G_CONST_RETURN gchar*
g_get_home_dir (void)
{
G_LOCK (g_utils_global);
@@ -910,7 +911,7 @@ g_get_home_dir (void)
* and C:\ on Windows.
*/
-gchar*
+G_CONST_RETURN gchar*
g_get_tmp_dir (void)
{
G_LOCK (g_utils_global);
@@ -1014,7 +1015,7 @@ g_get_codeset (void)
#endif /* G_OS_WIN32 */
-gchar *
+G_CONST_RETURN gchar *
_glib_gettext (const gchar *str)
{
gboolean _glib_gettext_initialized = FALSE;
diff --git a/gutils.h b/gutils.h
index 523af02c7..2da2048a1 100644
--- a/gutils.h
+++ b/gutils.h
@@ -113,12 +113,12 @@ G_BEGIN_DECLS
/* Retrive static string info
*/
-gchar* g_get_user_name (void);
-gchar* g_get_real_name (void);
-gchar* g_get_home_dir (void);
-gchar* g_get_tmp_dir (void);
-gchar* g_get_prgname (void);
-void g_set_prgname (const gchar *prgname);
+G_CONST_RETURN gchar* g_get_user_name (void);
+G_CONST_RETURN gchar* g_get_real_name (void);
+G_CONST_RETURN gchar* g_get_home_dir (void);
+G_CONST_RETURN gchar* g_get_tmp_dir (void);
+gchar* g_get_prgname (void);
+void g_set_prgname (const gchar *prgname);
typedef struct _GDebugKey GDebugKey;
@@ -130,40 +130,42 @@ struct _GDebugKey
/* Miscellaneous utility functions
*/
-guint g_parse_debug_string (const gchar *string,
- GDebugKey *keys,
- guint nkeys);
-gint g_snprintf (gchar *string,
- gulong n,
- gchar const *format,
- ...) G_GNUC_PRINTF (3, 4);
-gint g_vsnprintf (gchar *string,
- gulong n,
- gchar const *format,
- va_list args);
+guint g_parse_debug_string (const gchar *string,
+ GDebugKey *keys,
+ guint nkeys);
+gint g_snprintf (gchar *string,
+ gulong n,
+ gchar const *format,
+ ...) G_GNUC_PRINTF (3, 4);
+gint g_vsnprintf (gchar *string,
+ gulong n,
+ gchar const *format,
+ va_list args);
+
/* Check if a file name is an absolute path */
-gboolean g_path_is_absolute (const gchar *file_name);
+gboolean g_path_is_absolute (const gchar *file_name);
+
/* In case of absolute paths, skip the root part */
-gchar* g_path_skip_root (gchar *file_name);
+G_CONST_RETURN gchar* g_path_skip_root (const gchar *file_name);
/* These two functions are deprecated and will be removed in the next
* major release of GLib. Use g_path_get_dirname/g_path_get_basename
* instead. Whatch out! The string returned by g_path_get_basename
* must be g_freed, while the string returned by g_basename must not.*/
-gchar* g_basename (const gchar *file_name);
-gchar* g_dirname (const gchar *file_name);
+G_CONST_RETURN gchar* g_basename (const gchar *file_name);
+gchar* g_dirname (const gchar *file_name);
/* The returned strings are newly allocated with g_malloc() */
-gchar* g_get_current_dir (void);
-gchar* g_path_get_basename (const gchar *file_name);
-gchar* g_path_get_dirname (const gchar *file_name);
+gchar* g_get_current_dir (void);
+gchar* g_path_get_basename (const gchar *file_name);
+gchar* g_path_get_dirname (const gchar *file_name);
/* Get the codeset for the current locale */
/* gchar * g_get_codeset (void); */
/* return the environment string for the variable. The returned memory
* must not be freed. */
-gchar* g_getenv (const gchar *variable);
+G_CONST_RETURN gchar* g_getenv (const gchar *variable);
/* we try to provide a usefull equivalent for ATEXIT if it is
diff --git a/gwin32.h b/gwin32.h
index b30ab1587..3168e08b9 100644
--- a/gwin32.h
+++ b/gwin32.h
@@ -102,18 +102,18 @@ gint g_win32_closedir (DIR *dir);
* returns it as a string of the above form for use in forming file
* names etc. The returned string should be deallocated with g_free().
*/
-gchar * g_win32_getlocale (void);
+gchar* g_win32_getlocale (void);
/* Translate a Win32 error code (as returned by GetLastError()) into
* the corresponding message. The returned string should be deallocated
* with g_free().
*/
-gchar * g_win32_error_message (gint error);
+gchar* g_win32_error_message (gint error);
-gchar * g_win32_get_package_installation_directory (gchar *package,
+gchar* g_win32_get_package_installation_directory (gchar *package,
gchar *dll_name);
-gchar * g_win32_get_package_installation_subdirectory (gchar *package,
+gchar* g_win32_get_package_installation_subdirectory (gchar *package,
gchar *dll_name,
gchar *subdir);
diff --git a/testglib.c b/testglib.c
index 7cbd93971..35ca81462 100644
--- a/testglib.c
+++ b/testglib.c
@@ -445,7 +445,7 @@ main (int argc,
g_print ("checking g_path_skip_root()...");
for (i = 0; i < n_skip_root_checks; i++)
{
- gchar *skipped;
+ const gchar *skipped;
skipped = g_path_skip_root (skip_root_checks[i].filename);
if ((skipped && !skip_root_checks[i].without_root) ||
diff --git a/tests/testglib.c b/tests/testglib.c
index 7cbd93971..35ca81462 100644
--- a/tests/testglib.c
+++ b/tests/testglib.c
@@ -445,7 +445,7 @@ main (int argc,
g_print ("checking g_path_skip_root()...");
for (i = 0; i < n_skip_root_checks; i++)
{
- gchar *skipped;
+ const gchar *skipped;
skipped = g_path_skip_root (skip_root_checks[i].filename);
if ((skipped && !skip_root_checks[i].without_root) ||