]> xenbits.xensource.com Git - libvirt.git/commitdiff
introduce virSaveLastError(), virFreeError()
authorJohn Levon <john.levon@sun.com>
Mon, 9 Feb 2009 14:16:23 +0000 (14:16 +0000)
committerJohn Levon <john.levon@sun.com>
Mon, 9 Feb 2009 14:16:23 +0000 (14:16 +0000)
ChangeLog
include/libvirt/virterror.h
src/libvirt_public.syms
src/virterror.c

index 63c2b3b0ff5b7c2808e45890d4cdf4a926d2196e..917b1fd6f53481ea983ded4031610f8a1a8779ad 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Mon Feb  9 14:07:51 GMT 2009 John Levon <john.levon@sun.com>
+
+       * include/libvirt/virterror.h:
+       * src/libvirt_public.syms:
+       * src/virterror.c: introduce virSaveLastError(), virFreeError()
+
 Mon Feb  9 10:21:33 GMT 2009 Daniel P. Berrange <berrange@redhat.com>
 
        * src/virsh.c: Limit readonly history to 500 to avoid unbounded
index 0f1f08c49f17407258dd8a8f6c966d25e376d3eb..d68201f1d2f1eef385b49c9fa5840d808c65973e 100644 (file)
@@ -172,8 +172,10 @@ typedef void (*virErrorFunc) (void *userData, virErrorPtr error);
  */
 
 virErrorPtr            virGetLastError         (void);
+virErrorPtr            virSaveLastError        (void);
 void                   virResetLastError       (void);
 void                   virResetError           (virErrorPtr err);
+void                   virFreeError            (virErrorPtr err);
 
 virErrorPtr            virConnGetLastError     (virConnectPtr conn);
 void                   virConnResetLastError   (virConnectPtr conn);
index 0555c9074f73eed6c6ff3d43e455c4b4c4108b52..1422e4cea8616eacd48ac4b2c65540cb5b319f6d 100644 (file)
@@ -247,4 +247,10 @@ LIBVIRT_0.6.0 {
 
 } LIBVIRT_0.5.0;
 
+LIBVIRT_0.6.1 {
+    global:
+       virFreeError;
+       virSaveLastError;
+} LIBVIRT_0.6.0;
+
 # .... define new API here using predicted next version number ....
index 6c479f43d758a7bbc6b8f6792810fe54c66b56d9..42a7cf578be12836f6828ee316bfbc65f4049b40 100644 (file)
@@ -285,6 +285,27 @@ virCopyLastError(virErrorPtr to)
     return to->code;
 }
 
+/**
+ * virSaveLastError:
+ *
+ * Save the last error into a new error object.
+ *
+ * Returns a pointer to the copied error or NULL if allocation failed.
+ * It is the caller's responsibility to free the error with
+ * virFreeError().
+ */
+virErrorPtr
+virSaveLastError(void)
+{
+    virErrorPtr to;
+
+    if (VIR_ALLOC(to) < 0)
+        return NULL;
+
+    virCopyLastError(to);
+    return to;
+}
+
 /**
  * virResetError:
  * @err: pointer to the virError to clean up
@@ -303,6 +324,18 @@ virResetError(virErrorPtr err)
     memset(err, 0, sizeof(virError));
 }
 
+/**
+ * virFreeError:
+ * @err: error to free
+ *
+ * Resets and frees the given error.
+ */
+void
+virFreeError(virErrorPtr err)
+{
+    virResetError(err);
+    VIR_FREE(err);
+}
 
 /**
  * virResetLastError: