[PATCH 5/8] call virReportOOMError when appropriate in hash.c

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

 



---
 src/util/hash.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/util/hash.c b/src/util/hash.c
index 031e5af..f19d249 100644
--- a/src/util/hash.c
+++ b/src/util/hash.c
@@ -28,6 +28,8 @@
 #include "hash.h"
 #include "memory.h"
 
+#define VIR_FROM_THIS VIR_FROM_NONE
+
 #define MAX_HASH_LEN 8
 
 /* #define DEBUG_GROW */
@@ -89,12 +91,15 @@ virHashCreate(int size)
     if (size <= 0)
         size = 256;
 
-    if (VIR_ALLOC(table) < 0)
+    if (VIR_ALLOC(table) < 0) {
+        virReportOOMError();
         return NULL;
+    }
 
     table->size = size;
     table->nbElems = 0;
     if (VIR_ALLOC_N(table->table, size) < 0) {
+        virReportOOMError();
         VIR_FREE(table);
         return NULL;
     }
@@ -136,6 +141,7 @@ virHashGrow(virHashTablePtr table, int size)
         return (-1);
 
     if (VIR_ALLOC_N(table->table, size) < 0) {
+        virReportOOMError();
         table->table = oldtable;
         return (-1);
     }
@@ -286,12 +292,15 @@ virHashAddOrUpdateEntry(virHashTablePtr table, const char *name,
     if (insert == NULL) {
         entry = &(table->table[key]);
     } else {
-        if (VIR_ALLOC(entry) < 0)
+        if (VIR_ALLOC(entry) < 0) {
+            virReportOOMError();
             return (-1);
+        }
     }
 
     new_name = strdup(name);
     if (new_name == NULL) {
+        virReportOOMError();
         if (insert != NULL)
             VIR_FREE(entry);
         return (-1);
-- 
1.7.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]