[glib/wip/resources] resource: Use const char* for the path in public API



commit 3eb93c0f1843e909de36a94fd011a8bb3dae1897
Author: Christian Persch <chpe gnome org>
Date:   Wed Jan 11 13:40:06 2012 +0100

    resource: Use const char* for the path in public API

 gio/gresource.c |   28 +++++++++++++---------------
 gio/gresource.h |   16 ++++++++--------
 2 files changed, 21 insertions(+), 23 deletions(-)
---
diff --git a/gio/gresource.c b/gio/gresource.c
index bba118e..bc11565 100644
--- a/gio/gresource.c
+++ b/gio/gresource.c
@@ -153,7 +153,7 @@ g_resource_load (const gchar *filename,
 }
 
 static gboolean do_lookup (GResource *resource,
-			   char *path,
+			   const char *path,
 			   GResourceLookupFlags lookup_flags,
 			   gsize *size,
 			   guint32 *flags,
@@ -161,7 +161,7 @@ static gboolean do_lookup (GResource *resource,
 			   gsize *data_size,
 			   GError **error)
 {
-  gboolean free_path = FALSE;
+  char *free_path = NULL;
   gsize path_len;
   gboolean res = FALSE;
   GVariant *value;
@@ -169,9 +169,8 @@ static gboolean do_lookup (GResource *resource,
   path_len = strlen (path);
   if (path[path_len-1] == '/')
     {
-      free_path = TRUE;
-      path = g_strdup (path);
-      path[path_len-1] = 0;
+      path = free_path = g_strdup (path);
+      free_path[path_len-1] = 0;
     }
 
   value = gvdb_table_get_value (resource->table, path);
@@ -234,14 +233,13 @@ static gboolean do_lookup (GResource *resource,
 	}
     }
 
-  if (free_path)
-    g_free (path);
+  g_free (free_path);
   return res;
 }
 
 GInputStream *
 g_resource_open_stream (GResource *resource,
-			char *path,
+			const char *path,
 			GResourceLookupFlags lookup_flags,
 			GError **error)
 {
@@ -274,7 +272,7 @@ g_resource_open_stream (GResource *resource,
 
 GBytes *
 g_resource_lookup_data (GResource *resource,
-			char *path,
+			const char *path,
 			GResourceLookupFlags lookup_flags,
 			GError **error)
 {
@@ -340,7 +338,7 @@ g_resource_lookup_data (GResource *resource,
 
 gboolean
 g_resource_get_info (GResource *resource,
-		     char *path,
+		     const char *path,
 		     GResourceLookupFlags lookup_flags,
 		     gsize *size,
 		     guint32 *flags,
@@ -351,7 +349,7 @@ g_resource_get_info (GResource *resource,
 
 char **
 g_resource_enumerate_children (GResource *resource,
-			       char *path,
+			       const char *path,
 			       GResourceLookupFlags lookup_flags,
 			       GError **error)
 {
@@ -420,7 +418,7 @@ g_resources_unregister (GResource *resource)
 }
 
 GInputStream *
-g_resources_open_stream (char *path,
+g_resources_open_stream (const char *path,
 			 GResourceLookupFlags lookup_flags,
 			 GError **error)
 {
@@ -461,7 +459,7 @@ g_resources_open_stream (char *path,
 }
 
 GBytes *
-g_resources_lookup_data (char *path,
+g_resources_lookup_data (const char *path,
 			 GResourceLookupFlags lookup_flags,
 			 GError **error)
 {
@@ -502,7 +500,7 @@ g_resources_lookup_data (char *path,
 }
 
 char **
-g_resources_enumerate_children (char *path,
+g_resources_enumerate_children (const char *path,
 				GResourceLookupFlags lookup_flags,
 				GError **error)
 {
@@ -560,7 +558,7 @@ g_resources_enumerate_children (char *path,
 }
 
 gboolean
-g_resources_get_info (char         *path,
+g_resources_get_info (const char   *path,
 		      GResourceLookupFlags lookup_flags,
 		      gsize        *size,
 		      guint32      *flags,
diff --git a/gio/gresource.h b/gio/gresource.h
index 1717cc4..d063c02 100644
--- a/gio/gresource.h
+++ b/gio/gresource.h
@@ -50,19 +50,19 @@ void          g_resource_unref               (GResource             *resource);
 GResource *   g_resource_load                (const gchar           *filename,
 					      GError               **error);
 GInputStream *g_resource_open_stream         (GResource             *resource,
-					      char                  *path,
+					      const char            *path,
 					      GResourceLookupFlags   lookup_flags,
 					      GError               **error);
 GBytes *      g_resource_lookup_data         (GResource             *resource,
-					      char                  *path,
+					      const char            *path,
 					      GResourceLookupFlags   lookup_flags,
 					      GError               **error);
 char **       g_resource_enumerate_children  (GResource             *resource,
-					      char                  *path,
+					      const char            *path,
 					      GResourceLookupFlags   lookup_flags,
 					      GError               **error);
 gboolean      g_resource_get_info            (GResource             *resource,
-					      char                  *path,
+					      const char            *path,
 					      GResourceLookupFlags   lookup_flags,
 					      gsize                 *size,
 					      guint32               *flags,
@@ -72,16 +72,16 @@ void          g_resource_set_module          (GResource             *resource,
 
 void          g_resources_register           (GResource             *resource);
 void          g_resources_unregister         (GResource             *resource);
-GInputStream *g_resources_open_stream        (char                  *path,
+GInputStream *g_resources_open_stream        (const char            *path,
 					      GResourceLookupFlags   lookup_flags,
 					      GError               **error);
-GBytes *      g_resources_lookup_data        (char                  *path,
+GBytes *      g_resources_lookup_data        (const char            *path,
 					      GResourceLookupFlags   lookup_flags,
 					      GError               **error);
-char **       g_resources_enumerate_children (char                  *path,
+char **       g_resources_enumerate_children (const char            *path,
 					      GResourceLookupFlags   lookup_flags,
 					      GError               **error);
-gboolean      g_resources_get_info           (char                  *path,
+gboolean      g_resources_get_info           (const char            *path,
 					      GResourceLookupFlags   lookup_flags,
 					      gsize                 *size,
 					      guint32               *flags,



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