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

[Libvir] [PATCH] deep copy dom structure



---
 src/virterror.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/src/virterror.c b/src/virterror.c
index 1463129..49f3b89 100644
--- a/src/virterror.c
+++ b/src/virterror.c
@@ -115,6 +115,11 @@ virResetError(virErrorPtr err)
     free(err->str1);
     free(err->str2);
     free(err->str3);
+    if(err->dom) {
+        if(err->dom->name)
+            free(err->dom->name);
+        free(err->dom);
+    }
     memset(err, 0, sizeof(virError));
 }
 
@@ -383,6 +388,15 @@ __virRaiseError(virConnectPtr conn, virDomainPtr dom, virNetworkPtr net,
     virResetError(to);
     to->conn = conn;
     to->dom = dom;
+    if (dom) {
+        if (!(to->dom = malloc(sizeof(virDomain)))) {
+            fprintf(stderr, "cannot allocate memory in %s", __FUNCTION__);
+        } else {
+            to->dom->name = strdup(dom->name);
+            memcpy (to->dom->uuid, dom->uuid, VIR_UUID_BUFLEN);
+            to->dom->id = dom->id;
+        }
+    }
     to->net = net;
     to->domain = domain;
     to->code = code;
-- 
1.5.4.4


--45Z9DzgjV8m4Oswq--


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