On Mon, Sep 26, 2016 at 08:18:30 -0400, John Ferlan wrote:
In subject: Static is not the same as stack allocated.
Rather than use static/stack state context pointers, let's
allocate and
same here.
free the state context pointer. In doing so, we'll shrink the
code a bit
since many routines perform the same initialization sequence.
Fair point in removing duplicity, but you did not justify the change
from stack allocated to heap allocated, just explained it.
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
src/storage/storage_backend_rbd.c | 136 +++++++++++++++++++-------------------
1 file changed, 69 insertions(+), 67 deletions(-)
diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backend_rbd.c
index 4e82232..37375c0 100644
--- a/src/storage/storage_backend_rbd.c
+++ b/src/storage/storage_backend_rbd.c
@@ -224,6 +224,42 @@ virStorageBackendRBDCloseRADOSConn(virStorageBackendRBDStatePtr
ptr)
time(0) - ptr->starttime);
}
+
+static void
+virStorageBackendRBDFreeStateContext(virStorageBackendRBDStatePtr *ptr)
The word "Context" seems a bit unnecessary in the name.
+{
+ if (!*ptr)
+ return;
+
+ virStorageBackendRBDCloseRADOSConn(*ptr);
+
+ VIR_FREE(*ptr);
+}
+
+
+static virStorageBackendRBDStatePtr
+virStorageBackendRBDAllocStateContext(virConnectPtr conn,
+ virStoragePoolObjPtr pool)
Same here. Also I think we prefer the word "New" instead of "Alloc"
+{
+ virStorageBackendRBDStatePtr ptr;
+
+ if (VIR_ALLOC(ptr) < 0)
+ return NULL;
ACK