]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Stop calling virAllocN directly from ESX code
authorDaniel P. Berrange <berrange@redhat.com>
Tue, 3 Sep 2013 15:22:48 +0000 (16:22 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Thu, 5 Sep 2013 11:00:07 +0000 (12:00 +0100)
The ESX code has a method esxVI_Alloc which would call
virAllocN directly, instead of using the VIR_ALLOC_N
macro. Remove this method and make the callers just
use VIR_ALLOC as is normal practice.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
src/esx/esx_vi.c
src/esx/esx_vi.h
src/esx/esx_vi_types.c

index ad1b5dc50e8c72a13572d7d2adead0628d91ca3d..7bc8b60a2a6680081d59a12ca3aa19ce05d7d26d 100644 (file)
     int                                                                       \
     esxVI_##_type##_Alloc(esxVI_##_type **ptrptr)                             \
     {                                                                         \
-        return esxVI_Alloc((void **)ptrptr, sizeof(esxVI_##_type),            \
-                           __FILE__, __FUNCTION__, __LINE__);                 \
+        if (ptrptr == NULL || *ptrptr != NULL) {                              \
+            virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")); \
+            return -1;                                                  \
+        }                                                               \
+                                                                        \
+        if (VIR_ALLOC(*ptrptr) < 0)                                     \
+            return -1;                                                  \
+        return 0;                                                       \
     }
 
 
@@ -1735,21 +1741,6 @@ esxVI_List_Deserialize(xmlNodePtr node, esxVI_List **list,
  *  - 'get' functions get information from a local object
  */
 
-int
-esxVI_Alloc(void **ptrptr, size_t size, const char *file,
-            const char *function, size_t linenr)
-{
-    if (ptrptr == NULL || *ptrptr != NULL) {
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
-        return -1;
-    }
-
-    return virAllocN(ptrptr, size, 1, true, VIR_FROM_THIS,
-                     file, function, linenr);
-}
-
-
-
 int
 esxVI_BuildSelectSet(esxVI_SelectionSpec **selectSet,
                      const char *name, const char *type,
index c1612e25d155d56f2eefdfcf80b7ad4aafc8600b..aeee953aa7621d3df2dedf93e0d8b47deb72c98c 100644 (file)
@@ -330,9 +330,6 @@ int esxVI_List_Deserialize(xmlNodePtr node, esxVI_List **list,
  *  - 'get' functions get information from a local object
  */
 
-int esxVI_Alloc(void **ptrptr, size_t size, const char *file,
-                const char *function, size_t linenr);
-
 int esxVI_BuildSelectSet
       (esxVI_SelectionSpec **selectSet, const char *name,
        const char *type, const char *path, const char *selectSetNames);
index 14caeebb66a8f7199bc7c77d8f99d0bba45d9148..03df444dbc66e255e5f15bcaad035097af22ac02 100644 (file)
     int                                                                       \
     esxVI_##__type##_Alloc(esxVI_##__type **ptrptr)                           \
     {                                                                         \
-        if (esxVI_Alloc((void **)ptrptr, sizeof(esxVI_##__type),              \
-                        __FILE__, __FUNCTION__, __LINE__) < 0) {              \
-            return -1;                                                        \
-        }                                                                     \
+        if (ptrptr == NULL || *ptrptr != NULL) {                              \
+            virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")); \
+            return -1;                                                  \
+        }                                                               \
+                                                                        \
+        if (VIR_ALLOC(*ptrptr) < 0)                                     \
+            return -1;                                                  \
                                                                               \
         (*ptrptr)->_type = esxVI_Type_##__type;                               \
                                                                               \