Allocate GErrors using the slice allocator. (#354054, Matt Barnes)
[platform/upstream/glib.git] / glib / gerror.c
index 664aa24..0b0f982 100644 (file)
  * GLib at ftp://ftp.gtk.org/pub/gtk/. 
  */
 
+#include "config.h"
+
 #include "glib.h"
+#include "galias.h"
+
 
 static GError* 
-g_error_new_valist(GQuark         domain,
-                   gint           code,
-                   const gchar   *format,
-                   va_list        args)
+g_error_new_valist (GQuark         domain,
+                    gint           code,
+                    const gchar   *format,
+                    va_list        args)
 {
   GError *error;
   
-  error = g_new (GError, 1);
+  error = g_slice_new (GError);
   
   error->domain = domain;
   error->code = code;
@@ -47,7 +51,7 @@ g_error_new_valist(GQuark         domain,
  * g_error_new:
  * @domain: error domain 
  * @code: error code
- * @format: <function>printf()</function>-style format for error message
+ * @format: printf()-style format for error message
  * @Varargs: parameters for message format
  * 
  * Creates a new #GError with the given @domain and @code,
@@ -81,9 +85,9 @@ g_error_new (GQuark       domain,
  * @message: error message
  * 
  * Creates a new #GError; unlike g_error_new(), @message is not
- * a <function>printf()</function>-style format string. Use this 
+ * a printf()-style format string. Use this 
  * function if @message contains text you don't have control over, 
- * that could include <function>printf()</function> escape sequences.
+ * that could include printf() escape sequences.
  * 
  * Return value: a new #GError
  **/
@@ -97,7 +101,7 @@ g_error_new_literal (GQuark         domain,
   g_return_val_if_fail (message != NULL, NULL);
   g_return_val_if_fail (domain != 0, NULL);
 
-  err = g_new (GError, 1);
+  err = g_slice_new (GError);
 
   err->domain = domain;
   err->code = code;
@@ -120,7 +124,7 @@ g_error_free (GError *error)
 
   g_free (error->message);
 
-  g_free (error);
+  g_slice_free (GError, error);
 }
 
 /**
@@ -138,7 +142,7 @@ g_error_copy (const GError *error)
   
   g_return_val_if_fail (error != NULL, NULL);
 
-  copy = g_new (GError, 1);
+  copy = g_slice_new (GError);
 
   *copy = *error;
 
@@ -177,7 +181,7 @@ g_error_matches (const GError *error,
  * @err: a return location for a #GError, or %NULL
  * @domain: error domain
  * @code: error code 
- * @format: <function>printf()</function>-style format
+ * @format: printf()-style format
  * @Varargs: args for @format 
  * 
  * Does nothing if @err is %NULL; if @err is non-%NULL, then *@err must
@@ -252,3 +256,6 @@ g_clear_error (GError **err)
       *err = NULL;
     }
 }
+
+#define __G_ERROR_C__
+#include "galiasdef.c"