[tracker/tracker-0.8] TrackerXMP: Do not modify setlocale() return value, as it's statically stored.



commit 2047681b24096214094b0b742dd544d8f6fa5fd8
Author: Carlos Garnacho <carlosg gnome org>
Date:   Wed May 5 12:35:13 2010 +0200

    TrackerXMP: Do not modify setlocale() return value, as it's statically stored.
    
    Also, do not perform a setlocale(..., NULL) call on every iteration, instead store
    the resulting value, as that's more than unlikely to change on runtime.

 .../tmpl/tracker-sparql-builder.sgml               |    6 ++++
 src/libtracker-extract/tracker-xmp.c               |   29 +++++++++++++-------
 2 files changed, 25 insertions(+), 10 deletions(-)
---
diff --git a/docs/reference/libtracker-client/tmpl/tracker-sparql-builder.sgml b/docs/reference/libtracker-client/tmpl/tracker-sparql-builder.sgml
index cd0b334..0df9974 100644
--- a/docs/reference/libtracker-client/tmpl/tracker-sparql-builder.sgml
+++ b/docs/reference/libtracker-client/tmpl/tracker-sparql-builder.sgml
@@ -55,6 +55,9 @@ for the same subject, and several objects for the same predicate.
 <!-- ##### SECTION Stability_Level ##### -->
 
 
+<!-- ##### SECTION Image ##### -->
+
+
 <!-- ##### STRUCT TrackerSparqlBuilder ##### -->
 <para>
 The <structname>TrackerSparqlBuilder</structname> object represents an
@@ -97,6 +100,7 @@ insertion/update SparQL query.
 Creates a stateless #TrackerSparqlBuilder.
 </para>
 
+ void: 
 @Returns: a newly created #TrackerSparqlBuilder. Free with g_object_unref() when done
 
 
@@ -107,6 +111,7 @@ inserts, the subject is implied (responsibility of the embedder), so only calls
 append predicates and objects for the given subject are allowed.
 </para>
 
+ void: 
 @Returns: a newly created #TrackerSparqlBuilder. Free with g_object_unref() when done
 
 
@@ -115,6 +120,7 @@ append predicates and objects for the given subject are allowed.
 Creates an empty #TrackerSparqlBuilder for an update query.
 </para>
 
+ void: 
 @Returns: a newly created #TrackerSparqlBuilder. Free with g_object_unref() when done
 
 
diff --git a/src/libtracker-extract/tracker-xmp.c b/src/libtracker-extract/tracker-xmp.c
index dfa119d..8fa2774 100644
--- a/src/libtracker-extract/tracker-xmp.c
+++ b/src/libtracker-extract/tracker-xmp.c
@@ -165,8 +165,7 @@ iterate_simple_qual (XmpPtr          xmp,
 	XmpIteratorPtr iter;
 	XmpStringPtr the_path;
 	XmpStringPtr the_prop;
-	gchar *locale;
-	gchar *sep;
+	static gchar *locale = NULL;
 	gboolean ignore_element = FALSE;
 
 	iter = xmp_iterator_new (xmp, schema, path, XMP_ITER_JUSTCHILDREN | XMP_ITER_JUSTLEAFNAME);
@@ -174,16 +173,26 @@ iterate_simple_qual (XmpPtr          xmp,
 	the_path = xmp_string_new ();
 	the_prop = xmp_string_new ();
 
-	locale = setlocale (LC_ALL, NULL);
-	sep = strchr (locale,'.');
+	if (G_UNLIKELY (!locale)) {
+		locale = g_strdup (setlocale (LC_ALL, NULL));
 
-	if (sep) {
-		locale[sep - locale] = '\0';
-	}
+		if (!locale) {
+			locale = g_strdup ("C");
+		} else {
+			gchar *sep;
+
+			sep = strchr (locale, '.');
+
+			if (sep) {
+				locale[sep - locale] = '\0';
+			}
 
-	sep = strchr (locale, '_');
-	if (sep) {
-		locale[sep - locale] = '-';
+			sep = strchr (locale, '_');
+
+			if (sep) {
+				locale[sep - locale] = '-';
+			}
+		}
 	}
 
 	while (xmp_iterator_next (iter, NULL, the_path, the_prop, NULL)) {



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