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

[libvirt] [PATCH 15/28] Rename memory.{c,h} to viralloc.{c,h}



From: "Daniel P. Berrange" <berrange redhat com>

---
 cfg.mk                                    |   6 +-
 daemon/libvirtd-config.c                  |   2 +-
 daemon/libvirtd.c                         |   2 +-
 daemon/remote.c                           |   2 +-
 daemon/stream.c                           |   2 +-
 python/libvirt-override.c                 |   2 +-
 python/typewrappers.c                     |   2 +-
 src/Makefile.am                           |   2 +-
 src/conf/capabilities.c                   |   2 +-
 src/conf/cpu_conf.c                       |   2 +-
 src/conf/device_conf.c                    |   2 +-
 src/conf/domain_audit.c                   |   2 +-
 src/conf/domain_conf.c                    |   2 +-
 src/conf/domain_event.c                   |   2 +-
 src/conf/interface_conf.c                 |   2 +-
 src/conf/netdev_bandwidth_conf.c          |   2 +-
 src/conf/netdev_vlan_conf.c               |   2 +-
 src/conf/netdev_vport_profile_conf.c      |   2 +-
 src/conf/network_conf.c                   |   2 +-
 src/conf/node_device_conf.c               |   4 +-
 src/conf/nwfilter_conf.c                  |   2 +-
 src/conf/nwfilter_params.c                |   2 +-
 src/conf/secret_conf.c                    |   2 +-
 src/conf/snapshot_conf.c                  |   2 +-
 src/conf/storage_conf.c                   |   2 +-
 src/conf/storage_encryption_conf.c        |   2 +-
 src/conf/virconsole.c                     |   2 +-
 src/cpu/cpu.c                             |   2 +-
 src/cpu/cpu_arm.c                         |   2 +-
 src/cpu/cpu_generic.c                     |   2 +-
 src/cpu/cpu_map.c                         |   2 +-
 src/cpu/cpu_powerpc.c                     |   2 +-
 src/cpu/cpu_s390.c                        |   2 +-
 src/cpu/cpu_x86.c                         |   2 +-
 src/datatypes.c                           |   2 +-
 src/driver.c                              |   2 +-
 src/esx/esx_device_monitor.c              |   2 +-
 src/esx/esx_driver.c                      |   2 +-
 src/esx/esx_interface_driver.c            |   2 +-
 src/esx/esx_network_driver.c              |   2 +-
 src/esx/esx_nwfilter_driver.c             |   2 +-
 src/esx/esx_secret_driver.c               |   2 +-
 src/esx/esx_storage_backend_iscsi.c       |   2 +-
 src/esx/esx_storage_backend_vmfs.c        |   2 +-
 src/esx/esx_storage_driver.c              |   2 +-
 src/esx/esx_util.c                        |   2 +-
 src/esx/esx_vi.c                          |   2 +-
 src/esx/esx_vi_methods.c                  |   2 +-
 src/esx/esx_vi_types.c                    |   2 +-
 src/fdstream.c                            |   2 +-
 src/hyperv/hyperv_device_monitor.c        |   2 +-
 src/hyperv/hyperv_driver.c                |   2 +-
 src/hyperv/hyperv_interface_driver.c      |   2 +-
 src/hyperv/hyperv_network_driver.c        |   2 +-
 src/hyperv/hyperv_nwfilter_driver.c       |   2 +-
 src/hyperv/hyperv_secret_driver.c         |   2 +-
 src/hyperv/hyperv_storage_driver.c        |   2 +-
 src/hyperv/hyperv_util.c                  |   2 +-
 src/hyperv/hyperv_wmi.c                   |   2 +-
 src/interface/interface_backend_netcf.c   |   2 +-
 src/interface/interface_backend_udev.c    |   2 +-
 src/libvirt.c                             |   2 +-
 src/libxl/libxl_conf.c                    |   2 +-
 src/libxl/libxl_driver.c                  |   2 +-
 src/locking/domain_lock.c                 |   2 +-
 src/locking/lock_daemon.c                 |   2 +-
 src/locking/lock_daemon_config.c          |   2 +-
 src/locking/lock_driver_lockd.c           |   2 +-
 src/locking/lock_driver_nop.c             |   2 +-
 src/locking/lock_driver_sanlock.c         |   2 +-
 src/locking/lock_manager.c                |   2 +-
 src/locking/sanlock_helper.c              |   2 +-
 src/lxc/lxc_cgroup.c                      |   2 +-
 src/lxc/lxc_conf.c                        |   2 +-
 src/lxc/lxc_container.c                   |   2 +-
 src/lxc/lxc_controller.c                  |   2 +-
 src/lxc/lxc_domain.c                      |   2 +-
 src/lxc/lxc_driver.c                      |   2 +-
 src/lxc/lxc_fuse.h                        |   2 +-
 src/lxc/lxc_monitor.c                     |   2 +-
 src/lxc/lxc_process.c                     |   2 +-
 src/network/bridge_driver.c               |   2 +-
 src/node_device/node_device_driver.c      |   2 +-
 src/node_device/node_device_hal.c         |   2 +-
 src/node_device/node_device_linux_sysfs.c |   2 +-
 src/node_device/node_device_udev.c        |   2 +-
 src/nodeinfo.c                            |   2 +-
 src/nwfilter/nwfilter_dhcpsnoop.c         |   2 +-
 src/nwfilter/nwfilter_driver.c            |   2 +-
 src/nwfilter/nwfilter_ebiptables_driver.c |   2 +-
 src/nwfilter/nwfilter_gentech_driver.c    |   2 +-
 src/nwfilter/nwfilter_learnipaddr.c       |   2 +-
 src/openvz/openvz_conf.c                  |   2 +-
 src/openvz/openvz_driver.c                |   2 +-
 src/openvz/openvz_util.c                  |   2 +-
 src/parallels/parallels_driver.c          |   2 +-
 src/parallels/parallels_network.c         |   2 +-
 src/parallels/parallels_storage.c         |   2 +-
 src/parallels/parallels_utils.c           |   2 +-
 src/phyp/phyp_driver.c                    |   2 +-
 src/qemu/qemu_agent.c                     |   2 +-
 src/qemu/qemu_capabilities.c              |   2 +-
 src/qemu/qemu_cgroup.c                    |   2 +-
 src/qemu/qemu_command.c                   |   2 +-
 src/qemu/qemu_conf.c                      |   2 +-
 src/qemu/qemu_domain.c                    |   2 +-
 src/qemu/qemu_driver.c                    |   2 +-
 src/qemu/qemu_hostdev.c                   |   2 +-
 src/qemu/qemu_hotplug.c                   |   2 +-
 src/qemu/qemu_migration.c                 |   2 +-
 src/qemu/qemu_monitor.c                   |   2 +-
 src/qemu/qemu_monitor_json.c              |   2 +-
 src/qemu/qemu_monitor_text.c              |   2 +-
 src/qemu/qemu_process.c                   |   2 +-
 src/remote/remote_driver.c                |   2 +-
 src/rpc/virkeepalive.c                    |   2 +-
 src/rpc/virnetclient.c                    |   2 +-
 src/rpc/virnetclientprogram.c             |   2 +-
 src/rpc/virnetclientstream.c              |   2 +-
 src/rpc/virnetmessage.c                   |   2 +-
 src/rpc/virnetsaslcontext.c               |   2 +-
 src/rpc/virnetserver.c                    |   2 +-
 src/rpc/virnetserverclient.c              |   2 +-
 src/rpc/virnetservermdns.c                |   2 +-
 src/rpc/virnetserverprogram.c             |   2 +-
 src/rpc/virnetserverservice.c             |   2 +-
 src/rpc/virnetsocket.c                    |   2 +-
 src/rpc/virnetsshsession.c                |   2 +-
 src/rpc/virnettlscontext.c                |   2 +-
 src/secret/secret_driver.c                |   2 +-
 src/security/security_apparmor.c          |   2 +-
 src/security/security_dac.c               |   2 +-
 src/security/security_manager.c           |   2 +-
 src/security/security_selinux.c           |   2 +-
 src/security/security_stack.c             |   2 +-
 src/security/virt-aa-helper.c             |   2 +-
 src/storage/storage_backend.c             |   2 +-
 src/storage/storage_backend_disk.c        |   2 +-
 src/storage/storage_backend_fs.c          |   2 +-
 src/storage/storage_backend_iscsi.c       |   2 +-
 src/storage/storage_backend_logical.c     |   2 +-
 src/storage/storage_backend_mpath.c       |   2 +-
 src/storage/storage_backend_rbd.c         |   2 +-
 src/storage/storage_backend_scsi.c        |   2 +-
 src/storage/storage_backend_sheepdog.c    |   2 +-
 src/storage/storage_driver.c              |   2 +-
 src/test/test_driver.c                    |   2 +-
 src/uml/uml_conf.c                        |   2 +-
 src/uml/uml_driver.c                      |   2 +-
 src/util/iohelper.c                       |   2 +-
 src/util/memory.c                         | 422 ------------------------------
 src/util/memory.h                         | 380 ---------------------------
 src/util/pci.c                            |   2 +-
 src/util/sexpr.c                          |   2 +-
 src/util/stats_linux.c                    |   2 +-
 src/util/storage_file.c                   |   2 +-
 src/util/sysinfo.c                        |   2 +-
 src/util/threadpool.c                     |   2 +-
 src/util/threads-pthread.c                |   2 +-
 src/util/threads-win32.c                  |   2 +-
 src/util/util.c                           |   2 +-
 src/util/uuid.c                           |   2 +-
 src/util/viralloc.c                       | 422 ++++++++++++++++++++++++++++++
 src/util/viralloc.h                       | 380 +++++++++++++++++++++++++++
 src/util/viraudit.c                       |   2 +-
 src/util/virauth.c                        |   2 +-
 src/util/virauthconfig.c                  |   2 +-
 src/util/virbitmap.c                      |   2 +-
 src/util/virbuffer.c                      |   2 +-
 src/util/vircgroup.c                      |   2 +-
 src/util/vircommand.c                     |   2 +-
 src/util/virconf.c                        |   2 +-
 src/util/virdbus.c                        |   2 +-
 src/util/virdnsmasq.c                     |   2 +-
 src/util/virebtables.c                    |   2 +-
 src/util/vireventpoll.c                   |   2 +-
 src/util/virfile.c                        |   2 +-
 src/util/virhash.c                        |   2 +-
 src/util/virhooks.c                       |   2 +-
 src/util/virinitctl.c                     |   2 +-
 src/util/viriptables.c                    |   2 +-
 src/util/virjson.c                        |   2 +-
 src/util/virkeyfile.c                     |   2 +-
 src/util/virlockspace.c                   |   2 +-
 src/util/virlog.c                         |   2 +-
 src/util/virnetdev.c                      |   2 +-
 src/util/virnetdevbandwidth.c             |   2 +-
 src/util/virnetdevbridge.c                |   2 +-
 src/util/virnetdevmacvlan.c               |   2 +-
 src/util/virnetdevopenvswitch.c           |   2 +-
 src/util/virnetdevtap.c                   |   2 +-
 src/util/virnetdevveth.c                  |   2 +-
 src/util/virnetdevvlan.c                  |   2 +-
 src/util/virnetdevvportprofile.c          |   2 +-
 src/util/virnetlink.c                     |   2 +-
 src/util/virnodesuspend.c                 |   2 +-
 src/util/virobject.c                      |   2 +-
 src/util/virpidfile.c                     |   2 +-
 src/util/virprocess.c                     |   2 +-
 src/util/virstring.c                      |   2 +-
 src/util/virterror.c                      |   2 +-
 src/util/virtime.c                        |   2 +-
 src/util/virtypedparam.c                  |   2 +-
 src/util/viruri.c                         |   2 +-
 src/util/virusb.c                         |   2 +-
 src/util/xml.c                            |   2 +-
 src/vbox/vbox_MSCOMGlue.c                 |   2 +-
 src/vbox/vbox_XPCOMCGlue.c                |   2 +-
 src/vbox/vbox_tmpl.c                      |   2 +-
 src/vmware/vmware_conf.c                  |   2 +-
 src/vmware/vmware_driver.c                |   2 +-
 src/vmx/vmx.c                             |   2 +-
 src/xen/block_stats.c                     |   2 +-
 src/xen/xen_driver.c                      |   2 +-
 src/xen/xen_hypervisor.c                  |   2 +-
 src/xen/xen_inotify.c                     |   2 +-
 src/xen/xend_internal.c                   |   2 +-
 src/xen/xm_internal.c                     |   2 +-
 src/xen/xs_internal.c                     |   2 +-
 src/xenapi/xenapi_driver.c                |   2 +-
 src/xenapi/xenapi_utils.c                 |   2 +-
 src/xenxs/xen_sxpr.c                      |   2 +-
 src/xenxs/xen_xm.c                        |   2 +-
 tests/commandhelper.c                     |   2 +-
 tests/commandtest.c                       |   2 +-
 tests/conftest.c                          |   2 +-
 tests/cputest.c                           |   2 +-
 tests/esxutilstest.c                      |   2 +-
 tests/networkxml2conftest.c               |   2 +-
 tests/openvzutilstest.c                   |   2 +-
 tests/qemuhelptest.c                      |   2 +-
 tests/qemumonitortest.c                   |   2 +-
 tests/qemumonitortestutils.c              |   2 +-
 tests/qemuxml2argvtest.c                  |   2 +-
 tests/securityselinuxtest.c               |   2 +-
 tests/sockettest.c                        |   2 +-
 tests/testutils.c                         |   2 +-
 tests/testutils.h                         |   2 +-
 tests/testutilslxc.c                      |   2 +-
 tests/testutilsqemu.c                     |   2 +-
 tests/utiltest.c                          |   2 +-
 tests/virauthconfigtest.c                 |   2 +-
 tests/virbuftest.c                        |   2 +-
 tests/virdrivermoduletest.c               |   2 +-
 tests/virhashtest.c                       |   2 +-
 tests/virkeyfiletest.c                    |   2 +-
 tests/virlockspacetest.c                  |   2 +-
 tests/virnetmessagetest.c                 |   2 +-
 tests/virnetsockettest.c                  |   2 +-
 tests/virnettlscontexttest.c              |   2 +-
 tests/virstringtest.c                     |   2 +-
 tests/virtimetest.c                       |   2 +-
 tests/viruritest.c                        |   2 +-
 tests/vmx2xmltest.c                       |   2 +-
 tests/xmconfigtest.c                      |   2 +-
 tests/xml2vmxtest.c                       |   2 +-
 tools/console.c                           |   2 +-
 tools/virsh-domain-monitor.c              |   2 +-
 tools/virsh-domain.c                      |   2 +-
 tools/virsh-host.c                        |   2 +-
 tools/virsh-interface.c                   |   2 +-
 tools/virsh-network.c                     |   2 +-
 tools/virsh-nodedev.c                     |   2 +-
 tools/virsh-nwfilter.c                    |   2 +-
 tools/virsh-pool.c                        |   2 +-
 tools/virsh-secret.c                      |   2 +-
 tools/virsh-snapshot.c                    |   2 +-
 tools/virsh-volume.c                      |   2 +-
 tools/virsh.c                             |   2 +-
 tools/virt-host-validate-common.c         |   2 +-
 270 files changed, 1071 insertions(+), 1071 deletions(-)
 delete mode 100644 src/util/memory.c
 delete mode 100644 src/util/memory.h
 create mode 100644 src/util/viralloc.c
 create mode 100644 src/util/viralloc.h

diff --git a/cfg.mk b/cfg.mk
index 9fbf799..e23f1c5 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -321,7 +321,7 @@ sc_prohibit_internal_functions:
 # Avoid raw malloc and free, except in documentation comments.
 sc_prohibit_raw_allocation:
 	@prohibit='^.[^*].*\<((m|c|re)alloc|free) *\([^)]'		\
-	halt='use VIR_ macros from memory.h instead of malloc/free'	\
+	halt='use VIR_ macros from viralloc.h instead of malloc/free'	\
 	  $(_sc_search_regexp)
 
 # Avoid functions that can lead to double-close bugs.
@@ -785,7 +785,7 @@ exclude_file_name_regexp--sc_prohibit_fork_wrappers = \
 exclude_file_name_regexp--sc_prohibit_gethostname = ^src/util/util\.c$$
 
 exclude_file_name_regexp--sc_prohibit_internal_functions = \
-  ^src/(util/(memory|util|virfile)\.[hc]|esx/esx_vi\.c)$$
+  ^src/(util/(viralloc|util|virfile)\.[hc]|esx/esx_vi\.c)$$
 
 exclude_file_name_regexp--sc_prohibit_newline_at_end_of_diagnostic = \
   ^src/rpc/gendispatch\.pl$$
@@ -794,7 +794,7 @@ exclude_file_name_regexp--sc_prohibit_nonreentrant = \
   ^((po|tests)/|docs/.*py|run.in$$)
 
 exclude_file_name_regexp--sc_prohibit_raw_allocation = \
-  ^(src/util/memory\.[ch]|examples/.*)$$
+  ^(src/util/viralloc\.[ch]|examples/.*)$$
 
 exclude_file_name_regexp--sc_prohibit_readlink = \
   ^src/(util/util|lxc/lxc_container)\.c$$
diff --git a/daemon/libvirtd-config.c b/daemon/libvirtd-config.c
index f61f08d..b979a23 100644
--- a/daemon/libvirtd-config.c
+++ b/daemon/libvirtd-config.c
@@ -25,7 +25,7 @@
 
 #include "libvirtd-config.h"
 #include "virconf.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virterror_internal.h"
 #include "virlog.h"
 #include "rpc/virnetserver.h"
diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index fbf23d8..903f8c2 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -46,7 +46,7 @@
 #include "util.h"
 #include "uuid.h"
 #include "remote_driver.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virconf.h"
 #include "virnetlink.h"
 #include "virnetserver.h"
diff --git a/daemon/remote.c b/daemon/remote.c
index 58ceb39..eb75281 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -33,7 +33,7 @@
 #include "libvirtd.h"
 #include "libvirt_internal.h"
 #include "datatypes.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 #include "util.h"
 #include "stream.h"
diff --git a/daemon/stream.c b/daemon/stream.c
index d63e009..f208139 100644
--- a/daemon/stream.c
+++ b/daemon/stream.c
@@ -25,7 +25,7 @@
 
 #include "stream.h"
 #include "remote.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 #include "virnetserverclient.h"
 #include "virterror_internal.h"
diff --git a/python/libvirt-override.c b/python/libvirt-override.c
index eda8a11..644f34d 100644
--- a/python/libvirt-override.c
+++ b/python/libvirt-override.c
@@ -24,7 +24,7 @@
 #include "libvirt/virterror.h"
 #include "typewrappers.h"
 #include "libvirt.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virtypedparam.h"
 #include "ignore-value.h"
 #include "util.h"
diff --git a/python/typewrappers.c b/python/typewrappers.c
index d633603..9ba8790 100644
--- a/python/typewrappers.c
+++ b/python/typewrappers.c
@@ -16,7 +16,7 @@
 
 #include "typewrappers.h"
 
-#include "memory.h"
+#include "viralloc.h"
 
 #ifndef Py_CAPSULE_H
 typedef void(*PyCapsule_Destructor)(void *, void *);
diff --git a/src/Makefile.am b/src/Makefile.am
index 93da171..64f117d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -53,7 +53,6 @@ augeastest_DATA =
 # These files are not related to driver APIs. Simply generic
 # helper APIs for various purposes
 UTIL_SOURCES =							\
-		util/memory.c util/memory.h			\
 		util/pci.c util/pci.h				\
 		util/processinfo.c util/processinfo.h		\
 		util/sexpr.c util/sexpr.h			\
@@ -66,6 +65,7 @@ UTIL_SOURCES =							\
 		util/threadpool.c util/threadpool.h		\
 		util/uuid.c util/uuid.h				\
 		util/util.c util/util.h				\
+		util/viralloc.c util/viralloc.h			\
 		util/viratomic.h util/viratomic.c		\
 		util/viraudit.c util/viraudit.h			\
 		util/virauth.c util/virauth.h			\
diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c
index 3b8fef1..9ac18e2 100644
--- a/src/conf/capabilities.c
+++ b/src/conf/capabilities.c
@@ -27,7 +27,7 @@
 
 #include "capabilities.h"
 #include "virbuffer.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "util.h"
 #include "uuid.h"
 #include "cpu_conf.h"
diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c
index 190b088..23941c5 100644
--- a/src/conf/cpu_conf.c
+++ b/src/conf/cpu_conf.c
@@ -24,7 +24,7 @@
 #include <config.h>
 
 #include "virterror_internal.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "util.h"
 #include "virbuffer.h"
 #include "cpu_conf.h"
diff --git a/src/conf/device_conf.c b/src/conf/device_conf.c
index daf57bc..c3ca2d6 100644
--- a/src/conf/device_conf.c
+++ b/src/conf/device_conf.c
@@ -23,7 +23,7 @@
 #include <config.h>
 #include "virterror_internal.h"
 #include "datatypes.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "xml.h"
 #include "uuid.h"
 #include "util.h"
diff --git a/src/conf/domain_audit.c b/src/conf/domain_audit.c
index 5fca6a6..c275f71 100644
--- a/src/conf/domain_audit.c
+++ b/src/conf/domain_audit.c
@@ -30,7 +30,7 @@
 #include "viraudit.h"
 #include "uuid.h"
 #include "virlog.h"
-#include "memory.h"
+#include "viralloc.h"
 
 /* Return nn:mm in hex for block and character devices, and NULL
  * for other file types, stat failure, or allocation failure.  */
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index c48adf5..f80f5f1 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -34,7 +34,7 @@
 #include "datatypes.h"
 #include "domain_conf.h"
 #include "snapshot_conf.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "verify.h"
 #include "xml.h"
 #include "uuid.h"
diff --git a/src/conf/domain_event.c b/src/conf/domain_event.c
index f1e247b..d523808 100644
--- a/src/conf/domain_event.c
+++ b/src/conf/domain_event.c
@@ -26,7 +26,7 @@
 #include "domain_event.h"
 #include "virlog.h"
 #include "datatypes.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virterror_internal.h"
 
 #define VIR_FROM_THIS VIR_FROM_NONE
diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c
index 738ef33..046a8a1 100644
--- a/src/conf/interface_conf.c
+++ b/src/conf/interface_conf.c
@@ -27,7 +27,7 @@
 
 #include "interface_conf.h"
 
-#include "memory.h"
+#include "viralloc.h"
 #include "xml.h"
 #include "uuid.h"
 #include "util.h"
diff --git a/src/conf/netdev_bandwidth_conf.c b/src/conf/netdev_bandwidth_conf.c
index 15840b9..35f067c 100644
--- a/src/conf/netdev_bandwidth_conf.c
+++ b/src/conf/netdev_bandwidth_conf.c
@@ -25,7 +25,7 @@
 #include "netdev_bandwidth_conf.h"
 #include "virterror_internal.h"
 #include "util.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "domain_conf.h"
 
 #define VIR_FROM_THIS VIR_FROM_NONE
diff --git a/src/conf/netdev_vlan_conf.c b/src/conf/netdev_vlan_conf.c
index 6a0511a..8cee025 100644
--- a/src/conf/netdev_vlan_conf.c
+++ b/src/conf/netdev_vlan_conf.c
@@ -23,7 +23,7 @@
 
 #include "netdev_vlan_conf.h"
 #include "virterror_internal.h"
-#include "memory.h"
+#include "viralloc.h"
 
 #define VIR_FROM_THIS VIR_FROM_NONE
 
diff --git a/src/conf/netdev_vport_profile_conf.c b/src/conf/netdev_vport_profile_conf.c
index 94992e3..a9a38d7 100644
--- a/src/conf/netdev_vport_profile_conf.c
+++ b/src/conf/netdev_vport_profile_conf.c
@@ -24,7 +24,7 @@
 
 #include "netdev_vport_profile_conf.h"
 #include "virterror_internal.h"
-#include "memory.h"
+#include "viralloc.h"
 
 #define VIR_FROM_THIS VIR_FROM_NONE
 
diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index 42cb87e..1932851 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -37,7 +37,7 @@
 #include "netdev_vport_profile_conf.h"
 #include "netdev_bandwidth_conf.h"
 #include "netdev_vlan_conf.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "xml.h"
 #include "uuid.h"
 #include "util.h"
diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c
index 50fcf0b..85de50f 100644
--- a/src/conf/node_device_conf.c
+++ b/src/conf/node_device_conf.c
@@ -28,10 +28,10 @@
 
 #include "virterror_internal.h"
 #include "datatypes.h"
-#include "memory.h"
+#include "viralloc.h"
 
 #include "node_device_conf.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "xml.h"
 #include "util.h"
 #include "virbuffer.h"
diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c
index 46580e9..09a9d1c 100644
--- a/src/conf/nwfilter_conf.c
+++ b/src/conf/nwfilter_conf.c
@@ -39,7 +39,7 @@
 #include "internal.h"
 
 #include "uuid.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virterror_internal.h"
 #include "datatypes.h"
 #include "nwfilter_params.h"
diff --git a/src/conf/nwfilter_params.c b/src/conf/nwfilter_params.c
index f8cf980..1429952 100644
--- a/src/conf/nwfilter_params.c
+++ b/src/conf/nwfilter_params.c
@@ -25,7 +25,7 @@
 
 #include "internal.h"
 
-#include "memory.h"
+#include "viralloc.h"
 #include "virterror_internal.h"
 #include "datatypes.h"
 #include "nwfilter_params.h"
diff --git a/src/conf/secret_conf.c b/src/conf/secret_conf.c
index 24d7aa0..5188c7a 100644
--- a/src/conf/secret_conf.c
+++ b/src/conf/secret_conf.c
@@ -26,7 +26,7 @@
 #include "virbuffer.h"
 #include "datatypes.h"
 #include "virlog.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "secret_conf.h"
 #include "virterror_internal.h"
 #include "util.h"
diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c
index 6361810..9c16a88 100644
--- a/src/conf/snapshot_conf.c
+++ b/src/conf/snapshot_conf.c
@@ -35,7 +35,7 @@
 #include "datatypes.h"
 #include "domain_conf.h"
 #include "virlog.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "netdev_bandwidth_conf.h"
 #include "netdev_vport_profile_conf.h"
 #include "nwfilter_conf.h"
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index b81c08c..0e00588 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -42,7 +42,7 @@
 #include "uuid.h"
 #include "virbuffer.h"
 #include "util.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virfile.h"
 
 #define VIR_FROM_THIS VIR_FROM_STORAGE
diff --git a/src/conf/storage_encryption_conf.c b/src/conf/storage_encryption_conf.c
index 0c2bded..8d3ceac 100644
--- a/src/conf/storage_encryption_conf.c
+++ b/src/conf/storage_encryption_conf.c
@@ -28,7 +28,7 @@
 #include "internal.h"
 
 #include "virbuffer.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "storage_conf.h"
 #include "storage_encryption_conf.h"
 #include "util.h"
diff --git a/src/conf/virconsole.c b/src/conf/virconsole.c
index 92179cc..757573d 100644
--- a/src/conf/virconsole.c
+++ b/src/conf/virconsole.c
@@ -32,7 +32,7 @@
 #include "fdstream.h"
 #include "internal.h"
 #include "threads.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virpidfile.h"
 #include "virlog.h"
 #include "virterror_internal.h"
diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c
index 17a06f3..2222a91 100644
--- a/src/cpu/cpu.c
+++ b/src/cpu/cpu.c
@@ -24,7 +24,7 @@
 #include <config.h>
 
 #include "virlog.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "xml.h"
 #include "cpu.h"
 #include "cpu_x86.h"
diff --git a/src/cpu/cpu_arm.c b/src/cpu/cpu_arm.c
index 2d005df..75dee30 100644
--- a/src/cpu/cpu_arm.c
+++ b/src/cpu/cpu_arm.c
@@ -23,7 +23,7 @@
 
 #include <config.h>
 
-#include "memory.h"
+#include "viralloc.h"
 #include "cpu.h"
 
 #define VIR_FROM_THIS VIR_FROM_CPU
diff --git a/src/cpu/cpu_generic.c b/src/cpu/cpu_generic.c
index 3a6ed6c..4415ce1 100644
--- a/src/cpu/cpu_generic.c
+++ b/src/cpu/cpu_generic.c
@@ -24,7 +24,7 @@
 
 #include <config.h>
 
-#include "memory.h"
+#include "viralloc.h"
 #include "virhash.h"
 #include "cpu.h"
 #include "cpu_generic.h"
diff --git a/src/cpu/cpu_map.c b/src/cpu/cpu_map.c
index 8c4cfee..015be2e 100644
--- a/src/cpu/cpu_map.c
+++ b/src/cpu/cpu_map.c
@@ -23,7 +23,7 @@
 
 #include <config.h>
 
-#include "memory.h"
+#include "viralloc.h"
 #include "cpu.h"
 #include "cpu_map.h"
 #include "configmake.h"
diff --git a/src/cpu/cpu_powerpc.c b/src/cpu/cpu_powerpc.c
index c59bd1b..6b6c325 100644
--- a/src/cpu/cpu_powerpc.c
+++ b/src/cpu/cpu_powerpc.c
@@ -27,7 +27,7 @@
 #include <stdint.h>
 
 #include "virlog.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "util.h"
 #include "cpu.h"
 
diff --git a/src/cpu/cpu_s390.c b/src/cpu/cpu_s390.c
index 137c15f..a0f06f1 100644
--- a/src/cpu/cpu_s390.c
+++ b/src/cpu/cpu_s390.c
@@ -23,7 +23,7 @@
 
 #include <config.h>
 
-#include "memory.h"
+#include "viralloc.h"
 #include "cpu.h"
 
 
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index bea48a1..93ee111 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -26,7 +26,7 @@
 #include <stdint.h>
 
 #include "virlog.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "util.h"
 #include "cpu.h"
 #include "cpu_map.h"
diff --git a/src/datatypes.c b/src/datatypes.c
index 73a2fd0..0907c7d 100644
--- a/src/datatypes.c
+++ b/src/datatypes.c
@@ -25,7 +25,7 @@
 #include "datatypes.h"
 #include "virterror_internal.h"
 #include "virlog.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "uuid.h"
 #include "util.h"
 
diff --git a/src/driver.c b/src/driver.c
index 4ef6fd2..23dc329 100644
--- a/src/driver.c
+++ b/src/driver.c
@@ -25,7 +25,7 @@
 #include <unistd.h>
 
 #include "driver.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 #include "util.h"
 #include "configmake.h"
diff --git a/src/esx/esx_device_monitor.c b/src/esx/esx_device_monitor.c
index 0ad95f5..854fc38 100644
--- a/src/esx/esx_device_monitor.c
+++ b/src/esx/esx_device_monitor.c
@@ -26,7 +26,7 @@
 
 #include "internal.h"
 #include "util.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 #include "uuid.h"
 #include "esx_private.h"
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index a69d149..0fe9a67 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -29,7 +29,7 @@
 #include "snapshot_conf.h"
 #include "virauth.h"
 #include "util.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 #include "uuid.h"
 #include "vmx.h"
diff --git a/src/esx/esx_interface_driver.c b/src/esx/esx_interface_driver.c
index 4760264..fea67ab 100644
--- a/src/esx/esx_interface_driver.c
+++ b/src/esx/esx_interface_driver.c
@@ -26,7 +26,7 @@
 
 #include "internal.h"
 #include "util.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 #include "uuid.h"
 #include "interface_conf.h"
diff --git a/src/esx/esx_network_driver.c b/src/esx/esx_network_driver.c
index 3e25aa2..fec7e72 100644
--- a/src/esx/esx_network_driver.c
+++ b/src/esx/esx_network_driver.c
@@ -27,7 +27,7 @@
 #include "md5.h"
 #include "internal.h"
 #include "util.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 #include "uuid.h"
 #include "network_conf.h"
diff --git a/src/esx/esx_nwfilter_driver.c b/src/esx/esx_nwfilter_driver.c
index f5e710d..7a05a5a 100644
--- a/src/esx/esx_nwfilter_driver.c
+++ b/src/esx/esx_nwfilter_driver.c
@@ -26,7 +26,7 @@
 
 #include "internal.h"
 #include "util.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 #include "uuid.h"
 #include "esx_private.h"
diff --git a/src/esx/esx_secret_driver.c b/src/esx/esx_secret_driver.c
index 2a98644..2969b19 100644
--- a/src/esx/esx_secret_driver.c
+++ b/src/esx/esx_secret_driver.c
@@ -25,7 +25,7 @@
 
 #include "internal.h"
 #include "util.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 #include "uuid.h"
 #include "esx_private.h"
diff --git a/src/esx/esx_storage_backend_iscsi.c b/src/esx/esx_storage_backend_iscsi.c
index 5d4eb3c..9d481d2 100644
--- a/src/esx/esx_storage_backend_iscsi.c
+++ b/src/esx/esx_storage_backend_iscsi.c
@@ -29,7 +29,7 @@
 #include "internal.h"
 #include "md5.h"
 #include "util.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 #include "uuid.h"
 #include "storage_conf.h"
diff --git a/src/esx/esx_storage_backend_vmfs.c b/src/esx/esx_storage_backend_vmfs.c
index c8bba9e..bca637b 100644
--- a/src/esx/esx_storage_backend_vmfs.c
+++ b/src/esx/esx_storage_backend_vmfs.c
@@ -32,7 +32,7 @@
 #include "internal.h"
 #include "md5.h"
 #include "util.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 #include "uuid.h"
 #include "storage_conf.h"
diff --git a/src/esx/esx_storage_driver.c b/src/esx/esx_storage_driver.c
index e6c09aa..1324469 100644
--- a/src/esx/esx_storage_driver.c
+++ b/src/esx/esx_storage_driver.c
@@ -26,7 +26,7 @@
 #include <config.h>
 
 #include "uuid.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "storage_conf.h"
 #include "esx_private.h"
 #include "esx_storage_driver.h"
diff --git a/src/esx/esx_util.c b/src/esx/esx_util.c
index 6e27fe4..bcda9df 100644
--- a/src/esx/esx_util.c
+++ b/src/esx/esx_util.c
@@ -29,7 +29,7 @@
 #include "internal.h"
 #include "datatypes.h"
 #include "util.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 #include "uuid.h"
 #include "vmx.h"
diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c
index 76192df..37b6e0f 100644
--- a/src/esx/esx_vi.c
+++ b/src/esx/esx_vi.c
@@ -27,7 +27,7 @@
 #include <libxml/xpathInternals.h>
 
 #include "virbuffer.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 #include "util.h"
 #include "uuid.h"
diff --git a/src/esx/esx_vi_methods.c b/src/esx/esx_vi_methods.c
index a3870ee..7ffca559 100644
--- a/src/esx/esx_vi_methods.c
+++ b/src/esx/esx_vi_methods.c
@@ -24,7 +24,7 @@
 #include <config.h>
 
 #include "virbuffer.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 #include "uuid.h"
 #include "esx_vi_methods.h"
diff --git a/src/esx/esx_vi_types.c b/src/esx/esx_vi_types.c
index d0a2c6c..b93223d 100644
--- a/src/esx/esx_vi_types.c
+++ b/src/esx/esx_vi_types.c
@@ -29,7 +29,7 @@
 
 #include "virbuffer.h"
 #include "datatypes.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 #include "util.h"
 #include "esx_vi.h"
diff --git a/src/fdstream.c b/src/fdstream.c
index fdbd7a2..39e92b8 100644
--- a/src/fdstream.c
+++ b/src/fdstream.c
@@ -36,7 +36,7 @@
 #include "virterror_internal.h"
 #include "datatypes.h"
 #include "virlog.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "util.h"
 #include "virfile.h"
 #include "configmake.h"
diff --git a/src/hyperv/hyperv_device_monitor.c b/src/hyperv/hyperv_device_monitor.c
index 1fa98b2..d6edb76 100644
--- a/src/hyperv/hyperv_device_monitor.c
+++ b/src/hyperv/hyperv_device_monitor.c
@@ -27,7 +27,7 @@
 #include "virterror_internal.h"
 #include "datatypes.h"
 #include "util.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 #include "uuid.h"
 #include "hyperv_device_monitor.h"
diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c
index 95b0cd9..749c7f0 100644
--- a/src/hyperv/hyperv_driver.c
+++ b/src/hyperv/hyperv_driver.c
@@ -28,7 +28,7 @@
 #include "domain_conf.h"
 #include "virauth.h"
 #include "util.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 #include "uuid.h"
 #include "hyperv_driver.h"
diff --git a/src/hyperv/hyperv_interface_driver.c b/src/hyperv/hyperv_interface_driver.c
index 6a3c2cb..43c7dd7 100644
--- a/src/hyperv/hyperv_interface_driver.c
+++ b/src/hyperv/hyperv_interface_driver.c
@@ -27,7 +27,7 @@
 #include "virterror_internal.h"
 #include "datatypes.h"
 #include "util.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 #include "uuid.h"
 #include "hyperv_interface_driver.h"
diff --git a/src/hyperv/hyperv_network_driver.c b/src/hyperv/hyperv_network_driver.c
index 2f9fcab..06b051b 100644
--- a/src/hyperv/hyperv_network_driver.c
+++ b/src/hyperv/hyperv_network_driver.c
@@ -27,7 +27,7 @@
 #include "virterror_internal.h"
 #include "datatypes.h"
 #include "util.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 #include "uuid.h"
 #include "hyperv_network_driver.h"
diff --git a/src/hyperv/hyperv_nwfilter_driver.c b/src/hyperv/hyperv_nwfilter_driver.c
index c490522..7452b7a 100644
--- a/src/hyperv/hyperv_nwfilter_driver.c
+++ b/src/hyperv/hyperv_nwfilter_driver.c
@@ -27,7 +27,7 @@
 #include "virterror_internal.h"
 #include "datatypes.h"
 #include "util.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 #include "uuid.h"
 #include "hyperv_nwfilter_driver.h"
diff --git a/src/hyperv/hyperv_secret_driver.c b/src/hyperv/hyperv_secret_driver.c
index 3d58b01..04a6ada 100644
--- a/src/hyperv/hyperv_secret_driver.c
+++ b/src/hyperv/hyperv_secret_driver.c
@@ -27,7 +27,7 @@
 #include "virterror_internal.h"
 #include "datatypes.h"
 #include "util.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 #include "uuid.h"
 #include "hyperv_secret_driver.h"
diff --git a/src/hyperv/hyperv_storage_driver.c b/src/hyperv/hyperv_storage_driver.c
index 7fbc14d..b2817a2 100644
--- a/src/hyperv/hyperv_storage_driver.c
+++ b/src/hyperv/hyperv_storage_driver.c
@@ -27,7 +27,7 @@
 #include "virterror_internal.h"
 #include "datatypes.h"
 #include "util.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 #include "uuid.h"
 #include "hyperv_storage_driver.h"
diff --git a/src/hyperv/hyperv_util.c b/src/hyperv/hyperv_util.c
index 1ef6dae..016d415 100644
--- a/src/hyperv/hyperv_util.c
+++ b/src/hyperv/hyperv_util.c
@@ -25,7 +25,7 @@
 #include "internal.h"
 #include "datatypes.h"
 #include "util.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 #include "uuid.h"
 #include "hyperv_private.h"
diff --git a/src/hyperv/hyperv_wmi.c b/src/hyperv/hyperv_wmi.c
index 069ebe6..69e7283 100644
--- a/src/hyperv/hyperv_wmi.c
+++ b/src/hyperv/hyperv_wmi.c
@@ -28,7 +28,7 @@
 #include "virterror_internal.h"
 #include "datatypes.h"
 #include "virlog.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "util.h"
 #include "uuid.h"
 #include "virbuffer.h"
diff --git a/src/interface/interface_backend_netcf.c b/src/interface/interface_backend_netcf.c
index 1f42920..74a749b 100644
--- a/src/interface/interface_backend_netcf.c
+++ b/src/interface/interface_backend_netcf.c
@@ -29,7 +29,7 @@
 #include "datatypes.h"
 #include "interface_driver.h"
 #include "interface_conf.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 
 #define VIR_FROM_THIS VIR_FROM_INTERFACE
diff --git a/src/interface/interface_backend_udev.c b/src/interface/interface_backend_udev.c
index 9233e87..248b02e 100644
--- a/src/interface/interface_backend_udev.c
+++ b/src/interface/interface_backend_udev.c
@@ -27,7 +27,7 @@
 #include "datatypes.h"
 #include "interface_driver.h"
 #include "interface_conf.h"
-#include "memory.h"
+#include "viralloc.h"
 
 #define VIR_FROM_THIS VIR_FROM_INTERFACE
 
diff --git a/src/libvirt.c b/src/libvirt.c
index d078304..ed7dcae 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -51,7 +51,7 @@
 #include "driver.h"
 
 #include "uuid.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "configmake.h"
 #include "intprops.h"
 #include "virconf.h"
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index 460d15f..ac55cf3 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -37,7 +37,7 @@
 #include "datatypes.h"
 #include "virfile.h"
 #include "virstring.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "uuid.h"
 #include "capabilities.h"
 #include "libxl_driver.h"
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index ced7cfa..af74ebc 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -37,7 +37,7 @@
 #include "virconf.h"
 #include "datatypes.h"
 #include "virfile.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "uuid.h"
 #include "vircommand.h"
 #include "libxl.h"
diff --git a/src/locking/domain_lock.c b/src/locking/domain_lock.c
index 00861cf..0ae9750 100644
--- a/src/locking/domain_lock.c
+++ b/src/locking/domain_lock.c
@@ -22,7 +22,7 @@
 #include <config.h>
 
 #include "domain_lock.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "uuid.h"
 #include "virterror_internal.h"
 #include "virlog.h"
diff --git a/src/locking/lock_daemon.c b/src/locking/lock_daemon.c
index 3c2a50c..3d90c57 100644
--- a/src/locking/lock_daemon.c
+++ b/src/locking/lock_daemon.c
@@ -39,7 +39,7 @@
 #include "virprocess.h"
 #include "virterror_internal.h"
 #include "virlog.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virconf.h"
 #include "rpc/virnetserver.h"
 #include "virrandom.h"
diff --git a/src/locking/lock_daemon_config.c b/src/locking/lock_daemon_config.c
index 9557b8c..e370dd4 100644
--- a/src/locking/lock_daemon_config.c
+++ b/src/locking/lock_daemon_config.c
@@ -25,7 +25,7 @@
 
 #include "lock_daemon_config.h"
 #include "virconf.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virterror_internal.h"
 #include "virlog.h"
 #include "rpc/virnetserver.h"
diff --git a/src/locking/lock_driver_lockd.c b/src/locking/lock_driver_lockd.c
index d5d721d..cee530d 100644
--- a/src/locking/lock_driver_lockd.c
+++ b/src/locking/lock_driver_lockd.c
@@ -23,7 +23,7 @@
 
 #include "lock_driver.h"
 #include "virconf.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 #include "uuid.h"
 #include "util.h"
diff --git a/src/locking/lock_driver_nop.c b/src/locking/lock_driver_nop.c
index 745a0bf..cf0f49a 100644
--- a/src/locking/lock_driver_nop.c
+++ b/src/locking/lock_driver_nop.c
@@ -22,7 +22,7 @@
 #include <config.h>
 
 #include "lock_driver_nop.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 #include "uuid.h"
 
diff --git a/src/locking/lock_driver_sanlock.c b/src/locking/lock_driver_sanlock.c
index 1e8df26..e520444 100644
--- a/src/locking/lock_driver_sanlock.c
+++ b/src/locking/lock_driver_sanlock.c
@@ -39,7 +39,7 @@
 #include "lock_driver.h"
 #include "virlog.h"
 #include "virterror_internal.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "util.h"
 #include "virfile.h"
 #include "md5.h"
diff --git a/src/locking/lock_manager.c b/src/locking/lock_manager.c
index f038d4e..f938b04 100644
--- a/src/locking/lock_manager.c
+++ b/src/locking/lock_manager.c
@@ -26,7 +26,7 @@
 #include "virterror_internal.h"
 #include "virlog.h"
 #include "util.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "uuid.h"
 
 #if HAVE_DLFCN_H
diff --git a/src/locking/sanlock_helper.c b/src/locking/sanlock_helper.c
index ad69312..3e400b7 100644
--- a/src/locking/sanlock_helper.c
+++ b/src/locking/sanlock_helper.c
@@ -6,7 +6,7 @@
 #include "configmake.h"
 #include "internal.h"
 #include "virconf.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "domain_conf.h"
 
 
diff --git a/src/lxc/lxc_cgroup.c b/src/lxc/lxc_cgroup.c
index b8c4308..5d1f7ff 100644
--- a/src/lxc/lxc_cgroup.c
+++ b/src/lxc/lxc_cgroup.c
@@ -26,7 +26,7 @@
 #include "virfile.h"
 #include "virterror_internal.h"
 #include "virlog.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "vircgroup.h"
 
 #define VIR_FROM_THIS VIR_FROM_LXC
diff --git a/src/lxc/lxc_conf.c b/src/lxc/lxc_conf.c
index ca36965..043630a 100644
--- a/src/lxc/lxc_conf.c
+++ b/src/lxc/lxc_conf.c
@@ -32,7 +32,7 @@
 #include "nodeinfo.h"
 #include "virterror_internal.h"
 #include "virconf.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 #include "uuid.h"
 #include "configmake.h"
diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index 4aae28e..f3c6e19 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -57,7 +57,7 @@
 #include "virlog.h"
 #include "lxc_container.h"
 #include "util.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virnetdevveth.h"
 #include "uuid.h"
 #include "virfile.h"
diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
index 78f10ab..8a83e71 100644
--- a/src/lxc/lxc_controller.c
+++ b/src/lxc/lxc_controller.c
@@ -63,7 +63,7 @@
 #include "lxc_fuse.h"
 #include "virnetdev.h"
 #include "virnetdevveth.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "util.h"
 #include "virfile.h"
 #include "virpidfile.h"
diff --git a/src/lxc/lxc_domain.c b/src/lxc/lxc_domain.c
index 77a64dd..fab1506 100644
--- a/src/lxc/lxc_domain.c
+++ b/src/lxc/lxc_domain.c
@@ -23,7 +23,7 @@
 
 #include "lxc_domain.h"
 
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 #include "virterror_internal.h"
 
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 0ab2cb9..35e8ac9 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -43,7 +43,7 @@
 #include "lxc_domain.h"
 #include "lxc_driver.h"
 #include "lxc_process.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "util.h"
 #include "virnetdevbridge.h"
 #include "virnetdevveth.h"
diff --git a/src/lxc/lxc_fuse.h b/src/lxc/lxc_fuse.h
index a888122..9878017 100644
--- a/src/lxc/lxc_fuse.h
+++ b/src/lxc/lxc_fuse.h
@@ -33,7 +33,7 @@
 
 # include "lxc_conf.h"
 # include "util.h"
-# include "memory.h"
+# include "viralloc.h"
 
 struct virLXCMeminfo {
     unsigned long long memtotal;
diff --git a/src/lxc/lxc_monitor.c b/src/lxc/lxc_monitor.c
index 9eb587d..90637eb 100644
--- a/src/lxc/lxc_monitor.c
+++ b/src/lxc/lxc_monitor.c
@@ -25,7 +25,7 @@
 #include "lxc_protocol.h"
 #include "lxc_monitor_dispatch.h"
 
-#include "memory.h"
+#include "viralloc.h"
 
 #include "virterror_internal.h"
 #include "virlog.h"
diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c
index 02ed226..af14f6a 100644
--- a/src/lxc/lxc_process.c
+++ b/src/lxc/lxc_process.c
@@ -38,7 +38,7 @@
 #include "virtime.h"
 #include "domain_nwfilter.h"
 #include "network/bridge_driver.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "domain_audit.h"
 #include "virterror_internal.h"
 #include "virlog.h"
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 2a59b84..52b36a1 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -54,7 +54,7 @@
 #include "virpidfile.h"
 #include "util.h"
 #include "vircommand.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "uuid.h"
 #include "viriptables.h"
 #include "virlog.h"
diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c
index 48360e3..d914816 100644
--- a/src/node_device/node_device_driver.c
+++ b/src/node_device/node_device_driver.c
@@ -32,7 +32,7 @@
 
 #include "virterror_internal.h"
 #include "datatypes.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 #include "node_device_conf.h"
 #include "node_device_hal.h"
diff --git a/src/node_device/node_device_hal.c b/src/node_device/node_device_hal.c
index 59ba5c3..6f89f16 100644
--- a/src/node_device/node_device_hal.c
+++ b/src/node_device/node_device_hal.c
@@ -33,7 +33,7 @@
 #include "virterror_internal.h"
 #include "driver.h"
 #include "datatypes.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "uuid.h"
 #include "pci.h"
 #include "virlog.h"
diff --git a/src/node_device/node_device_linux_sysfs.c b/src/node_device/node_device_linux_sysfs.c
index fbe0da5..be5d3ed 100644
--- a/src/node_device/node_device_linux_sysfs.c
+++ b/src/node_device/node_device_linux_sysfs.c
@@ -29,7 +29,7 @@
 #include "node_device_driver.h"
 #include "node_device_hal.h"
 #include "virterror_internal.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 #include "virfile.h"
 
diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index fef00ad..81a11d7 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -33,7 +33,7 @@
 #include "driver.h"
 #include "datatypes.h"
 #include "virlog.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "uuid.h"
 #include "util.h"
 #include "virbuffer.h"
diff --git a/src/nodeinfo.c b/src/nodeinfo.c
index 0019c2b..b14e63b 100644
--- a/src/nodeinfo.c
+++ b/src/nodeinfo.c
@@ -39,7 +39,7 @@
 #endif
 
 #include "c-ctype.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "nodeinfo.h"
 #include "physmem.h"
 #include "util.h"
diff --git a/src/nwfilter/nwfilter_dhcpsnoop.c b/src/nwfilter/nwfilter_dhcpsnoop.c
index 68aa233..a798e95 100644
--- a/src/nwfilter/nwfilter_dhcpsnoop.c
+++ b/src/nwfilter/nwfilter_dhcpsnoop.c
@@ -54,7 +54,7 @@
 #include <netinet/udp.h>
 #include <net/if.h>
 
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 #include "datatypes.h"
 #include "virterror_internal.h"
diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c
index 7fde656..4b1188d 100644
--- a/src/nwfilter/nwfilter_driver.c
+++ b/src/nwfilter/nwfilter_driver.c
@@ -34,7 +34,7 @@
 
 #include "virterror_internal.h"
 #include "datatypes.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "domain_conf.h"
 #include "domain_nwfilter.h"
 #include "nwfilter_conf.h"
diff --git a/src/nwfilter/nwfilter_ebiptables_driver.c b/src/nwfilter/nwfilter_ebiptables_driver.c
index 23a43d2..092ae5a 100644
--- a/src/nwfilter/nwfilter_ebiptables_driver.c
+++ b/src/nwfilter/nwfilter_ebiptables_driver.c
@@ -31,7 +31,7 @@
 #include "internal.h"
 
 #include "virbuffer.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 #include "virterror_internal.h"
 #include "domain_conf.h"
diff --git a/src/nwfilter/nwfilter_gentech_driver.c b/src/nwfilter/nwfilter_gentech_driver.c
index 6be4a93..2b4cc8e 100644
--- a/src/nwfilter/nwfilter_gentech_driver.c
+++ b/src/nwfilter/nwfilter_gentech_driver.c
@@ -26,7 +26,7 @@
 
 #include "internal.h"
 
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 #include "domain_conf.h"
 #include "virterror_internal.h"
diff --git a/src/nwfilter/nwfilter_learnipaddr.c b/src/nwfilter/nwfilter_learnipaddr.c
index 110eae8..8c4bbcf 100644
--- a/src/nwfilter/nwfilter_learnipaddr.c
+++ b/src/nwfilter/nwfilter_learnipaddr.c
@@ -42,7 +42,7 @@
 
 #include "intprops.h"
 #include "virbuffer.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 #include "datatypes.h"
 #include "virnetdev.h"
diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c
index c9189ef..6e0f6eb 100644
--- a/src/openvz/openvz_conf.c
+++ b/src/openvz/openvz_conf.c
@@ -48,7 +48,7 @@
 #include "openvz_util.h"
 #include "uuid.h"
 #include "virbuffer.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "util.h"
 #include "nodeinfo.h"
 #include "virfile.h"
diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index 101fa32..f6327fd 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -53,7 +53,7 @@
 #include "util.h"
 #include "openvz_conf.h"
 #include "nodeinfo.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virfile.h"
 #include "virtypedparam.h"
 #include "virlog.h"
diff --git a/src/openvz/openvz_util.c b/src/openvz/openvz_util.c
index 4163e19..51b22c9 100644
--- a/src/openvz/openvz_util.c
+++ b/src/openvz/openvz_util.c
@@ -28,7 +28,7 @@
 #include "virterror_internal.h"
 #include "vircommand.h"
 #include "datatypes.h"
-#include "memory.h"
+#include "viralloc.h"
 
 #include "openvz_conf.h"
 #include "openvz_util.h"
diff --git a/src/parallels/parallels_driver.c b/src/parallels/parallels_driver.c
index 4e6f903..2d3dc4a 100644
--- a/src/parallels/parallels_driver.c
+++ b/src/parallels/parallels_driver.c
@@ -43,7 +43,7 @@
 
 #include "datatypes.h"
 #include "virterror_internal.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "util.h"
 #include "virlog.h"
 #include "vircommand.h"
diff --git a/src/parallels/parallels_network.c b/src/parallels/parallels_network.c
index 40706aa..4729f18 100644
--- a/src/parallels/parallels_network.c
+++ b/src/parallels/parallels_network.c
@@ -23,7 +23,7 @@
 #include <config.h>
 
 #include "datatypes.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virterror_internal.h"
 #include "md5.h"
 
diff --git a/src/parallels/parallels_storage.c b/src/parallels/parallels_storage.c
index 90fa104..f546d28 100644
--- a/src/parallels/parallels_storage.c
+++ b/src/parallels/parallels_storage.c
@@ -31,7 +31,7 @@
 #include <libgen.h>
 
 #include "datatypes.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "configmake.h"
 #include "storage_file.h"
 #include "virterror_internal.h"
diff --git a/src/parallels/parallels_utils.c b/src/parallels/parallels_utils.c
index b032882..9e317b1 100644
--- a/src/parallels/parallels_utils.c
+++ b/src/parallels/parallels_utils.c
@@ -26,7 +26,7 @@
 
 #include "vircommand.h"
 #include "virterror_internal.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virjson.h"
 
 #include "parallels_utils.h"
diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
index 0ac2771..ad56686 100644
--- a/src/phyp/phyp_driver.c
+++ b/src/phyp/phyp_driver.c
@@ -48,7 +48,7 @@
 #include "util.h"
 #include "datatypes.h"
 #include "virbuffer.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 #include "driver.h"
 #include "libvirt/libvirt.h"
diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index 421e43f..ec1e300 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -34,7 +34,7 @@
 
 #include "qemu_agent.h"
 #include "qemu_command.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 #include "virterror_internal.h"
 #include "virjson.h"
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 5853180..46f8540 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -24,7 +24,7 @@
 #include <config.h>
 
 #include "qemu_capabilities.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 #include "virterror_internal.h"
 #include "util.h"
diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
index 8d9ccf9..b47fb78 100644
--- a/src/qemu/qemu_cgroup.c
+++ b/src/qemu/qemu_cgroup.c
@@ -28,7 +28,7 @@
 #include "qemu_process.h"
 #include "vircgroup.h"
 #include "virlog.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virterror_internal.h"
 #include "util.h"
 #include "domain_audit.h"
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 8a35982..8a57cb5 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -28,7 +28,7 @@
 #include "qemu_capabilities.h"
 #include "qemu_bridge_filter.h"
 #include "cpu/cpu.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 #include "virterror_internal.h"
 #include "util.h"
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 598fad7..d6bc1fc 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -44,7 +44,7 @@
 #include "virbuffer.h"
 #include "virconf.h"
 #include "util.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "datatypes.h"
 #include "xml.h"
 #include "nodeinfo.h"
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index e6eaa58..8dcadbc 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -27,7 +27,7 @@
 #include "qemu_command.h"
 #include "qemu_capabilities.h"
 #include "qemu_migration.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 #include "virterror_internal.h"
 #include "c-ctype.h"
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 25e5738..65254b6 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -67,7 +67,7 @@
 #include "nodeinfo.h"
 #include "stats_linux.h"
 #include "capabilities.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "uuid.h"
 #include "domain_conf.h"
 #include "domain_audit.h"
diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c
index 3854520..754f8d0 100644
--- a/src/qemu/qemu_hostdev.c
+++ b/src/qemu/qemu_hostdev.c
@@ -26,7 +26,7 @@
 #include "qemu_hostdev.h"
 #include "virlog.h"
 #include "virterror_internal.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "pci.h"
 #include "virusb.h"
 #include "virnetdev.h"
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 7edd125..c432a32 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -35,7 +35,7 @@
 #include "virlog.h"
 #include "datatypes.h"
 #include "virterror_internal.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "pci.h"
 #include "virfile.h"
 #include "qemu_cgroup.h"
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index cabbe1a..3e9ff03 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -38,7 +38,7 @@
 #include "domain_audit.h"
 #include "virlog.h"
 #include "virterror_internal.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "util.h"
 #include "virfile.h"
 #include "datatypes.h"
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 920453d..5ca1f89 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -32,7 +32,7 @@
 #include "qemu_monitor_text.h"
 #include "qemu_monitor_json.h"
 #include "virterror_internal.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 #include "virfile.h"
 #include "virprocess.h"
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index e14134b..0137291 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -35,7 +35,7 @@
 #include "qemu_monitor_json.h"
 #include "qemu_command.h"
 #include "qemu_capabilities.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 #include "driver.h"
 #include "datatypes.h"
diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c
index 28690b1..82e9108 100644
--- a/src/qemu/qemu_monitor_text.c
+++ b/src/qemu/qemu_monitor_text.c
@@ -34,7 +34,7 @@
 #include "qemu_command.h"
 #include "c-ctype.h"
 #include "c-strcasestr.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 #include "driver.h"
 #include "datatypes.h"
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index a77b248..b20734d 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -53,7 +53,7 @@
 #include "datatypes.h"
 #include "virlog.h"
 #include "virterror_internal.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virhooks.h"
 #include "virfile.h"
 #include "virpidfile.h"
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 1e9151a..2edf6e6 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -38,7 +38,7 @@
 #include "remote_driver.h"
 #include "remote_protocol.h"
 #include "qemu_protocol.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "util.h"
 #include "virfile.h"
 #include "vircommand.h"
diff --git a/src/rpc/virkeepalive.c b/src/rpc/virkeepalive.c
index 8fc1cba..91af315 100644
--- a/src/rpc/virkeepalive.c
+++ b/src/rpc/virkeepalive.c
@@ -22,7 +22,7 @@
 
 #include <config.h>
 
-#include "memory.h"
+#include "viralloc.h"
 #include "threads.h"
 #include "virfile.h"
 #include "virlog.h"
diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c
index 7370ae0..b4fe4d9 100644
--- a/src/rpc/virnetclient.c
+++ b/src/rpc/virnetclient.c
@@ -30,7 +30,7 @@
 #include "virnetclient.h"
 #include "virnetsocket.h"
 #include "virkeepalive.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "threads.h"
 #include "virfile.h"
 #include "virlog.h"
diff --git a/src/rpc/virnetclientprogram.c b/src/rpc/virnetclientprogram.c
index dec3943..7396971 100644
--- a/src/rpc/virnetclientprogram.c
+++ b/src/rpc/virnetclientprogram.c
@@ -28,7 +28,7 @@
 #include "virnetclient.h"
 #include "virnetprotocol.h"
 
-#include "memory.h"
+#include "viralloc.h"
 #include "virterror_internal.h"
 #include "virlog.h"
 #include "util.h"
diff --git a/src/rpc/virnetclientstream.c b/src/rpc/virnetclientstream.c
index 26dc292..4877b0c 100644
--- a/src/rpc/virnetclientstream.c
+++ b/src/rpc/virnetclientstream.c
@@ -24,7 +24,7 @@
 
 #include "virnetclientstream.h"
 #include "virnetclient.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virterror_internal.h"
 #include "virlog.h"
 #include "threads.h"
diff --git a/src/rpc/virnetmessage.c b/src/rpc/virnetmessage.c
index 16d8e61..f273811 100644
--- a/src/rpc/virnetmessage.c
+++ b/src/rpc/virnetmessage.c
@@ -24,7 +24,7 @@
 #include <unistd.h>
 
 #include "virnetmessage.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virterror_internal.h"
 #include "virlog.h"
 #include "virfile.h"
diff --git a/src/rpc/virnetsaslcontext.c b/src/rpc/virnetsaslcontext.c
index e880127..adc4f1e 100644
--- a/src/rpc/virnetsaslcontext.c
+++ b/src/rpc/virnetsaslcontext.c
@@ -26,7 +26,7 @@
 #include "virnetmessage.h"
 
 #include "virterror_internal.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "threads.h"
 #include "virlog.h"
 
diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c
index 6d3532a..67cd4b5 100644
--- a/src/rpc/virnetserver.c
+++ b/src/rpc/virnetserver.c
@@ -29,7 +29,7 @@
 
 #include "virnetserver.h"
 #include "virlog.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virterror_internal.h"
 #include "threads.h"
 #include "threadpool.h"
diff --git a/src/rpc/virnetserverclient.c b/src/rpc/virnetserverclient.c
index 9642ea5..7f028b8 100644
--- a/src/rpc/virnetserverclient.c
+++ b/src/rpc/virnetserverclient.c
@@ -31,7 +31,7 @@
 
 #include "virlog.h"
 #include "virterror_internal.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "threads.h"
 #include "virkeepalive.h"
 
diff --git a/src/rpc/virnetservermdns.c b/src/rpc/virnetservermdns.c
index c17b65d..daef2b4 100644
--- a/src/rpc/virnetservermdns.c
+++ b/src/rpc/virnetservermdns.c
@@ -42,7 +42,7 @@
 
 #include "virnetservermdns.h"
 #include "vireventpoll.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virterror_internal.h"
 #include "virlog.h"
 
diff --git a/src/rpc/virnetserverprogram.c b/src/rpc/virnetserverprogram.c
index 5b96c34..287282e 100644
--- a/src/rpc/virnetserverprogram.c
+++ b/src/rpc/virnetserverprogram.c
@@ -26,7 +26,7 @@
 #include "virnetserverprogram.h"
 #include "virnetserverclient.h"
 
-#include "memory.h"
+#include "viralloc.h"
 #include "virterror_internal.h"
 #include "virlog.h"
 #include "virfile.h"
diff --git a/src/rpc/virnetserverservice.c b/src/rpc/virnetserverservice.c
index a9362ad..92b5cef 100644
--- a/src/rpc/virnetserverservice.c
+++ b/src/rpc/virnetserverservice.c
@@ -25,7 +25,7 @@
 
 #include "virnetserverservice.h"
 
-#include "memory.h"
+#include "viralloc.h"
 #include "virterror_internal.h"
 #include "threads.h"
 
diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c
index aa8f4b9..8c62a2a 100644
--- a/src/rpc/virnetsocket.c
+++ b/src/rpc/virnetsocket.c
@@ -42,7 +42,7 @@
 #include "c-ctype.h"
 #include "virnetsocket.h"
 #include "util.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virterror_internal.h"
 #include "virlog.h"
 #include "virfile.h"
diff --git a/src/rpc/virnetsshsession.c b/src/rpc/virnetsshsession.c
index 734acaa..8a7d5f9 100644
--- a/src/rpc/virnetsshsession.c
+++ b/src/rpc/virnetsshsession.c
@@ -27,7 +27,7 @@
 
 #include "internal.h"
 #include "virbuffer.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 #include "configmake.h"
 #include "threads.h"
diff --git a/src/rpc/virnettlscontext.c b/src/rpc/virnettlscontext.c
index 2931003..d9354e0 100644
--- a/src/rpc/virnettlscontext.c
+++ b/src/rpc/virnettlscontext.c
@@ -30,7 +30,7 @@
 
 #include "virnettlscontext.h"
 
-#include "memory.h"
+#include "viralloc.h"
 #include "virterror_internal.h"
 #include "util.h"
 #include "virlog.h"
diff --git a/src/secret/secret_driver.c b/src/secret/secret_driver.c
index 4159358..fb2024b 100644
--- a/src/secret/secret_driver.c
+++ b/src/secret/secret_driver.c
@@ -33,7 +33,7 @@
 #include "datatypes.h"
 #include "driver.h"
 #include "virlog.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "secret_conf.h"
 #include "secret_driver.h"
 #include "threads.h"
diff --git a/src/security/security_apparmor.c b/src/security/security_apparmor.c
index f2aebc8..b65384e 100644
--- a/src/security/security_apparmor.c
+++ b/src/security/security_apparmor.c
@@ -39,7 +39,7 @@
 
 #include "security_apparmor.h"
 #include "util.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virterror_internal.h"
 #include "datatypes.h"
 #include "uuid.h"
diff --git a/src/security/security_dac.c b/src/security/security_dac.c
index 9ff2665..bdb29c7 100644
--- a/src/security/security_dac.c
+++ b/src/security/security_dac.c
@@ -26,7 +26,7 @@
 #include "security_dac.h"
 #include "virterror_internal.h"
 #include "util.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 #include "pci.h"
 #include "virusb.h"
diff --git a/src/security/security_manager.c b/src/security/security_manager.c
index 67c8858..2da6244 100644
--- a/src/security/security_manager.c
+++ b/src/security/security_manager.c
@@ -27,7 +27,7 @@
 #include "security_stack.h"
 #include "security_dac.h"
 #include "virterror_internal.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 
 #define VIR_FROM_THIS VIR_FROM_SECURITY
diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c
index 2a19781..3a1548d 100644
--- a/src/security/security_selinux.c
+++ b/src/security/security_selinux.c
@@ -35,7 +35,7 @@
 #include "security_selinux.h"
 #include "virterror_internal.h"
 #include "util.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 #include "pci.h"
 #include "virusb.h"
diff --git a/src/security/security_stack.c b/src/security/security_stack.c
index c2ccbd0..390bd3b 100644
--- a/src/security/security_stack.c
+++ b/src/security/security_stack.c
@@ -23,7 +23,7 @@
 #include "security_stack.h"
 
 #include "virterror_internal.h"
-#include "memory.h"
+#include "viralloc.h"
 
 #define VIR_FROM_THIS VIR_FROM_SECURITY
 
diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c
index d92b3d4..c9c222a 100644
--- a/src/security/virt-aa-helper.c
+++ b/src/security/virt-aa-helper.c
@@ -42,7 +42,7 @@
 #include "internal.h"
 #include "virbuffer.h"
 #include "util.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "vircommand.h"
 
 #include "security_driver.h"
diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
index 899caeb..cdc5bda 100644
--- a/src/storage/storage_backend.c
+++ b/src/storage/storage_backend.c
@@ -48,7 +48,7 @@
 #include "datatypes.h"
 #include "virterror_internal.h"
 #include "util.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "internal.h"
 #include "secret_conf.h"
 #include "uuid.h"
diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backend_disk.c
index 7e1d3ec..8759b3a 100644
--- a/src/storage/storage_backend_disk.c
+++ b/src/storage/storage_backend_disk.c
@@ -30,7 +30,7 @@
 #include "virlog.h"
 #include "storage_backend_disk.h"
 #include "util.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "vircommand.h"
 #include "configmake.h"
 
diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c
index 78b50f0..f7b4656 100644
--- a/src/storage/storage_backend_fs.c
+++ b/src/storage/storage_backend_fs.c
@@ -46,7 +46,7 @@
 #include "storage_conf.h"
 #include "storage_file.h"
 #include "vircommand.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "xml.h"
 #include "virfile.h"
 #include "virlog.h"
diff --git a/src/storage/storage_backend_iscsi.c b/src/storage/storage_backend_iscsi.c
index 46659af..ecb8f8e 100644
--- a/src/storage/storage_backend_iscsi.c
+++ b/src/storage/storage_backend_iscsi.c
@@ -38,7 +38,7 @@
 #include "storage_backend_scsi.h"
 #include "storage_backend_iscsi.h"
 #include "util.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 #include "virfile.h"
 #include "vircommand.h"
diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_backend_logical.c
index f28c663..83b517c 100644
--- a/src/storage/storage_backend_logical.c
+++ b/src/storage/storage_backend_logical.c
@@ -35,7 +35,7 @@
 #include "storage_backend_logical.h"
 #include "storage_conf.h"
 #include "vircommand.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 #include "virfile.h"
 
diff --git a/src/storage/storage_backend_mpath.c b/src/storage/storage_backend_mpath.c
index 1ca120f..0e5d032 100644
--- a/src/storage/storage_backend_mpath.c
+++ b/src/storage/storage_backend_mpath.c
@@ -32,7 +32,7 @@
 #include "virterror_internal.h"
 #include "storage_conf.h"
 #include "storage_backend.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 #include "virfile.h"
 
diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backend_rbd.c
index 4e58911..e1f07ab 100644
--- a/src/storage/storage_backend_rbd.c
+++ b/src/storage/storage_backend_rbd.c
@@ -26,7 +26,7 @@
 #include "storage_backend_rbd.h"
 #include "storage_conf.h"
 #include "util.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 #include "base64.h"
 #include "uuid.h"
diff --git a/src/storage/storage_backend_scsi.c b/src/storage/storage_backend_scsi.c
index 32713be..1db8fdd 100644
--- a/src/storage/storage_backend_scsi.c
+++ b/src/storage/storage_backend_scsi.c
@@ -30,7 +30,7 @@
 
 #include "virterror_internal.h"
 #include "storage_backend_scsi.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 #include "virfile.h"
 #include "vircommand.h"
diff --git a/src/storage/storage_backend_sheepdog.c b/src/storage/storage_backend_sheepdog.c
index 05deeeb..d3b9d87 100644
--- a/src/storage/storage_backend_sheepdog.c
+++ b/src/storage/storage_backend_sheepdog.c
@@ -31,7 +31,7 @@
 #include "storage_conf.h"
 #include "vircommand.h"
 #include "util.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 
 #define VIR_FROM_THIS VIR_FROM_STORAGE
diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index 6076f6c..aebf8bb 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -42,7 +42,7 @@
 #include "util.h"
 #include "storage_driver.h"
 #include "storage_conf.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "storage_backend.h"
 #include "virlog.h"
 #include "virfile.h"
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index dbaf14e..3abd289 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -39,7 +39,7 @@
 #include "util.h"
 #include "uuid.h"
 #include "capabilities.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "network_conf.h"
 #include "interface_conf.h"
 #include "domain_conf.h"
diff --git a/src/uml/uml_conf.c b/src/uml/uml_conf.c
index 35b54c2..6da311b 100644
--- a/src/uml/uml_conf.c
+++ b/src/uml/uml_conf.c
@@ -40,7 +40,7 @@
 #include "virbuffer.h"
 #include "virconf.h"
 #include "util.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "nodeinfo.h"
 #include "virlog.h"
 #include "domain_nwfilter.h"
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index 90c9b66..cece114 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -51,7 +51,7 @@
 #include "nodeinfo.h"
 #include "stats_linux.h"
 #include "capabilities.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "uuid.h"
 #include "domain_conf.h"
 #include "domain_audit.h"
diff --git a/src/util/iohelper.c b/src/util/iohelper.c
index a9c8b4c..1b16d5c 100644
--- a/src/util/iohelper.c
+++ b/src/util/iohelper.c
@@ -36,7 +36,7 @@
 #include "util.h"
 #include "threads.h"
 #include "virfile.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virterror_internal.h"
 #include "configmake.h"
 #include "virrandom.h"
diff --git a/src/util/memory.c b/src/util/memory.c
deleted file mode 100644
index 186d3b6..0000000
--- a/src/util/memory.c
+++ /dev/null
@@ -1,422 +0,0 @@
-/*
- * memory.c: safer memory allocation
- *
- * Copyright (C) 2010-2012 Red Hat, Inc.
- * Copyright (C) 2008 Daniel P. Berrange
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library.  If not, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-
-#include <config.h>
-#include <stdlib.h>
-
-#include "memory.h"
-#include "virlog.h"
-
-#if TEST_OOM
-static int testMallocNext = 0;
-static int testMallocFailFirst = 0;
-static int testMallocFailLast = 0;
-static void (*testMallocHook)(int, void*) = NULL;
-static void *testMallocHookData = NULL;
-
-void virAllocTestInit(void)
-{
-    testMallocNext = 1;
-    testMallocFailFirst = 0;
-    testMallocFailLast = 0;
-}
-
-int virAllocTestCount(void)
-{
-    return testMallocNext - 1;
-}
-
-void virAllocTestHook(void (*func)(int, void*), void *data)
-{
-    testMallocHook = func;
-    testMallocHookData = data;
-}
-
-void virAllocTestOOM(int n, int m)
-{
-    testMallocNext = 1;
-    testMallocFailFirst = n;
-    testMallocFailLast = n + m - 1;
-}
-
-static int virAllocTestFail(void)
-{
-    int fail = 0;
-    if (testMallocNext == 0)
-        return 0;
-
-    fail =
-        testMallocNext >= testMallocFailFirst &&
-        testMallocNext <= testMallocFailLast;
-
-    if (fail && testMallocHook)
-        (testMallocHook)(testMallocNext, testMallocHookData);
-
-    testMallocNext++;
-    return fail;
-}
-#endif
-
-
-/**
- * virAlloc:
- * @ptrptr: pointer to pointer for address of allocated memory
- * @size: number of bytes to allocate
- *
- * Allocate  'size' bytes of memory. Return the address of the
- * allocated memory in 'ptrptr'. The newly allocated memory is
- * filled with zeros.
- *
- * Returns -1 on failure to allocate, zero on success
- */
-int virAlloc(void *ptrptr, size_t size)
-{
-#if TEST_OOM
-    if (virAllocTestFail()) {
-        *(void **)ptrptr = NULL;
-        return -1;
-    }
-#endif
-
-    *(void **)ptrptr = calloc(1, size);
-    if (*(void **)ptrptr == NULL)
-        return -1;
-    return 0;
-}
-
-/**
- * virAllocN:
- * @ptrptr: pointer to pointer for address of allocated memory
- * @size: number of bytes to allocate
- * @count: number of elements to allocate
- *
- * Allocate an array of memory 'count' elements long,
- * each with 'size' bytes. Return the address of the
- * allocated memory in 'ptrptr'.  The newly allocated
- * memory is filled with zeros.
- *
- * Returns -1 on failure to allocate, zero on success
- */
-int virAllocN(void *ptrptr, size_t size, size_t count)
-{
-#if TEST_OOM
-    if (virAllocTestFail()) {
-        *(void **)ptrptr = NULL;
-        return -1;
-    }
-#endif
-
-    *(void**)ptrptr = calloc(count, size);
-    if (*(void**)ptrptr == NULL)
-        return -1;
-    return 0;
-}
-
-/**
- * virReallocN:
- * @ptrptr: pointer to pointer for address of allocated memory
- * @size: number of bytes to allocate
- * @count: number of elements in array
- *
- * Resize the block of memory in 'ptrptr' to be an array of
- * 'count' elements, each 'size' bytes in length. Update 'ptrptr'
- * with the address of the newly allocated memory. On failure,
- * 'ptrptr' is not changed and still points to the original memory
- * block. Any newly allocated memory in 'ptrptr' is uninitialized.
- *
- * Returns -1 on failure to allocate, zero on success
- */
-int virReallocN(void *ptrptr, size_t size, size_t count)
-{
-    void *tmp;
-#if TEST_OOM
-    if (virAllocTestFail())
-        return -1;
-#endif
-
-    if (xalloc_oversized(count, size)) {
-        errno = ENOMEM;
-        return -1;
-    }
-    tmp = realloc(*(void**)ptrptr, size * count);
-    if (!tmp && (size * count))
-        return -1;
-    *(void**)ptrptr = tmp;
-    return 0;
-}
-
-/**
- * virExpandN:
- * @ptrptr: pointer to pointer for address of allocated memory
- * @size: number of bytes per element
- * @countptr: pointer to number of elements in array
- * @add: number of elements to add
- *
- * Resize the block of memory in 'ptrptr' to be an array of
- * '*countptr' + 'add' elements, each 'size' bytes in length.
- * Update 'ptrptr' and 'countptr'  with the details of the newly
- * allocated memory. On failure, 'ptrptr' and 'countptr' are not
- * changed. Any newly allocated memory in 'ptrptr' is zero-filled.
- *
- * Returns -1 on failure to allocate, zero on success
- */
-int virExpandN(void *ptrptr, size_t size, size_t *countptr, size_t add)
-{
-    int ret;
-
-    if (*countptr + add < *countptr) {
-        errno = ENOMEM;
-        return -1;
-    }
-    ret = virReallocN(ptrptr, size, *countptr + add);
-    if (ret == 0) {
-        memset(*(char **)ptrptr + (size * *countptr), 0, size * add);
-        *countptr += add;
-    }
-    return ret;
-}
-
-/**
- * virResizeN:
- * @ptrptr: pointer to pointer for address of allocated memory
- * @size: number of bytes per element
- * @allocptr: pointer to number of elements allocated in array
- * @count: number of elements currently used in array
- * @add: minimum number of additional elements to support in array
- *
- * If 'count' + 'add' is larger than '*allocptr', then resize the
- * block of memory in 'ptrptr' to be an array of at least 'count' +
- * 'add' elements, each 'size' bytes in length. Update 'ptrptr' and
- * 'allocptr' with the details of the newly allocated memory. On
- * failure, 'ptrptr' and 'allocptr' are not changed. Any newly
- * allocated memory in 'ptrptr' is zero-filled.
- *
- * Returns -1 on failure to allocate, zero on success
- */
-int virResizeN(void *ptrptr, size_t size, size_t *allocptr, size_t count,
-               size_t add)
-{
-    size_t delta;
-
-    if (count + add < count) {
-        errno = ENOMEM;
-        return -1;
-    }
-    if (count + add <= *allocptr)
-        return 0;
-
-    delta = count + add - *allocptr;
-    if (delta < *allocptr / 2)
-        delta = *allocptr / 2;
-    return virExpandN(ptrptr, size, allocptr, delta);
-}
-
-/**
- * virShrinkN:
- * @ptrptr: pointer to pointer for address of allocated memory
- * @size: number of bytes per element
- * @countptr: pointer to number of elements in array
- * @toremove: number of elements to remove
- *
- * Resize the block of memory in 'ptrptr' to be an array of
- * '*countptr' - 'toremove' elements, each 'size' bytes in length.
- * Update 'ptrptr' and 'countptr'  with the details of the newly
- * allocated memory. If 'toremove' is larger than 'countptr', free
- * the entire array.
- */
-void virShrinkN(void *ptrptr, size_t size, size_t *countptr, size_t toremove)
-{
-    if (toremove < *countptr)
-        ignore_value(virReallocN(ptrptr, size, *countptr -= toremove));
-    else {
-        virFree(ptrptr);
-        *countptr = 0;
-    }
-}
-
-/**
- * virInsertElementsN:
- * @ptrptr:   pointer to hold address of allocated memory
- * @size:     the size of one element in bytes
- * @at:       index within array where new elements should be added
- * @countptr: variable tracking number of elements currently allocated
- * @add:      number of elements to add
- * @newelems: pointer to array of one or more new elements to move into
- *            place (the originals will be zeroed out if successful
- *            and if clearOriginal is true)
- * @clearOriginal: false if the new item in the array should be copied
- *            from the original, and the original left intact.
- *            true if the original should be 0'd out on success.
- * @inPlace:  false if we should expand the allocated memory before
- *            moving, true if we should assume someone else *has
- *            already* done that.
- *
- * Re-allocate an array of *countptr elements, each sizeof(*ptrptr) bytes
- * long, to be *countptr+add elements long, then appropriately move
- * the elements starting at ptrptr[at] up by add elements, copy the
- * items from newelems into ptrptr[at], then store the address of
- * allocated memory in *ptrptr and the new size in *countptr.  If
- * newelems is NULL, the new elements at ptrptr[at] are instead filled
- * with zero.
- *
- * Returns -1 on failure, 0 on success
- */
-int
-virInsertElementsN(void *ptrptr, size_t size, size_t at,
-                   size_t *countptr,
-                   size_t add, void *newelems,
-                   bool clearOriginal, bool inPlace)
-{
-    if (at > *countptr) {
-        VIR_WARN("out of bounds index - count %zu at %zu add %zu",
-                 *countptr, at, add);
-        return -1;
-    }
-
-    if (inPlace) {
-        *countptr += add;
-    } else if (virExpandN(ptrptr, size, countptr, add) < 0) {
-        return -1;
-    }
-
-    /* memory was successfully re-allocated. Move up all elements from
-     * ptrptr[at] to the end (if we're not "inserting" at the end
-     * already), memcpy in the new elements, and clear the elements
-     * from their original location. Remember that *countptr has
-     * already been updated with new element count!
-     */
-    if (at < *countptr - add) {
-        memmove(*(char**)ptrptr + (size * (at + add)),
-                *(char**)ptrptr + (size * at),
-                size * (*countptr - add - at));
-    }
-
-    if (newelems) {
-        memcpy(*(char**)ptrptr + (size * at), newelems, size * add);
-        if (clearOriginal)
-           memset((char*)newelems, 0, size * add);
-    } else if (inPlace || (at < *countptr - add)) {
-        /* NB: if inPlace, assume memory at the end wasn't initialized */
-        memset(*(char**)ptrptr + (size * at), 0, size * add);
-    }
-
-    return 0;
-}
-
-/**
- * virDeleteElementsN:
- * @ptrptr:   pointer to hold address of allocated memory
- * @size:     the size of one element in bytes
- * @at:       index within array where new elements should be deleted
- * @countptr: variable tracking number of elements currently allocated
- * @remove:   number of elements to remove
- * @inPlace:  false if we should shrink the allocated memory when done,
- *            true if we should assume someone else will do that.
- *
- * Re-allocate an array of *countptr elements, each sizeof(*ptrptr)
- * bytes long, to be *countptr-remove elements long, then store the
- * address of allocated memory in *ptrptr and the new size in *countptr.
- * If *countptr <= remove, the entire array is freed.
- *
- * Returns -1 on failure, 0 on success
- */
-int
-virDeleteElementsN(void *ptrptr, size_t size, size_t at,
-                   size_t *countptr, size_t remove,
-                   bool inPlace)
-{
-    if (at + remove > *countptr) {
-        VIR_WARN("out of bounds index - count %zu at %zu remove %zu",
-                 *countptr, at, remove);
-        return -1;
-    }
-
-    /* First move down the elements at the end that won't be deleted,
-     * then realloc. We assume that the items being deleted have
-     * already been cleared.
-    */
-    memmove(*(char**)ptrptr + (size * at),
-            *(char**)ptrptr + (size * (at + remove)),
-            size * (*countptr - remove - at));
-    if (inPlace)
-        *countptr -= remove;
-    else
-        virShrinkN(ptrptr, size, countptr, remove);
-    return 0;
-}
-
-/**
- * Vir_Alloc_Var:
- * @ptrptr: pointer to hold address of allocated memory
- * @struct_size: size of initial struct
- * @element_size: size of array elements
- * @count: number of array elements to allocate
- *
- * Allocate struct_size bytes plus an array of 'count' elements, each
- * of size element_size.  This sort of allocation is useful for
- * receiving the data of certain ioctls and other APIs which return a
- * struct in which the last element is an array of undefined length.
- * The caller of this type of API is expected to know the length of
- * the array that will be returned and allocate a suitable buffer to
- * contain the returned data.  C99 refers to these variable length
- * objects as structs containing flexible array members.
- *
- * Returns -1 on failure, 0 on success
- */
-int virAllocVar(void *ptrptr, size_t struct_size, size_t element_size, size_t count)
-{
-    size_t alloc_size = 0;
-
-#if TEST_OOM
-    if (virAllocTestFail())
-        return -1;
-#endif
-
-    if (VIR_ALLOC_VAR_OVERSIZED(struct_size, count, element_size)) {
-        errno = ENOMEM;
-        return -1;
-    }
-
-    alloc_size = struct_size + (element_size * count);
-    *(void **)ptrptr = calloc(1, alloc_size);
-    if (*(void **)ptrptr == NULL)
-        return -1;
-    return 0;
-}
-
-
-/**
- * virFree:
- * @ptrptr: pointer to pointer for address of memory to be freed
- *
- * Release the chunk of memory in the pointer pointed to by
- * the 'ptrptr' variable. After release, 'ptrptr' will be
- * updated to point to NULL.
- */
-void virFree(void *ptrptr)
-{
-    int save_errno = errno;
-
-    free(*(void**)ptrptr);
-    *(void**)ptrptr = NULL;
-    errno = save_errno;
-}
diff --git a/src/util/memory.h b/src/util/memory.h
deleted file mode 100644
index 8398105..0000000
--- a/src/util/memory.h
+++ /dev/null
@@ -1,380 +0,0 @@
-/*
- * memory.c: safer memory allocation
- *
- * Copyright (C) 2010-2012 Red Hat, Inc.
- * Copyright (C) 2008 Daniel P. Berrange
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library.  If not, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-
-
-#ifndef __VIR_MEMORY_H_
-# define __VIR_MEMORY_H_
-
-# include "internal.h"
-
-/* Return 1 if an array of N objects, each of size S, cannot exist due
-   to size arithmetic overflow.  S must be positive and N must be
-   nonnegative.  This is a macro, not an inline function, so that it
-   works correctly even when SIZE_MAX < N.
-
-   By gnulib convention, SIZE_MAX represents overflow in size
-   calculations, so the conservative dividend to use here is
-   SIZE_MAX - 1, since SIZE_MAX might represent an overflowed value.
-   However, malloc (SIZE_MAX) fails on all known hosts where
-   sizeof(ptrdiff_t) <= sizeof(size_t), so do not bother to test for
-   exactly-SIZE_MAX allocations on such hosts; this avoids a test and
-   branch when S is known to be 1.  */
-# ifndef xalloc_oversized
-#  define xalloc_oversized(n, s) \
-    ((size_t) (sizeof(ptrdiff_t) <= sizeof(size_t) ? -1 : -2) / (s) < (n))
-# endif
-
-
-
-/* Don't call these directly - use the macros below */
-int virAlloc(void *ptrptr, size_t size) ATTRIBUTE_RETURN_CHECK
-    ATTRIBUTE_NONNULL(1);
-int virAllocN(void *ptrptr, size_t size, size_t count) ATTRIBUTE_RETURN_CHECK
-    ATTRIBUTE_NONNULL(1);
-int virReallocN(void *ptrptr, size_t size, size_t count) ATTRIBUTE_RETURN_CHECK
-    ATTRIBUTE_NONNULL(1);
-int virExpandN(void *ptrptr, size_t size, size_t *count, size_t add)
-    ATTRIBUTE_RETURN_CHECK ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3);
-int virResizeN(void *ptrptr, size_t size, size_t *alloc, size_t count,
-               size_t desired)
-    ATTRIBUTE_RETURN_CHECK ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3);
-void virShrinkN(void *ptrptr, size_t size, size_t *count, size_t toremove)
-    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3);
-int virInsertElementsN(void *ptrptr, size_t size, size_t at, size_t *countptr,
-                       size_t add, void *newelem,
-                       bool clearOriginal, bool inPlace)
-    ATTRIBUTE_RETURN_CHECK ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4);
-int virDeleteElementsN(void *ptrptr, size_t size, size_t at, size_t *countptr,
-                       size_t remove, bool inPlace)
-    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4);
-int virAllocVar(void *ptrptr,
-                size_t struct_size,
-                size_t element_size,
-                size_t count) ATTRIBUTE_RETURN_CHECK ATTRIBUTE_NONNULL(1);
-void virFree(void *ptrptr) ATTRIBUTE_NONNULL(1);
-
-/**
- * VIR_ALLOC:
- * @ptr: pointer to hold address of allocated memory
- *
- * Allocate sizeof(*ptr) bytes of memory and store
- * the address of allocated memory in 'ptr'. Fill the
- * newly allocated memory with zeros.
- *
- * Returns -1 on failure, 0 on success
- */
-# define VIR_ALLOC(ptr) virAlloc(&(ptr), sizeof(*(ptr)))
-
-/**
- * VIR_ALLOC_N:
- * @ptr: pointer to hold address of allocated memory
- * @count: number of elements to allocate
- *
- * Allocate an array of 'count' elements, each sizeof(*ptr)
- * bytes long and store the address of allocated memory in
- * 'ptr'. Fill the newly allocated memory with zeros.
- *
- * Returns -1 on failure, 0 on success
- */
-# define VIR_ALLOC_N(ptr, count) virAllocN(&(ptr), sizeof(*(ptr)), (count))
-
-/**
- * VIR_REALLOC_N:
- * @ptr: pointer to hold address of allocated memory
- * @count: number of elements to allocate
- *
- * Re-allocate an array of 'count' elements, each sizeof(*ptr)
- * bytes long and store the address of allocated memory in
- * 'ptr'. If 'ptr' grew, the added memory is uninitialized.
- *
- * Returns -1 on failure, 0 on success
- */
-# define VIR_REALLOC_N(ptr, count) virReallocN(&(ptr), sizeof(*(ptr)), (count))
-
-/**
- * VIR_EXPAND_N:
- * @ptr: pointer to hold address of allocated memory
- * @count: variable tracking number of elements currently allocated
- * @add: number of elements to add
- *
- * Re-allocate an array of 'count' elements, each sizeof(*ptr)
- * bytes long, to be 'count' + 'add' elements long, then store the
- * address of allocated memory in 'ptr' and the new size in 'count'.
- * The new elements are filled with zero.
- *
- * Returns -1 on failure, 0 on success
- */
-# define VIR_EXPAND_N(ptr, count, add) \
-    virExpandN(&(ptr), sizeof(*(ptr)), &(count), add)
-
-/**
- * VIR_RESIZE_N:
- * @ptr: pointer to hold address of allocated memory
- * @alloc: variable tracking number of elements currently allocated
- * @count: number of elements currently in use
- * @add: minimum number of elements to additionally support
- *
- * Blindly using VIR_EXPAND_N(array, alloc, 1) in a loop scales
- * quadratically, because every iteration must copy contents from
- * all prior iterations.  But amortized linear scaling can be achieved
- * by tracking allocation size separately from the number of used
- * elements, and growing geometrically only as needed.
- *
- * If 'count' + 'add' is larger than 'alloc', then geometrically reallocate
- * the array of 'alloc' elements, each sizeof(*ptr) bytes long, and store
- * the address of allocated memory in 'ptr' and the new size in 'alloc'.
- * The new elements are filled with zero.
- *
- * Returns -1 on failure, 0 on success
- */
-# define VIR_RESIZE_N(ptr, alloc, count, add) \
-    virResizeN(&(ptr), sizeof(*(ptr)), &(alloc), count, add)
-
-/**
- * VIR_SHRINK_N:
- * @ptr: pointer to hold address of allocated memory
- * @count: variable tracking number of elements currently allocated
- * @remove: number of elements to remove
- *
- * Re-allocate an array of 'count' elements, each sizeof(*ptr)
- * bytes long, to be 'count' - 'remove' elements long, then store the
- * address of allocated memory in 'ptr' and the new size in 'count'.
- * If 'count' <= 'remove', the entire array is freed.
- *
- * No return value.
- */
-# define VIR_SHRINK_N(ptr, count, remove) \
-    virShrinkN(&(ptr), sizeof(*(ptr)), &(count), remove)
-
-/*
- * VIR_TYPEMATCH:
- *
- * The following macro seems a bit cryptic, so it needs a thorough
- * explanation. Its purpose is to check for assignment compatibility
- * and identical size between two values without creating any side
- * effects (by doing something silly like actually assigning one to
- * the other). Note that it takes advantage of the C89-guaranteed
- * property of sizeof() - it cannot have any side effects, so anything
- * that happens inside sizeof() will not have any effect at runtime.
- *
- * VIR_TYPEMATCH evaluates to "1" if the two passed values are both
- * assignment-compatible and the same size, and otherwise generates a
- * compile-time error. It determines the result by performing the
- * following three operations:
- *
- *    * sizeof(*(a) = *(b)) assures that *a and *b are
- *      assignment-compatible (they may still have a different size
- *      though! e.g. longVar = intVar) (If not, there is a compile-time
- *      error. If so, the result of that subexpression is sizeof(*(a)),
- *      i.e. one element of the array)
- *
- *    * sizeof(*(a) = *(b)) == sizeof(*(b)) checks if *a and *b are also
- *      of the same size (so that, e.g. you don't accidentally copy an
- *      int plus the random bytes following it into an array of long). It
- *      evaluates to 1 if they are the same, and 0 otherwise.
- *
- *    * sizeof(char[2 * (result of previous step) - 1]) evaluates to 1
- *      if the previous step was successful (char [(2*1) - 1] i.e.
- *      char[1]), or generates a compile error if it wasn't successful
- *      (char[2*0 -1] i.e. char[-1], which isn't valid in C).
- *
- * So VIR_TYPECHECK(a, b) will either abort the compile with an error,
- * or evaluate to "1", and in the meantime check that we've actually
- * added the correct &'s and/or *'s to the arguments. (Whew!)
-*/
-# define VIR_TYPEMATCH(a, b) \
-    sizeof(char[2 * (sizeof(*(a) = *(b)) == sizeof(*(b))) - 1])
-
-/**
- * VIR_INSERT_ELEMENT:
- * @ptr:     pointer to array of objects (*not* ptr to ptr)
- * @at:      index within array where new elements should be added
- * @count:   variable tracking number of elements currently allocated
- * @newelem: the new element to move into place (*not* a pointer to
- *           the element, but the element itself).
- *           (the original will be zeroed out if successful)
- *
- * Re-allocate an array of 'count' elements, each sizeof(*ptr) bytes
- * long, to be 'count' + 1 elements long, then appropriately move
- * the elements starting at ptr[at] up by 1 element, copy the
- * item 'newelem' into ptr[at], then store the address of
- * allocated memory in 'ptr' and the new size in 'count'.
- *
- * VIR_INSERT_ELEMENT_COPY is identical, but doesn't clear out the
- *   original element to 0 on success, so there are two copies of the
- *   element. This is useful if the "element" is actually just a
- *   pointer to the real data, and you want to maintain a reference to
- *   it for use after the insert is completed; but if the "element" is
- *   an object that points to other allocated memory, having multiple
- *   copies can cause problems (e.g. double free).
- *
- * VIR_INSERT_ELEMENT_*INPLACE are identical, but assume any necessary
- *   memory re-allocation has already been done.
- *
- * VIR_INSERT_ELEMENT_* all need to send "1" as the "add" argument to
- * virInsertElementsN (which has the currently-unused capability of
- * inserting multiple items at once). We use this to our advantage by
- * replacing it with VIR_TYPECHECK(ptr, &newelem) so that we can be
- * assured ptr and &newelem are of compatible types.
- *
- * Returns -1 on failure, 0 on success
- *
- *
- */
-# define VIR_INSERT_ELEMENT(ptr, at, count, newelem) \
-    virInsertElementsN(&(ptr), sizeof(*(ptr)), at, &(count),    \
-                       VIR_TYPEMATCH(ptr, &(newelem)), &(newelem), true, false)
-# define VIR_INSERT_ELEMENT_COPY(ptr, at, count, newelem) \
-    virInsertElementsN(&(ptr), sizeof(*(ptr)), at, &(count), \
-                       VIR_TYPEMATCH(ptr, &(newelem)), &(newelem), false, false)
-# define VIR_INSERT_ELEMENT_INPLACE(ptr, at, count, newelem) \
-    virInsertElementsN(&(ptr), sizeof(*(ptr)), at, &(count), \
-                       VIR_TYPEMATCH(ptr, &(newelem)), &(newelem), true, true)
-# define VIR_INSERT_ELEMENT_COPY_INPLACE(ptr, at, count, newelem) \
-    virInsertElementsN(&(ptr), sizeof(*(ptr)), at, &(count), \
-                       VIR_TYPEMATCH(ptr, &(newelem)), &(newelem), false, true)
-
-/**
- * VIR_APPEND_ELEMENT:
- * @ptr:     pointer to array of objects (*not* ptr to ptr)
- * @count:   variable tracking number of elements currently allocated
- * @newelem: the new element to move into place (*not* a pointer to
- *           the element, but the element itself).
- *           (the original will be zeroed out if successful)
- *
- * Re-allocate an array of 'count' elements, each sizeof(*ptr) bytes
- * long, to be 'count' + 1 elements long, then copy the item from
- * 'newelem' into ptr[count+1], and store the address of allocated
- * memory in 'ptr' and the new size in 'count'. If 'newelem' is NULL,
- * the new element at ptr[at] is instead filled with zero.
- *
- * VIR_APPEND_ELEMENT_COPY is identical, but doesn't clear out the
- *   original element to 0 on success, so there are two copies of the
- *   element. This is useful if the "element" is actually just a
- *   pointer to the real data, and you want to maintain a reference to
- *   it for use after the append is completed; but if the "element" is
- *   an object that points to other allocated memory, having multiple
- *   copies can cause problems (e.g. double free).
- *
- * VIR_APPEND_ELEMENT_*INPLACE are identical, but assume any
- *   necessary memory re-allocation has already been done.
- *
- * VIR_APPEND_ELEMENT_* all need to send "1" as the "add" argument to
- * virInsertElementsN (which has the currently-unused capability of
- * inserting multiple items at once). We use this to our advantage by
- * replacing it with VIR_TYPECHECK(ptr, &newelem) so that we can be
- * assured ptr and &newelem are of compatible types.
- *
- * Returns -1 on failure, 0 on success
- *
- *
- */
-# define VIR_APPEND_ELEMENT(ptr, count, newelem) \
-    virInsertElementsN(&(ptr), sizeof(*(ptr)), count, &(count),  \
-                       VIR_TYPEMATCH(ptr, &(newelem)), &(newelem), true, false)
-# define VIR_APPEND_ELEMENT_COPY(ptr, count, newelem) \
-    virInsertElementsN(&(ptr), sizeof(*(ptr)), count, &(count),  \
-                       VIR_TYPEMATCH(ptr, &(newelem)), &(newelem), false, false)
-# define VIR_APPEND_ELEMENT_INPLACE(ptr, count, newelem) \
-    virInsertElementsN(&(ptr), sizeof(*(ptr)), count, &(count),  \
-                       VIR_TYPEMATCH(ptr, &(newelem)), &(newelem), true, true)
-# define VIR_APPEND_ELEMENT_COPY_INPLACE(ptr, count, newelem) \
-    virInsertElementsN(&(ptr), sizeof(*(ptr)), count, &(count),  \
-                       VIR_TYPEMATCH(ptr, &(newelem)), &(newelem), false, true)
-
-/**
- * VIR_DELETE_ELEMENT:
- * @ptr:   pointer to array of objects (*not* ptr to ptr)
- * @at:    index within array where new elements should be deleted
- * @count: variable tracking number of elements currently allocated
- *
- * Re-allocate an array of 'count' elements, each sizeof(*ptr)
- * bytes long, to be 'count' - 1 elements long, then store the
- * address of allocated memory in 'ptr' and the new size in 'count'.
- * If 'count' <= 1, the entire array is freed.
- *
- * VIR_DELETE_ELEMENT_INPLACE is identical, but assumes any
- *   necessary memory re-allocation will be done later.
- *
- * Returns -1 on failure, 0 on success
- */
-# define VIR_DELETE_ELEMENT(ptr, at, count) \
-    virDeleteElementsN(&(ptr), sizeof(*(ptr)), at, &(count), 1, false)
-# define VIR_DELETE_ELEMENT_INPLACE(ptr, at, count) \
-    virDeleteElementsN(&(ptr), sizeof(*(ptr)), at, &(count), 1, true)
-
-/*
- * VIR_ALLOC_VAR_OVERSIZED:
- * @M: size of base structure
- * @N: number of array elements in trailing array
- * @S: size of trailing array elements
- *
- * Check to make sure that the requested allocation will not cause
- * arithmetic overflow in the allocation size.  The check is
- * essentially the same as that in gnulib's xalloc_oversized.
- */
-# define VIR_ALLOC_VAR_OVERSIZED(M, N, S) ((((size_t)-1) - (M)) / (S) < (N))
-
-/**
- * VIR_ALLOC_VAR:
- * @ptr: pointer to hold address of allocated memory
- * @type: element type of trailing array
- * @count: number of array elements to allocate
- *
- * Allocate sizeof(*ptr) bytes plus an array of 'count' elements, each
- * sizeof('type').  This sort of allocation is useful for receiving
- * the data of certain ioctls and other APIs which return a struct in
- * which the last element is an array of undefined length.  The caller
- * of this type of API is expected to know the length of the array
- * that will be returned and allocate a suitable buffer to contain the
- * returned data.  C99 refers to these variable length objects as
- * structs containing flexible array members.
-
- * Returns -1 on failure, 0 on success
- */
-# define VIR_ALLOC_VAR(ptr, type, count) \
-    virAllocVar(&(ptr), sizeof(*(ptr)), sizeof(type), (count))
-
-/**
- * VIR_FREE:
- * @ptr: pointer holding address to be freed
- *
- * Free the memory stored in 'ptr' and update to point
- * to NULL.
- */
-/* The ternary ensures that ptr is a pointer and not an integer type,
- * while evaluating ptr only once.  For now, we intentionally cast
- * away const, since a number of callers safely pass const char *.
- */
-# define VIR_FREE(ptr) virFree((void *) (1 ? (const void *) &(ptr) : (ptr)))
-
-
-# if TEST_OOM
-void virAllocTestInit(void);
-int virAllocTestCount(void);
-void virAllocTestOOM(int n, int m);
-void virAllocTestHook(void (*func)(int, void*), void *data);
-# endif
-
-
-
-#endif /* __VIR_MEMORY_H_ */
diff --git a/src/util/pci.c b/src/util/pci.c
index 7adce75..e4009fa 100644
--- a/src/util/pci.c
+++ b/src/util/pci.c
@@ -35,7 +35,7 @@
 #include <stdlib.h>
 
 #include "virlog.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "vircommand.h"
 #include "virterror_internal.h"
 #include "virfile.h"
diff --git a/src/util/sexpr.c b/src/util/sexpr.c
index f72b7d7..ae0cc18 100644
--- a/src/util/sexpr.c
+++ b/src/util/sexpr.c
@@ -20,7 +20,7 @@
 #include "virterror_internal.h"
 #include "sexpr.h"
 #include "util.h"
-#include "memory.h"
+#include "viralloc.h"
 
 #define VIR_FROM_THIS VIR_FROM_SEXPR
 
diff --git a/src/util/stats_linux.c b/src/util/stats_linux.c
index 2dfc30d..67ef82e 100644
--- a/src/util/stats_linux.c
+++ b/src/util/stats_linux.c
@@ -36,7 +36,7 @@
 # include "datatypes.h"
 # include "util.h"
 # include "stats_linux.h"
-# include "memory.h"
+# include "viralloc.h"
 # include "virfile.h"
 
 # define VIR_FROM_THIS VIR_FROM_STATS_LINUX
diff --git a/src/util/storage_file.c b/src/util/storage_file.c
index 6c3390b..a020bb2 100644
--- a/src/util/storage_file.c
+++ b/src/util/storage_file.c
@@ -35,7 +35,7 @@
 # include <sys/statfs.h>
 #endif
 #include "dirname.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virterror_internal.h"
 #include "virlog.h"
 #include "virfile.h"
diff --git a/src/util/sysinfo.c b/src/util/sysinfo.c
index 5690f95..667e6a2 100644
--- a/src/util/sysinfo.c
+++ b/src/util/sysinfo.c
@@ -34,7 +34,7 @@
 #include "sysinfo.h"
 #include "util.h"
 #include "virlog.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "vircommand.h"
 
 #define VIR_FROM_THIS VIR_FROM_SYSINFO
diff --git a/src/util/threadpool.c b/src/util/threadpool.c
index ffbbe72..9d3d5d2 100644
--- a/src/util/threadpool.c
+++ b/src/util/threadpool.c
@@ -26,7 +26,7 @@
 #include <config.h>
 
 #include "threadpool.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "threads.h"
 #include "virterror_internal.h"
 
diff --git a/src/util/threads-pthread.c b/src/util/threads-pthread.c
index 44e8bc0..37d8902 100644
--- a/src/util/threads-pthread.c
+++ b/src/util/threads-pthread.c
@@ -27,7 +27,7 @@
 # include <sys/syscall.h>
 #endif
 
-#include "memory.h"
+#include "viralloc.h"
 
 
 /* Nothing special required for pthreads */
diff --git a/src/util/threads-win32.c b/src/util/threads-win32.c
index 142aa4f..c9f16c1 100644
--- a/src/util/threads-win32.c
+++ b/src/util/threads-win32.c
@@ -23,7 +23,7 @@
 
 #include <process.h>
 
-#include "memory.h"
+#include "viralloc.h"
 
 struct virThreadLocalData {
     DWORD key;
diff --git a/src/util/util.c b/src/util/util.c
index f941dfd..c070d94 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -80,7 +80,7 @@
 #include "virbuffer.h"
 #include "util.h"
 #include "storage_file.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "threads.h"
 #include "verify.h"
 #include "virfile.h"
diff --git a/src/util/uuid.c b/src/util/uuid.c
index 6efc7be..5232ba9 100644
--- a/src/util/uuid.c
+++ b/src/util/uuid.c
@@ -38,7 +38,7 @@
 #include "util.h"
 #include "virterror_internal.h"
 #include "virlog.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virfile.h"
 #include "virrandom.h"
 
diff --git a/src/util/viralloc.c b/src/util/viralloc.c
new file mode 100644
index 0000000..628145f
--- /dev/null
+++ b/src/util/viralloc.c
@@ -0,0 +1,422 @@
+/*
+ * memory.c: safer memory allocation
+ *
+ * Copyright (C) 2010-2012 Red Hat, Inc.
+ * Copyright (C) 2008 Daniel P. Berrange
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include <config.h>
+#include <stdlib.h>
+
+#include "viralloc.h"
+#include "virlog.h"
+
+#if TEST_OOM
+static int testMallocNext = 0;
+static int testMallocFailFirst = 0;
+static int testMallocFailLast = 0;
+static void (*testMallocHook)(int, void*) = NULL;
+static void *testMallocHookData = NULL;
+
+void virAllocTestInit(void)
+{
+    testMallocNext = 1;
+    testMallocFailFirst = 0;
+    testMallocFailLast = 0;
+}
+
+int virAllocTestCount(void)
+{
+    return testMallocNext - 1;
+}
+
+void virAllocTestHook(void (*func)(int, void*), void *data)
+{
+    testMallocHook = func;
+    testMallocHookData = data;
+}
+
+void virAllocTestOOM(int n, int m)
+{
+    testMallocNext = 1;
+    testMallocFailFirst = n;
+    testMallocFailLast = n + m - 1;
+}
+
+static int virAllocTestFail(void)
+{
+    int fail = 0;
+    if (testMallocNext == 0)
+        return 0;
+
+    fail =
+        testMallocNext >= testMallocFailFirst &&
+        testMallocNext <= testMallocFailLast;
+
+    if (fail && testMallocHook)
+        (testMallocHook)(testMallocNext, testMallocHookData);
+
+    testMallocNext++;
+    return fail;
+}
+#endif
+
+
+/**
+ * virAlloc:
+ * @ptrptr: pointer to pointer for address of allocated memory
+ * @size: number of bytes to allocate
+ *
+ * Allocate  'size' bytes of memory. Return the address of the
+ * allocated memory in 'ptrptr'. The newly allocated memory is
+ * filled with zeros.
+ *
+ * Returns -1 on failure to allocate, zero on success
+ */
+int virAlloc(void *ptrptr, size_t size)
+{
+#if TEST_OOM
+    if (virAllocTestFail()) {
+        *(void **)ptrptr = NULL;
+        return -1;
+    }
+#endif
+
+    *(void **)ptrptr = calloc(1, size);
+    if (*(void **)ptrptr == NULL)
+        return -1;
+    return 0;
+}
+
+/**
+ * virAllocN:
+ * @ptrptr: pointer to pointer for address of allocated memory
+ * @size: number of bytes to allocate
+ * @count: number of elements to allocate
+ *
+ * Allocate an array of memory 'count' elements long,
+ * each with 'size' bytes. Return the address of the
+ * allocated memory in 'ptrptr'.  The newly allocated
+ * memory is filled with zeros.
+ *
+ * Returns -1 on failure to allocate, zero on success
+ */
+int virAllocN(void *ptrptr, size_t size, size_t count)
+{
+#if TEST_OOM
+    if (virAllocTestFail()) {
+        *(void **)ptrptr = NULL;
+        return -1;
+    }
+#endif
+
+    *(void**)ptrptr = calloc(count, size);
+    if (*(void**)ptrptr == NULL)
+        return -1;
+    return 0;
+}
+
+/**
+ * virReallocN:
+ * @ptrptr: pointer to pointer for address of allocated memory
+ * @size: number of bytes to allocate
+ * @count: number of elements in array
+ *
+ * Resize the block of memory in 'ptrptr' to be an array of
+ * 'count' elements, each 'size' bytes in length. Update 'ptrptr'
+ * with the address of the newly allocated memory. On failure,
+ * 'ptrptr' is not changed and still points to the original memory
+ * block. Any newly allocated memory in 'ptrptr' is uninitialized.
+ *
+ * Returns -1 on failure to allocate, zero on success
+ */
+int virReallocN(void *ptrptr, size_t size, size_t count)
+{
+    void *tmp;
+#if TEST_OOM
+    if (virAllocTestFail())
+        return -1;
+#endif
+
+    if (xalloc_oversized(count, size)) {
+        errno = ENOMEM;
+        return -1;
+    }
+    tmp = realloc(*(void**)ptrptr, size * count);
+    if (!tmp && (size * count))
+        return -1;
+    *(void**)ptrptr = tmp;
+    return 0;
+}
+
+/**
+ * virExpandN:
+ * @ptrptr: pointer to pointer for address of allocated memory
+ * @size: number of bytes per element
+ * @countptr: pointer to number of elements in array
+ * @add: number of elements to add
+ *
+ * Resize the block of memory in 'ptrptr' to be an array of
+ * '*countptr' + 'add' elements, each 'size' bytes in length.
+ * Update 'ptrptr' and 'countptr'  with the details of the newly
+ * allocated memory. On failure, 'ptrptr' and 'countptr' are not
+ * changed. Any newly allocated memory in 'ptrptr' is zero-filled.
+ *
+ * Returns -1 on failure to allocate, zero on success
+ */
+int virExpandN(void *ptrptr, size_t size, size_t *countptr, size_t add)
+{
+    int ret;
+
+    if (*countptr + add < *countptr) {
+        errno = ENOMEM;
+        return -1;
+    }
+    ret = virReallocN(ptrptr, size, *countptr + add);
+    if (ret == 0) {
+        memset(*(char **)ptrptr + (size * *countptr), 0, size * add);
+        *countptr += add;
+    }
+    return ret;
+}
+
+/**
+ * virResizeN:
+ * @ptrptr: pointer to pointer for address of allocated memory
+ * @size: number of bytes per element
+ * @allocptr: pointer to number of elements allocated in array
+ * @count: number of elements currently used in array
+ * @add: minimum number of additional elements to support in array
+ *
+ * If 'count' + 'add' is larger than '*allocptr', then resize the
+ * block of memory in 'ptrptr' to be an array of at least 'count' +
+ * 'add' elements, each 'size' bytes in length. Update 'ptrptr' and
+ * 'allocptr' with the details of the newly allocated memory. On
+ * failure, 'ptrptr' and 'allocptr' are not changed. Any newly
+ * allocated memory in 'ptrptr' is zero-filled.
+ *
+ * Returns -1 on failure to allocate, zero on success
+ */
+int virResizeN(void *ptrptr, size_t size, size_t *allocptr, size_t count,
+               size_t add)
+{
+    size_t delta;
+
+    if (count + add < count) {
+        errno = ENOMEM;
+        return -1;
+    }
+    if (count + add <= *allocptr)
+        return 0;
+
+    delta = count + add - *allocptr;
+    if (delta < *allocptr / 2)
+        delta = *allocptr / 2;
+    return virExpandN(ptrptr, size, allocptr, delta);
+}
+
+/**
+ * virShrinkN:
+ * @ptrptr: pointer to pointer for address of allocated memory
+ * @size: number of bytes per element
+ * @countptr: pointer to number of elements in array
+ * @toremove: number of elements to remove
+ *
+ * Resize the block of memory in 'ptrptr' to be an array of
+ * '*countptr' - 'toremove' elements, each 'size' bytes in length.
+ * Update 'ptrptr' and 'countptr'  with the details of the newly
+ * allocated memory. If 'toremove' is larger than 'countptr', free
+ * the entire array.
+ */
+void virShrinkN(void *ptrptr, size_t size, size_t *countptr, size_t toremove)
+{
+    if (toremove < *countptr)
+        ignore_value(virReallocN(ptrptr, size, *countptr -= toremove));
+    else {
+        virFree(ptrptr);
+        *countptr = 0;
+    }
+}
+
+/**
+ * virInsertElementsN:
+ * @ptrptr:   pointer to hold address of allocated memory
+ * @size:     the size of one element in bytes
+ * @at:       index within array where new elements should be added
+ * @countptr: variable tracking number of elements currently allocated
+ * @add:      number of elements to add
+ * @newelems: pointer to array of one or more new elements to move into
+ *            place (the originals will be zeroed out if successful
+ *            and if clearOriginal is true)
+ * @clearOriginal: false if the new item in the array should be copied
+ *            from the original, and the original left intact.
+ *            true if the original should be 0'd out on success.
+ * @inPlace:  false if we should expand the allocated memory before
+ *            moving, true if we should assume someone else *has
+ *            already* done that.
+ *
+ * Re-allocate an array of *countptr elements, each sizeof(*ptrptr) bytes
+ * long, to be *countptr+add elements long, then appropriately move
+ * the elements starting at ptrptr[at] up by add elements, copy the
+ * items from newelems into ptrptr[at], then store the address of
+ * allocated memory in *ptrptr and the new size in *countptr.  If
+ * newelems is NULL, the new elements at ptrptr[at] are instead filled
+ * with zero.
+ *
+ * Returns -1 on failure, 0 on success
+ */
+int
+virInsertElementsN(void *ptrptr, size_t size, size_t at,
+                   size_t *countptr,
+                   size_t add, void *newelems,
+                   bool clearOriginal, bool inPlace)
+{
+    if (at > *countptr) {
+        VIR_WARN("out of bounds index - count %zu at %zu add %zu",
+                 *countptr, at, add);
+        return -1;
+    }
+
+    if (inPlace) {
+        *countptr += add;
+    } else if (virExpandN(ptrptr, size, countptr, add) < 0) {
+        return -1;
+    }
+
+    /* memory was successfully re-allocated. Move up all elements from
+     * ptrptr[at] to the end (if we're not "inserting" at the end
+     * already), memcpy in the new elements, and clear the elements
+     * from their original location. Remember that *countptr has
+     * already been updated with new element count!
+     */
+    if (at < *countptr - add) {
+        memmove(*(char**)ptrptr + (size * (at + add)),
+                *(char**)ptrptr + (size * at),
+                size * (*countptr - add - at));
+    }
+
+    if (newelems) {
+        memcpy(*(char**)ptrptr + (size * at), newelems, size * add);
+        if (clearOriginal)
+           memset((char*)newelems, 0, size * add);
+    } else if (inPlace || (at < *countptr - add)) {
+        /* NB: if inPlace, assume memory at the end wasn't initialized */
+        memset(*(char**)ptrptr + (size * at), 0, size * add);
+    }
+
+    return 0;
+}
+
+/**
+ * virDeleteElementsN:
+ * @ptrptr:   pointer to hold address of allocated memory
+ * @size:     the size of one element in bytes
+ * @at:       index within array where new elements should be deleted
+ * @countptr: variable tracking number of elements currently allocated
+ * @remove:   number of elements to remove
+ * @inPlace:  false if we should shrink the allocated memory when done,
+ *            true if we should assume someone else will do that.
+ *
+ * Re-allocate an array of *countptr elements, each sizeof(*ptrptr)
+ * bytes long, to be *countptr-remove elements long, then store the
+ * address of allocated memory in *ptrptr and the new size in *countptr.
+ * If *countptr <= remove, the entire array is freed.
+ *
+ * Returns -1 on failure, 0 on success
+ */
+int
+virDeleteElementsN(void *ptrptr, size_t size, size_t at,
+                   size_t *countptr, size_t remove,
+                   bool inPlace)
+{
+    if (at + remove > *countptr) {
+        VIR_WARN("out of bounds index - count %zu at %zu remove %zu",
+                 *countptr, at, remove);
+        return -1;
+    }
+
+    /* First move down the elements at the end that won't be deleted,
+     * then realloc. We assume that the items being deleted have
+     * already been cleared.
+    */
+    memmove(*(char**)ptrptr + (size * at),
+            *(char**)ptrptr + (size * (at + remove)),
+            size * (*countptr - remove - at));
+    if (inPlace)
+        *countptr -= remove;
+    else
+        virShrinkN(ptrptr, size, countptr, remove);
+    return 0;
+}
+
+/**
+ * Vir_Alloc_Var:
+ * @ptrptr: pointer to hold address of allocated memory
+ * @struct_size: size of initial struct
+ * @element_size: size of array elements
+ * @count: number of array elements to allocate
+ *
+ * Allocate struct_size bytes plus an array of 'count' elements, each
+ * of size element_size.  This sort of allocation is useful for
+ * receiving the data of certain ioctls and other APIs which return a
+ * struct in which the last element is an array of undefined length.
+ * The caller of this type of API is expected to know the length of
+ * the array that will be returned and allocate a suitable buffer to
+ * contain the returned data.  C99 refers to these variable length
+ * objects as structs containing flexible array members.
+ *
+ * Returns -1 on failure, 0 on success
+ */
+int virAllocVar(void *ptrptr, size_t struct_size, size_t element_size, size_t count)
+{
+    size_t alloc_size = 0;
+
+#if TEST_OOM
+    if (virAllocTestFail())
+        return -1;
+#endif
+
+    if (VIR_ALLOC_VAR_OVERSIZED(struct_size, count, element_size)) {
+        errno = ENOMEM;
+        return -1;
+    }
+
+    alloc_size = struct_size + (element_size * count);
+    *(void **)ptrptr = calloc(1, alloc_size);
+    if (*(void **)ptrptr == NULL)
+        return -1;
+    return 0;
+}
+
+
+/**
+ * virFree:
+ * @ptrptr: pointer to pointer for address of memory to be freed
+ *
+ * Release the chunk of memory in the pointer pointed to by
+ * the 'ptrptr' variable. After release, 'ptrptr' will be
+ * updated to point to NULL.
+ */
+void virFree(void *ptrptr)
+{
+    int save_errno = errno;
+
+    free(*(void**)ptrptr);
+    *(void**)ptrptr = NULL;
+    errno = save_errno;
+}
diff --git a/src/util/viralloc.h b/src/util/viralloc.h
new file mode 100644
index 0000000..8398105
--- /dev/null
+++ b/src/util/viralloc.h
@@ -0,0 +1,380 @@
+/*
+ * memory.c: safer memory allocation
+ *
+ * Copyright (C) 2010-2012 Red Hat, Inc.
+ * Copyright (C) 2008 Daniel P. Berrange
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+
+#ifndef __VIR_MEMORY_H_
+# define __VIR_MEMORY_H_
+
+# include "internal.h"
+
+/* Return 1 if an array of N objects, each of size S, cannot exist due
+   to size arithmetic overflow.  S must be positive and N must be
+   nonnegative.  This is a macro, not an inline function, so that it
+   works correctly even when SIZE_MAX < N.
+
+   By gnulib convention, SIZE_MAX represents overflow in size
+   calculations, so the conservative dividend to use here is
+   SIZE_MAX - 1, since SIZE_MAX might represent an overflowed value.
+   However, malloc (SIZE_MAX) fails on all known hosts where
+   sizeof(ptrdiff_t) <= sizeof(size_t), so do not bother to test for
+   exactly-SIZE_MAX allocations on such hosts; this avoids a test and
+   branch when S is known to be 1.  */
+# ifndef xalloc_oversized
+#  define xalloc_oversized(n, s) \
+    ((size_t) (sizeof(ptrdiff_t) <= sizeof(size_t) ? -1 : -2) / (s) < (n))
+# endif
+
+
+
+/* Don't call these directly - use the macros below */
+int virAlloc(void *ptrptr, size_t size) ATTRIBUTE_RETURN_CHECK
+    ATTRIBUTE_NONNULL(1);
+int virAllocN(void *ptrptr, size_t size, size_t count) ATTRIBUTE_RETURN_CHECK
+    ATTRIBUTE_NONNULL(1);
+int virReallocN(void *ptrptr, size_t size, size_t count) ATTRIBUTE_RETURN_CHECK
+    ATTRIBUTE_NONNULL(1);
+int virExpandN(void *ptrptr, size_t size, size_t *count, size_t add)
+    ATTRIBUTE_RETURN_CHECK ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3);
+int virResizeN(void *ptrptr, size_t size, size_t *alloc, size_t count,
+               size_t desired)
+    ATTRIBUTE_RETURN_CHECK ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3);
+void virShrinkN(void *ptrptr, size_t size, size_t *count, size_t toremove)
+    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3);
+int virInsertElementsN(void *ptrptr, size_t size, size_t at, size_t *countptr,
+                       size_t add, void *newelem,
+                       bool clearOriginal, bool inPlace)
+    ATTRIBUTE_RETURN_CHECK ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4);
+int virDeleteElementsN(void *ptrptr, size_t size, size_t at, size_t *countptr,
+                       size_t remove, bool inPlace)
+    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4);
+int virAllocVar(void *ptrptr,
+                size_t struct_size,
+                size_t element_size,
+                size_t count) ATTRIBUTE_RETURN_CHECK ATTRIBUTE_NONNULL(1);
+void virFree(void *ptrptr) ATTRIBUTE_NONNULL(1);
+
+/**
+ * VIR_ALLOC:
+ * @ptr: pointer to hold address of allocated memory
+ *
+ * Allocate sizeof(*ptr) bytes of memory and store
+ * the address of allocated memory in 'ptr'. Fill the
+ * newly allocated memory with zeros.
+ *
+ * Returns -1 on failure, 0 on success
+ */
+# define VIR_ALLOC(ptr) virAlloc(&(ptr), sizeof(*(ptr)))
+
+/**
+ * VIR_ALLOC_N:
+ * @ptr: pointer to hold address of allocated memory
+ * @count: number of elements to allocate
+ *
+ * Allocate an array of 'count' elements, each sizeof(*ptr)
+ * bytes long and store the address of allocated memory in
+ * 'ptr'. Fill the newly allocated memory with zeros.
+ *
+ * Returns -1 on failure, 0 on success
+ */
+# define VIR_ALLOC_N(ptr, count) virAllocN(&(ptr), sizeof(*(ptr)), (count))
+
+/**
+ * VIR_REALLOC_N:
+ * @ptr: pointer to hold address of allocated memory
+ * @count: number of elements to allocate
+ *
+ * Re-allocate an array of 'count' elements, each sizeof(*ptr)
+ * bytes long and store the address of allocated memory in
+ * 'ptr'. If 'ptr' grew, the added memory is uninitialized.
+ *
+ * Returns -1 on failure, 0 on success
+ */
+# define VIR_REALLOC_N(ptr, count) virReallocN(&(ptr), sizeof(*(ptr)), (count))
+
+/**
+ * VIR_EXPAND_N:
+ * @ptr: pointer to hold address of allocated memory
+ * @count: variable tracking number of elements currently allocated
+ * @add: number of elements to add
+ *
+ * Re-allocate an array of 'count' elements, each sizeof(*ptr)
+ * bytes long, to be 'count' + 'add' elements long, then store the
+ * address of allocated memory in 'ptr' and the new size in 'count'.
+ * The new elements are filled with zero.
+ *
+ * Returns -1 on failure, 0 on success
+ */
+# define VIR_EXPAND_N(ptr, count, add) \
+    virExpandN(&(ptr), sizeof(*(ptr)), &(count), add)
+
+/**
+ * VIR_RESIZE_N:
+ * @ptr: pointer to hold address of allocated memory
+ * @alloc: variable tracking number of elements currently allocated
+ * @count: number of elements currently in use
+ * @add: minimum number of elements to additionally support
+ *
+ * Blindly using VIR_EXPAND_N(array, alloc, 1) in a loop scales
+ * quadratically, because every iteration must copy contents from
+ * all prior iterations.  But amortized linear scaling can be achieved
+ * by tracking allocation size separately from the number of used
+ * elements, and growing geometrically only as needed.
+ *
+ * If 'count' + 'add' is larger than 'alloc', then geometrically reallocate
+ * the array of 'alloc' elements, each sizeof(*ptr) bytes long, and store
+ * the address of allocated memory in 'ptr' and the new size in 'alloc'.
+ * The new elements are filled with zero.
+ *
+ * Returns -1 on failure, 0 on success
+ */
+# define VIR_RESIZE_N(ptr, alloc, count, add) \
+    virResizeN(&(ptr), sizeof(*(ptr)), &(alloc), count, add)
+
+/**
+ * VIR_SHRINK_N:
+ * @ptr: pointer to hold address of allocated memory
+ * @count: variable tracking number of elements currently allocated
+ * @remove: number of elements to remove
+ *
+ * Re-allocate an array of 'count' elements, each sizeof(*ptr)
+ * bytes long, to be 'count' - 'remove' elements long, then store the
+ * address of allocated memory in 'ptr' and the new size in 'count'.
+ * If 'count' <= 'remove', the entire array is freed.
+ *
+ * No return value.
+ */
+# define VIR_SHRINK_N(ptr, count, remove) \
+    virShrinkN(&(ptr), sizeof(*(ptr)), &(count), remove)
+
+/*
+ * VIR_TYPEMATCH:
+ *
+ * The following macro seems a bit cryptic, so it needs a thorough
+ * explanation. Its purpose is to check for assignment compatibility
+ * and identical size between two values without creating any side
+ * effects (by doing something silly like actually assigning one to
+ * the other). Note that it takes advantage of the C89-guaranteed
+ * property of sizeof() - it cannot have any side effects, so anything
+ * that happens inside sizeof() will not have any effect at runtime.
+ *
+ * VIR_TYPEMATCH evaluates to "1" if the two passed values are both
+ * assignment-compatible and the same size, and otherwise generates a
+ * compile-time error. It determines the result by performing the
+ * following three operations:
+ *
+ *    * sizeof(*(a) = *(b)) assures that *a and *b are
+ *      assignment-compatible (they may still have a different size
+ *      though! e.g. longVar = intVar) (If not, there is a compile-time
+ *      error. If so, the result of that subexpression is sizeof(*(a)),
+ *      i.e. one element of the array)
+ *
+ *    * sizeof(*(a) = *(b)) == sizeof(*(b)) checks if *a and *b are also
+ *      of the same size (so that, e.g. you don't accidentally copy an
+ *      int plus the random bytes following it into an array of long). It
+ *      evaluates to 1 if they are the same, and 0 otherwise.
+ *
+ *    * sizeof(char[2 * (result of previous step) - 1]) evaluates to 1
+ *      if the previous step was successful (char [(2*1) - 1] i.e.
+ *      char[1]), or generates a compile error if it wasn't successful
+ *      (char[2*0 -1] i.e. char[-1], which isn't valid in C).
+ *
+ * So VIR_TYPECHECK(a, b) will either abort the compile with an error,
+ * or evaluate to "1", and in the meantime check that we've actually
+ * added the correct &'s and/or *'s to the arguments. (Whew!)
+*/
+# define VIR_TYPEMATCH(a, b) \
+    sizeof(char[2 * (sizeof(*(a) = *(b)) == sizeof(*(b))) - 1])
+
+/**
+ * VIR_INSERT_ELEMENT:
+ * @ptr:     pointer to array of objects (*not* ptr to ptr)
+ * @at:      index within array where new elements should be added
+ * @count:   variable tracking number of elements currently allocated
+ * @newelem: the new element to move into place (*not* a pointer to
+ *           the element, but the element itself).
+ *           (the original will be zeroed out if successful)
+ *
+ * Re-allocate an array of 'count' elements, each sizeof(*ptr) bytes
+ * long, to be 'count' + 1 elements long, then appropriately move
+ * the elements starting at ptr[at] up by 1 element, copy the
+ * item 'newelem' into ptr[at], then store the address of
+ * allocated memory in 'ptr' and the new size in 'count'.
+ *
+ * VIR_INSERT_ELEMENT_COPY is identical, but doesn't clear out the
+ *   original element to 0 on success, so there are two copies of the
+ *   element. This is useful if the "element" is actually just a
+ *   pointer to the real data, and you want to maintain a reference to
+ *   it for use after the insert is completed; but if the "element" is
+ *   an object that points to other allocated memory, having multiple
+ *   copies can cause problems (e.g. double free).
+ *
+ * VIR_INSERT_ELEMENT_*INPLACE are identical, but assume any necessary
+ *   memory re-allocation has already been done.
+ *
+ * VIR_INSERT_ELEMENT_* all need to send "1" as the "add" argument to
+ * virInsertElementsN (which has the currently-unused capability of
+ * inserting multiple items at once). We use this to our advantage by
+ * replacing it with VIR_TYPECHECK(ptr, &newelem) so that we can be
+ * assured ptr and &newelem are of compatible types.
+ *
+ * Returns -1 on failure, 0 on success
+ *
+ *
+ */
+# define VIR_INSERT_ELEMENT(ptr, at, count, newelem) \
+    virInsertElementsN(&(ptr), sizeof(*(ptr)), at, &(count),    \
+                       VIR_TYPEMATCH(ptr, &(newelem)), &(newelem), true, false)
+# define VIR_INSERT_ELEMENT_COPY(ptr, at, count, newelem) \
+    virInsertElementsN(&(ptr), sizeof(*(ptr)), at, &(count), \
+                       VIR_TYPEMATCH(ptr, &(newelem)), &(newelem), false, false)
+# define VIR_INSERT_ELEMENT_INPLACE(ptr, at, count, newelem) \
+    virInsertElementsN(&(ptr), sizeof(*(ptr)), at, &(count), \
+                       VIR_TYPEMATCH(ptr, &(newelem)), &(newelem), true, true)
+# define VIR_INSERT_ELEMENT_COPY_INPLACE(ptr, at, count, newelem) \
+    virInsertElementsN(&(ptr), sizeof(*(ptr)), at, &(count), \
+                       VIR_TYPEMATCH(ptr, &(newelem)), &(newelem), false, true)
+
+/**
+ * VIR_APPEND_ELEMENT:
+ * @ptr:     pointer to array of objects (*not* ptr to ptr)
+ * @count:   variable tracking number of elements currently allocated
+ * @newelem: the new element to move into place (*not* a pointer to
+ *           the element, but the element itself).
+ *           (the original will be zeroed out if successful)
+ *
+ * Re-allocate an array of 'count' elements, each sizeof(*ptr) bytes
+ * long, to be 'count' + 1 elements long, then copy the item from
+ * 'newelem' into ptr[count+1], and store the address of allocated
+ * memory in 'ptr' and the new size in 'count'. If 'newelem' is NULL,
+ * the new element at ptr[at] is instead filled with zero.
+ *
+ * VIR_APPEND_ELEMENT_COPY is identical, but doesn't clear out the
+ *   original element to 0 on success, so there are two copies of the
+ *   element. This is useful if the "element" is actually just a
+ *   pointer to the real data, and you want to maintain a reference to
+ *   it for use after the append is completed; but if the "element" is
+ *   an object that points to other allocated memory, having multiple
+ *   copies can cause problems (e.g. double free).
+ *
+ * VIR_APPEND_ELEMENT_*INPLACE are identical, but assume any
+ *   necessary memory re-allocation has already been done.
+ *
+ * VIR_APPEND_ELEMENT_* all need to send "1" as the "add" argument to
+ * virInsertElementsN (which has the currently-unused capability of
+ * inserting multiple items at once). We use this to our advantage by
+ * replacing it with VIR_TYPECHECK(ptr, &newelem) so that we can be
+ * assured ptr and &newelem are of compatible types.
+ *
+ * Returns -1 on failure, 0 on success
+ *
+ *
+ */
+# define VIR_APPEND_ELEMENT(ptr, count, newelem) \
+    virInsertElementsN(&(ptr), sizeof(*(ptr)), count, &(count),  \
+                       VIR_TYPEMATCH(ptr, &(newelem)), &(newelem), true, false)
+# define VIR_APPEND_ELEMENT_COPY(ptr, count, newelem) \
+    virInsertElementsN(&(ptr), sizeof(*(ptr)), count, &(count),  \
+                       VIR_TYPEMATCH(ptr, &(newelem)), &(newelem), false, false)
+# define VIR_APPEND_ELEMENT_INPLACE(ptr, count, newelem) \
+    virInsertElementsN(&(ptr), sizeof(*(ptr)), count, &(count),  \
+                       VIR_TYPEMATCH(ptr, &(newelem)), &(newelem), true, true)
+# define VIR_APPEND_ELEMENT_COPY_INPLACE(ptr, count, newelem) \
+    virInsertElementsN(&(ptr), sizeof(*(ptr)), count, &(count),  \
+                       VIR_TYPEMATCH(ptr, &(newelem)), &(newelem), false, true)
+
+/**
+ * VIR_DELETE_ELEMENT:
+ * @ptr:   pointer to array of objects (*not* ptr to ptr)
+ * @at:    index within array where new elements should be deleted
+ * @count: variable tracking number of elements currently allocated
+ *
+ * Re-allocate an array of 'count' elements, each sizeof(*ptr)
+ * bytes long, to be 'count' - 1 elements long, then store the
+ * address of allocated memory in 'ptr' and the new size in 'count'.
+ * If 'count' <= 1, the entire array is freed.
+ *
+ * VIR_DELETE_ELEMENT_INPLACE is identical, but assumes any
+ *   necessary memory re-allocation will be done later.
+ *
+ * Returns -1 on failure, 0 on success
+ */
+# define VIR_DELETE_ELEMENT(ptr, at, count) \
+    virDeleteElementsN(&(ptr), sizeof(*(ptr)), at, &(count), 1, false)
+# define VIR_DELETE_ELEMENT_INPLACE(ptr, at, count) \
+    virDeleteElementsN(&(ptr), sizeof(*(ptr)), at, &(count), 1, true)
+
+/*
+ * VIR_ALLOC_VAR_OVERSIZED:
+ * @M: size of base structure
+ * @N: number of array elements in trailing array
+ * @S: size of trailing array elements
+ *
+ * Check to make sure that the requested allocation will not cause
+ * arithmetic overflow in the allocation size.  The check is
+ * essentially the same as that in gnulib's xalloc_oversized.
+ */
+# define VIR_ALLOC_VAR_OVERSIZED(M, N, S) ((((size_t)-1) - (M)) / (S) < (N))
+
+/**
+ * VIR_ALLOC_VAR:
+ * @ptr: pointer to hold address of allocated memory
+ * @type: element type of trailing array
+ * @count: number of array elements to allocate
+ *
+ * Allocate sizeof(*ptr) bytes plus an array of 'count' elements, each
+ * sizeof('type').  This sort of allocation is useful for receiving
+ * the data of certain ioctls and other APIs which return a struct in
+ * which the last element is an array of undefined length.  The caller
+ * of this type of API is expected to know the length of the array
+ * that will be returned and allocate a suitable buffer to contain the
+ * returned data.  C99 refers to these variable length objects as
+ * structs containing flexible array members.
+
+ * Returns -1 on failure, 0 on success
+ */
+# define VIR_ALLOC_VAR(ptr, type, count) \
+    virAllocVar(&(ptr), sizeof(*(ptr)), sizeof(type), (count))
+
+/**
+ * VIR_FREE:
+ * @ptr: pointer holding address to be freed
+ *
+ * Free the memory stored in 'ptr' and update to point
+ * to NULL.
+ */
+/* The ternary ensures that ptr is a pointer and not an integer type,
+ * while evaluating ptr only once.  For now, we intentionally cast
+ * away const, since a number of callers safely pass const char *.
+ */
+# define VIR_FREE(ptr) virFree((void *) (1 ? (const void *) &(ptr) : (ptr)))
+
+
+# if TEST_OOM
+void virAllocTestInit(void);
+int virAllocTestCount(void);
+void virAllocTestOOM(int n, int m);
+void virAllocTestHook(void (*func)(int, void*), void *data);
+# endif
+
+
+
+#endif /* __VIR_MEMORY_H_ */
diff --git a/src/util/viraudit.c b/src/util/viraudit.c
index c4e0129..a807b76 100644
--- a/src/util/viraudit.c
+++ b/src/util/viraudit.c
@@ -32,7 +32,7 @@
 #include "viraudit.h"
 #include "util.h"
 #include "virfile.h"
-#include "memory.h"
+#include "viralloc.h"
 
 /* Provide the macros in case the header file is old.
    FIXME: should be removed. */
diff --git a/src/util/virauth.c b/src/util/virauth.c
index a1bad6a..c4c5676 100644
--- a/src/util/virauth.c
+++ b/src/util/virauth.c
@@ -26,7 +26,7 @@
 
 #include "virauth.h"
 #include "util.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 #include "datatypes.h"
 #include "virterror_internal.h"
diff --git a/src/util/virauthconfig.c b/src/util/virauthconfig.c
index 46ba040..a0f0be5 100644
--- a/src/util/virauthconfig.c
+++ b/src/util/virauthconfig.c
@@ -25,7 +25,7 @@
 #include "virauthconfig.h"
 
 #include "virkeyfile.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "util.h"
 #include "virlog.h"
 #include "virterror_internal.h"
diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c
index 41b74d4..cb9606b 100644
--- a/src/util/virbitmap.c
+++ b/src/util/virbitmap.c
@@ -31,7 +31,7 @@
 #include <sys/types.h>
 
 #include "virbitmap.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virbuffer.h"
 #include "util.h"
 #include "c-ctype.h"
diff --git a/src/util/virbuffer.c b/src/util/virbuffer.c
index e4409c6..6fcb7d6 100644
--- a/src/util/virbuffer.c
+++ b/src/util/virbuffer.c
@@ -31,7 +31,7 @@
 #define __VIR_BUFFER_C__
 
 #include "virbuffer.h"
-#include "memory.h"
+#include "viralloc.h"
 
 
 /* If adding more fields, ensure to edit buf.h to match
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index 82e6613..5c628cc 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -39,7 +39,7 @@
 
 #include "internal.h"
 #include "util.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "vircgroup.h"
 #include "virlog.h"
 #include "virfile.h"
diff --git a/src/util/vircommand.c b/src/util/vircommand.c
index 7bed04e..6e17a8d 100644
--- a/src/util/vircommand.c
+++ b/src/util/vircommand.c
@@ -34,7 +34,7 @@
 #endif
 
 #include "vircommand.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virterror_internal.h"
 #include "util.h"
 #include "virlog.h"
diff --git a/src/util/virconf.c b/src/util/virconf.c
index c12a0bb..2f6d60e 100644
--- a/src/util/virconf.c
+++ b/src/util/virconf.c
@@ -36,7 +36,7 @@
 #include "util.h"
 #include "c-ctype.h"
 #include "virlog.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virfile.h"
 
 #define VIR_FROM_THIS VIR_FROM_CONF
diff --git a/src/util/virdbus.c b/src/util/virdbus.c
index b6c6642..34c46b2 100644
--- a/src/util/virdbus.c
+++ b/src/util/virdbus.c
@@ -22,7 +22,7 @@
 #include <config.h>
 
 #include "virdbus.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virterror_internal.h"
 #include "virlog.h"
 #include "threads.h"
diff --git a/src/util/virdnsmasq.c b/src/util/virdnsmasq.c
index 7bb42fc..918610a 100644
--- a/src/util/virdnsmasq.c
+++ b/src/util/virdnsmasq.c
@@ -43,7 +43,7 @@
 #include "virdnsmasq.h"
 #include "util.h"
 #include "vircommand.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virterror_internal.h"
 #include "virlog.h"
 #include "virfile.h"
diff --git a/src/util/virebtables.c b/src/util/virebtables.c
index 8333c38..1beb085 100644
--- a/src/util/virebtables.c
+++ b/src/util/virebtables.c
@@ -42,7 +42,7 @@
 #include "internal.h"
 #include "virebtables.h"
 #include "vircommand.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virterror_internal.h"
 #include "virlog.h"
 #include "threads.h"
diff --git a/src/util/vireventpoll.c b/src/util/vireventpoll.c
index 0256d83..cf4dc41 100644
--- a/src/util/vireventpoll.c
+++ b/src/util/vireventpoll.c
@@ -34,7 +34,7 @@
 #include "threads.h"
 #include "virlog.h"
 #include "vireventpoll.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "util.h"
 #include "virfile.h"
 #include "virterror_internal.h"
diff --git a/src/util/virfile.c b/src/util/virfile.c
index 30294a2..f20ce64 100644
--- a/src/util/virfile.c
+++ b/src/util/virfile.c
@@ -39,7 +39,7 @@
 
 #include "vircommand.h"
 #include "configmake.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virterror_internal.h"
 #include "virlog.h"
 
diff --git a/src/util/virhash.c b/src/util/virhash.c
index 077abca..a1234c4 100644
--- a/src/util/virhash.c
+++ b/src/util/virhash.c
@@ -26,7 +26,7 @@
 
 #include "virterror_internal.h"
 #include "virhash.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 #include "virhashcode.h"
 #include "virrandom.h"
diff --git a/src/util/virhooks.c b/src/util/virhooks.c
index 2e8ecf2..ad3a371 100644
--- a/src/util/virhooks.c
+++ b/src/util/virhooks.c
@@ -34,7 +34,7 @@
 #include "virhooks.h"
 #include "util.h"
 #include "virlog.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virfile.h"
 #include "configmake.h"
 #include "vircommand.h"
diff --git a/src/util/virinitctl.c b/src/util/virinitctl.c
index e8949af..91a948f 100644
--- a/src/util/virinitctl.c
+++ b/src/util/virinitctl.c
@@ -30,7 +30,7 @@
 #include "virinitctl.h"
 #include "virterror_internal.h"
 #include "util.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virfile.h"
 
 #define VIR_FROM_THIS VIR_FROM_INITCTL
diff --git a/src/util/viriptables.c b/src/util/viriptables.c
index ee3e9a0..178580d 100644
--- a/src/util/viriptables.c
+++ b/src/util/viriptables.c
@@ -40,7 +40,7 @@
 #include "internal.h"
 #include "viriptables.h"
 #include "vircommand.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virterror_internal.h"
 #include "virlog.h"
 #include "threads.h"
diff --git a/src/util/virjson.c b/src/util/virjson.c
index 18a28ba..4fa5363 100644
--- a/src/util/virjson.c
+++ b/src/util/virjson.c
@@ -24,7 +24,7 @@
 #include <config.h>
 
 #include "virjson.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virterror_internal.h"
 #include "virlog.h"
 #include "util.h"
diff --git a/src/util/virkeyfile.c b/src/util/virkeyfile.c
index b43b92d..fc61cf5 100644
--- a/src/util/virkeyfile.c
+++ b/src/util/virkeyfile.c
@@ -27,7 +27,7 @@
 
 #include "c-ctype.h"
 #include "virlog.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "util.h"
 #include "virhash.h"
 #include "virkeyfile.h"
diff --git a/src/util/virlockspace.c b/src/util/virlockspace.c
index b652294..509b162 100644
--- a/src/util/virlockspace.c
+++ b/src/util/virlockspace.c
@@ -23,7 +23,7 @@
 
 #include "virlockspace.h"
 #include "virlog.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virterror_internal.h"
 #include "util.h"
 #include "virfile.h"
diff --git a/src/util/virlog.c b/src/util/virlog.c
index d179de2..cb15a22 100644
--- a/src/util/virlog.c
+++ b/src/util/virlog.c
@@ -42,7 +42,7 @@
 
 #include "virterror_internal.h"
 #include "virlog.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "util.h"
 #include "virbuffer.h"
 #include "threads.h"
diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
index a1d1c12..88a2e4b 100644
--- a/src/util/virnetdev.c
+++ b/src/util/virnetdev.c
@@ -27,7 +27,7 @@
 #include "virfile.h"
 #include "virterror_internal.h"
 #include "vircommand.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "pci.h"
 #include "virlog.h"
 
diff --git a/src/util/virnetdevbandwidth.c b/src/util/virnetdevbandwidth.c
index bd75a9d..9cc8858 100644
--- a/src/util/virnetdevbandwidth.c
+++ b/src/util/virnetdevbandwidth.c
@@ -24,7 +24,7 @@
 
 #include "virnetdevbandwidth.h"
 #include "vircommand.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virterror_internal.h"
 
 #define VIR_FROM_THIS VIR_FROM_NONE
diff --git a/src/util/virnetdevbridge.c b/src/util/virnetdevbridge.c
index 2c4a9eb..eb341a2 100644
--- a/src/util/virnetdevbridge.c
+++ b/src/util/virnetdevbridge.c
@@ -26,7 +26,7 @@
 #include "virterror_internal.h"
 #include "util.h"
 #include "virfile.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "intprops.h"
 
 #include <sys/ioctl.h>
diff --git a/src/util/virnetdevmacvlan.c b/src/util/virnetdevmacvlan.c
index 8d2574c..0f7107b 100644
--- a/src/util/virnetdevmacvlan.c
+++ b/src/util/virnetdevmacvlan.c
@@ -56,7 +56,7 @@ VIR_ENUM_IMPL(virNetDevMacVLanMode, VIR_NETDEV_MACVLAN_MODE_LAST,
 #  define MACVLAN_MODE_PASSTHRU 8
 # endif
 
-# include "memory.h"
+# include "viralloc.h"
 # include "virlog.h"
 # include "uuid.h"
 # include "virfile.h"
diff --git a/src/util/virnetdevopenvswitch.c b/src/util/virnetdevopenvswitch.c
index 983a240..b876a4e 100644
--- a/src/util/virnetdevopenvswitch.c
+++ b/src/util/virnetdevopenvswitch.c
@@ -25,7 +25,7 @@
 
 #include "virnetdevopenvswitch.h"
 #include "vircommand.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virterror_internal.h"
 #include "virmacaddr.h"
 
diff --git a/src/util/virnetdevtap.c b/src/util/virnetdevtap.c
index 644e9a4..339d636 100644
--- a/src/util/virnetdevtap.c
+++ b/src/util/virnetdevtap.c
@@ -30,7 +30,7 @@
 #include "virterror_internal.h"
 #include "virfile.h"
 #include "virterror_internal.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 #include "util.h"
 
diff --git a/src/util/virnetdevveth.c b/src/util/virnetdevveth.c
index 630b7c9..c6568b7 100644
--- a/src/util/virnetdevveth.c
+++ b/src/util/virnetdevveth.c
@@ -26,7 +26,7 @@
 #include <sys/wait.h>
 
 #include "virnetdevveth.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 #include "vircommand.h"
 #include "virterror_internal.h"
diff --git a/src/util/virnetdevvlan.c b/src/util/virnetdevvlan.c
index 7a6ff9b..53c6b65 100644
--- a/src/util/virnetdevvlan.c
+++ b/src/util/virnetdevvlan.c
@@ -24,7 +24,7 @@
 #include "internal.h"
 #include "virterror_internal.h"
 #include "virnetdevvlan.h"
-#include "memory.h"
+#include "viralloc.h"
 
 #define VIR_FROM_THIS VIR_FROM_NONE
 
diff --git a/src/util/virnetdevvportprofile.c b/src/util/virnetdevvportprofile.c
index 834b9b9..60acabd 100644
--- a/src/util/virnetdevvportprofile.c
+++ b/src/util/virnetdevvportprofile.c
@@ -24,7 +24,7 @@
 
 #include "virnetdevvportprofile.h"
 #include "virterror_internal.h"
-#include "memory.h"
+#include "viralloc.h"
 
 #define VIR_FROM_THIS VIR_FROM_NET
 
diff --git a/src/util/virnetlink.c b/src/util/virnetlink.c
index 830e9b9..b132d9a 100644
--- a/src/util/virnetlink.c
+++ b/src/util/virnetlink.c
@@ -37,7 +37,7 @@
 
 #include "virnetlink.h"
 #include "virlog.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "threads.h"
 #include "virmacaddr.h"
 #include "virterror_internal.h"
diff --git a/src/util/virnodesuspend.c b/src/util/virnodesuspend.c
index e37a2d6..1528cf1 100644
--- a/src/util/virnodesuspend.c
+++ b/src/util/virnodesuspend.c
@@ -26,7 +26,7 @@
 #include "threads.h"
 #include "datatypes.h"
 
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 #include "virterror_internal.h"
 
diff --git a/src/util/virobject.c b/src/util/virobject.c
index aa80cab..5cdd2e8 100644
--- a/src/util/virobject.c
+++ b/src/util/virobject.c
@@ -23,7 +23,7 @@
 
 #include "virobject.h"
 #include "threads.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "viratomic.h"
 #include "virterror_internal.h"
 #include "virlog.h"
diff --git a/src/util/virpidfile.c b/src/util/virpidfile.c
index 6ec9760..3b3322b 100644
--- a/src/util/virpidfile.c
+++ b/src/util/virpidfile.c
@@ -29,7 +29,7 @@
 
 #include "virpidfile.h"
 #include "virfile.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "util.h"
 #include "intprops.h"
 #include "virlog.h"
diff --git a/src/util/virprocess.c b/src/util/virprocess.c
index 3c0ed8a..8070b8b 100644
--- a/src/util/virprocess.c
+++ b/src/util/virprocess.c
@@ -28,7 +28,7 @@
 
 #include "virprocess.h"
 #include "virterror_internal.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 #include "util.h"
 
diff --git a/src/util/virstring.c b/src/util/virstring.c
index 228c3fb..5607b3e 100644
--- a/src/util/virstring.c
+++ b/src/util/virstring.c
@@ -22,7 +22,7 @@
 #include <config.h>
 
 #include "virstring.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virbuffer.h"
 #include "virterror_internal.h"
 
diff --git a/src/util/virterror.c b/src/util/virterror.c
index 6e3301b..ce2d837 100644
--- a/src/util/virterror.c
+++ b/src/util/virterror.c
@@ -30,7 +30,7 @@
 #include "virterror_internal.h"
 #include "datatypes.h"
 #include "virlog.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "threads.h"
 #include "util.h"
 
diff --git a/src/util/virtime.c b/src/util/virtime.c
index a2610c4..f9fc282 100644
--- a/src/util/virtime.c
+++ b/src/util/virtime.c
@@ -38,7 +38,7 @@
 
 #include "virtime.h"
 #include "util.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virterror_internal.h"
 
 #define VIR_FROM_THIS VIR_FROM_NONE
diff --git a/src/util/virtypedparam.c b/src/util/virtypedparam.c
index 7f0a44b..e08530e 100644
--- a/src/util/virtypedparam.c
+++ b/src/util/virtypedparam.c
@@ -24,7 +24,7 @@
 
 #include <stdarg.h>
 
-#include "memory.h"
+#include "viralloc.h"
 #include "util.h"
 #include "virterror_internal.h"
 
diff --git a/src/util/viruri.c b/src/util/viruri.c
index dd3b878..f48079d 100644
--- a/src/util/viruri.c
+++ b/src/util/viruri.c
@@ -22,7 +22,7 @@
 
 #include "viruri.h"
 
-#include "memory.h"
+#include "viralloc.h"
 #include "util.h"
 #include "virterror_internal.h"
 #include "virbuffer.h"
diff --git a/src/util/virusb.c b/src/util/virusb.c
index ebc1af5..9786e86 100644
--- a/src/util/virusb.c
+++ b/src/util/virusb.c
@@ -33,7 +33,7 @@
 
 #include "virusb.h"
 #include "virlog.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "util.h"
 #include "virterror_internal.h"
 
diff --git a/src/util/xml.c b/src/util/xml.c
index 5b08b1f..caf26a3 100644
--- a/src/util/xml.c
+++ b/src/util/xml.c
@@ -34,7 +34,7 @@
 #include "xml.h"
 #include "virbuffer.h"
 #include "util.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virfile.h"
 
 #define VIR_FROM_THIS VIR_FROM_XML
diff --git a/src/vbox/vbox_MSCOMGlue.c b/src/vbox/vbox_MSCOMGlue.c
index 3194b7c..cab4398 100644
--- a/src/vbox/vbox_MSCOMGlue.c
+++ b/src/vbox/vbox_MSCOMGlue.c
@@ -30,7 +30,7 @@
 #define nsCID CLSID
 
 #include "internal.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "util.h"
 #include "virlog.h"
 #include "virterror_internal.h"
diff --git a/src/vbox/vbox_XPCOMCGlue.c b/src/vbox/vbox_XPCOMCGlue.c
index 5f70283..5296127 100644
--- a/src/vbox/vbox_XPCOMCGlue.c
+++ b/src/vbox/vbox_XPCOMCGlue.c
@@ -37,7 +37,7 @@
 
 #include "vbox_XPCOMCGlue.h"
 #include "internal.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "util.h"
 #include "virlog.h"
 #include "virterror_internal.h"
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index 847af35..daa90bf 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -50,7 +50,7 @@
 #include "storage_conf.h"
 #include "storage_file.h"
 #include "uuid.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "nodeinfo.h"
 #include "virlog.h"
 #include "vbox_driver.h"
diff --git a/src/vmware/vmware_conf.c b/src/vmware/vmware_conf.c
index b32de66..7cf9bcc 100644
--- a/src/vmware/vmware_conf.c
+++ b/src/vmware/vmware_conf.c
@@ -27,7 +27,7 @@
 #include "vircommand.h"
 #include "cpu/cpu.h"
 #include "dirname.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "nodeinfo.h"
 #include "virfile.h"
 #include "uuid.h"
diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c
index d9a1333..233804e 100644
--- a/src/vmware/vmware_driver.c
+++ b/src/vmware/vmware_driver.c
@@ -27,7 +27,7 @@
 #include "virterror_internal.h"
 #include "datatypes.h"
 #include "virfile.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "util.h"
 #include "uuid.h"
 #include "vircommand.h"
diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
index e74e9ed..90496ce 100644
--- a/src/vmx/vmx.c
+++ b/src/vmx/vmx.c
@@ -28,7 +28,7 @@
 #include "internal.h"
 #include "virterror_internal.h"
 #include "virconf.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 #include "uuid.h"
 #include "vmx.h"
diff --git a/src/xen/block_stats.c b/src/xen/block_stats.c
index e50b5ff..126283b 100644
--- a/src/xen/block_stats.c
+++ b/src/xen/block_stats.c
@@ -42,7 +42,7 @@
 # include "datatypes.h"
 # include "util.h"
 # include "block_stats.h"
-# include "memory.h"
+# include "viralloc.h"
 # include "virfile.h"
 
 # define VIR_FROM_THIS VIR_FROM_STATS_LINUX
diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c
index c281c00..94df116 100644
--- a/src/xen/xen_driver.c
+++ b/src/xen/xen_driver.c
@@ -55,7 +55,7 @@
 #endif
 #include "xml.h"
 #include "util.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "node_device_conf.h"
 #include "pci.h"
 #include "uuid.h"
diff --git a/src/xen/xen_hypervisor.c b/src/xen/xen_hypervisor.c
index b094313..598ec5e 100644
--- a/src/xen/xen_hypervisor.c
+++ b/src/xen/xen_hypervisor.c
@@ -76,7 +76,7 @@
 #include "xend_internal.h"
 #include "virbuffer.h"
 #include "capabilities.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "threads.h"
 #include "virfile.h"
 #include "virnodesuspend.h"
diff --git a/src/xen/xen_inotify.c b/src/xen/xen_inotify.c
index 073663f..35a625c 100644
--- a/src/xen/xen_inotify.c
+++ b/src/xen/xen_inotify.c
@@ -30,7 +30,7 @@
 #include "virterror_internal.h"
 #include "datatypes.h"
 #include "driver.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "xen_driver.h"
 #include "virconf.h"
 #include "domain_conf.h"
diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c
index 0364f84..a4005f4 100644
--- a/src/xen/xend_internal.c
+++ b/src/xen/xend_internal.c
@@ -42,7 +42,7 @@
 #include "xen_driver.h"
 #include "xen_hypervisor.h"
 #include "xs_internal.h" /* To extract VNC port & Serial console TTY */
-#include "memory.h"
+#include "viralloc.h"
 #include "count-one-bits.h"
 #include "virfile.h"
 #include "viruri.h"
diff --git a/src/xen/xm_internal.c b/src/xen/xm_internal.c
index fc7b581..2109972 100644
--- a/src/xen/xm_internal.c
+++ b/src/xen/xm_internal.c
@@ -46,7 +46,7 @@
 #include "virbuffer.h"
 #include "uuid.h"
 #include "util.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 #include "count-one-bits.h"
 
diff --git a/src/xen/xs_internal.c b/src/xen/xs_internal.c
index 4cc82d8..e414966 100644
--- a/src/xen/xs_internal.c
+++ b/src/xen/xs_internal.c
@@ -44,7 +44,7 @@
 #include "virterror_internal.h"
 #include "datatypes.h"
 #include "driver.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 #include "uuid.h"
 #include "xen_driver.h"
diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c
index f00dcfd..0a0ac0e 100644
--- a/src/xenapi/xenapi_driver.c
+++ b/src/xenapi/xenapi_driver.c
@@ -33,7 +33,7 @@
 #include "virauth.h"
 #include "util.h"
 #include "uuid.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virbuffer.h"
 #include "viruri.h"
 #include "xenapi_driver.h"
diff --git a/src/xenapi/xenapi_utils.c b/src/xenapi/xenapi_utils.c
index 6f51100..33aa4d7 100644
--- a/src/xenapi/xenapi_utils.c
+++ b/src/xenapi/xenapi_utils.c
@@ -31,7 +31,7 @@
 #include "datatypes.h"
 #include "util.h"
 #include "uuid.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virbuffer.h"
 #include "virlog.h"
 #include "viruri.h"
diff --git a/src/xenxs/xen_sxpr.c b/src/xenxs/xen_sxpr.c
index 2aa384d..0cbc248 100644
--- a/src/xenxs/xen_sxpr.c
+++ b/src/xenxs/xen_sxpr.c
@@ -29,7 +29,7 @@
 #include "internal.h"
 #include "virterror_internal.h"
 #include "virconf.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "verify.h"
 #include "uuid.h"
 #include "virlog.h"
diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
index 7bde7ab..7d67bbe 100644
--- a/src/xenxs/xen_xm.c
+++ b/src/xenxs/xen_xm.c
@@ -28,7 +28,7 @@
 #include "internal.h"
 #include "virterror_internal.h"
 #include "virconf.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "verify.h"
 #include "uuid.h"
 #include "sexpr.h"
diff --git a/tests/commandhelper.c b/tests/commandhelper.c
index 2100aa0..3c7fef5 100644
--- a/tests/commandhelper.c
+++ b/tests/commandhelper.c
@@ -28,7 +28,7 @@
 
 #include "internal.h"
 #include "util.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virfile.h"
 #include "testutils.h"
 
diff --git a/tests/commandtest.c b/tests/commandtest.c
index f76bc54..b15c168 100644
--- a/tests/commandtest.c
+++ b/tests/commandtest.c
@@ -32,7 +32,7 @@
 #include "internal.h"
 #include "nodeinfo.h"
 #include "util.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "vircommand.h"
 #include "virfile.h"
 #include "virpidfile.h"
diff --git a/tests/conftest.c b/tests/conftest.c
index aacc526..d5467e8 100644
--- a/tests/conftest.c
+++ b/tests/conftest.c
@@ -6,7 +6,7 @@
 #include <string.h>
 #include <errno.h>
 #include "virconf.h"
-#include "memory.h"
+#include "viralloc.h"
 
 int main(int argc, char **argv)
 {
diff --git a/tests/cputest.c b/tests/cputest.c
index f6110c1..ee1a608 100644
--- a/tests/cputest.c
+++ b/tests/cputest.c
@@ -32,7 +32,7 @@
 
 #include "internal.h"
 #include "xml.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virbuffer.h"
 #include "testutils.h"
 #include "cpu_conf.h"
diff --git a/tests/esxutilstest.c b/tests/esxutilstest.c
index 201b930..b65009b 100644
--- a/tests/esxutilstest.c
+++ b/tests/esxutilstest.c
@@ -7,7 +7,7 @@
 # include <unistd.h>
 
 # include "internal.h"
-# include "memory.h"
+# include "viralloc.h"
 # include "testutils.h"
 # include "util.h"
 # include "vmx/vmx.h"
diff --git a/tests/networkxml2conftest.c b/tests/networkxml2conftest.c
index dc0e064..3979540 100644
--- a/tests/networkxml2conftest.c
+++ b/tests/networkxml2conftest.c
@@ -12,7 +12,7 @@
 #include "testutils.h"
 #include "network_conf.h"
 #include "vircommand.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "network/bridge_driver.h"
 
 static int
diff --git a/tests/openvzutilstest.c b/tests/openvzutilstest.c
index 305c7b1..80701a2 100644
--- a/tests/openvzutilstest.c
+++ b/tests/openvzutilstest.c
@@ -7,7 +7,7 @@
 # include <unistd.h>
 
 # include "internal.h"
-# include "memory.h"
+# include "viralloc.h"
 # include "testutils.h"
 # include "util.h"
 # include "openvz/openvz_conf.h"
diff --git a/tests/qemuhelptest.c b/tests/qemuhelptest.c
index caa7d64..252ad3a 100644
--- a/tests/qemuhelptest.c
+++ b/tests/qemuhelptest.c
@@ -7,7 +7,7 @@
 
 # include "testutils.h"
 # include "qemu/qemu_capabilities.h"
-# include "memory.h"
+# include "viralloc.h"
 
 struct testInfo {
     const char *name;
diff --git a/tests/qemumonitortest.c b/tests/qemumonitortest.c
index 82f861b..21a6828 100644
--- a/tests/qemumonitortest.c
+++ b/tests/qemumonitortest.c
@@ -8,7 +8,7 @@
 #ifdef WITH_QEMU
 
 # include "internal.h"
-# include "memory.h"
+# include "viralloc.h"
 # include "testutils.h"
 # include "util.h"
 # include "qemu/qemu_monitor.h"
diff --git a/tests/qemumonitortestutils.c b/tests/qemumonitortestutils.c
index e4194de..1e3f0da 100644
--- a/tests/qemumonitortestutils.c
+++ b/tests/qemumonitortestutils.c
@@ -29,7 +29,7 @@
 #include "threads.h"
 #include "qemu/qemu_monitor.h"
 #include "rpc/virnetsocket.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "util.h"
 #include "virlog.h"
 #include "virterror_internal.h"
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 1816362..27f3029 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -12,7 +12,7 @@
 
 # include "internal.h"
 # include "testutils.h"
-# include "util/memory.h"
+# include "viralloc.h"
 # include "qemu/qemu_capabilities.h"
 # include "qemu/qemu_command.h"
 # include "qemu/qemu_domain.h"
diff --git a/tests/securityselinuxtest.c b/tests/securityselinuxtest.c
index c021480..045c9c0 100644
--- a/tests/securityselinuxtest.c
+++ b/tests/securityselinuxtest.c
@@ -30,7 +30,7 @@
 
 #include "internal.h"
 #include "testutils.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "util.h"
 #include "virlog.h"
 #include "virterror_internal.h"
diff --git a/tests/sockettest.c b/tests/sockettest.c
index c6a175f..156ef45 100644
--- a/tests/sockettest.c
+++ b/tests/sockettest.c
@@ -28,7 +28,7 @@
 #include "virsocketaddr.h"
 #include "testutils.h"
 #include "virlog.h"
-#include "memory.h"
+#include "viralloc.h"
 
 static void testQuietError(void *userData ATTRIBUTE_UNUSED,
                            virErrorPtr error ATTRIBUTE_UNUSED)
diff --git a/tests/testutils.c b/tests/testutils.c
index 96e24d4..7bb88f0 100644
--- a/tests/testutils.c
+++ b/tests/testutils.c
@@ -39,7 +39,7 @@
 #include <limits.h>
 #include "testutils.h"
 #include "internal.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "util.h"
 #include "threads.h"
 #include "virterror_internal.h"
diff --git a/tests/testutils.h b/tests/testutils.h
index 82837ab..581bd3e 100644
--- a/tests/testutils.h
+++ b/tests/testutils.h
@@ -24,7 +24,7 @@
 # define __VIT_TEST_UTILS_H__
 
 # include <stdio.h>
-# include "memory.h"
+# include "viralloc.h"
 
 # define EXIT_AM_SKIP 77 /* tell Automake we're skipping a test */
 # define EXIT_AM_HARDFAIL 99 /* tell Automake that the framework is broken */
diff --git a/tests/testutilslxc.c b/tests/testutilslxc.c
index 822e518..384414b 100644
--- a/tests/testutilslxc.c
+++ b/tests/testutilslxc.c
@@ -4,7 +4,7 @@
 
 # include "testutilslxc.h"
 # include "testutils.h"
-# include "memory.h"
+# include "viralloc.h"
 # include "domain_conf.h"
 
 
diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c
index 4ff4a08..8ee3a27 100644
--- a/tests/testutilsqemu.c
+++ b/tests/testutilsqemu.c
@@ -4,7 +4,7 @@
 
 # include "testutilsqemu.h"
 # include "testutils.h"
-# include "memory.h"
+# include "viralloc.h"
 # include "cpu_conf.h"
 # include "qemu/qemu_driver.h"
 # include "qemu/qemu_domain.h"
diff --git a/tests/utiltest.c b/tests/utiltest.c
index 774a2f7..4fbb25c 100644
--- a/tests/utiltest.c
+++ b/tests/utiltest.c
@@ -6,7 +6,7 @@
 #include <unistd.h>
 
 #include "internal.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "testutils.h"
 #include "util.h"
 
diff --git a/tests/virauthconfigtest.c b/tests/virauthconfigtest.c
index 74cc187..9e7dac5 100644
--- a/tests/virauthconfigtest.c
+++ b/tests/virauthconfigtest.c
@@ -26,7 +26,7 @@
 #include "testutils.h"
 #include "util.h"
 #include "virterror_internal.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 
 #include "virauthconfig.h"
diff --git a/tests/virbuftest.c b/tests/virbuftest.c
index 53b9bbe..ec93939 100644
--- a/tests/virbuftest.c
+++ b/tests/virbuftest.c
@@ -8,7 +8,7 @@
 #include "util.h"
 #include "testutils.h"
 #include "virbuffer.h"
-#include "memory.h"
+#include "viralloc.h"
 
 #define TEST_ERROR(...)                             \
     do {                                            \
diff --git a/tests/virdrivermoduletest.c b/tests/virdrivermoduletest.c
index 440ee8e..e06179f 100644
--- a/tests/virdrivermoduletest.c
+++ b/tests/virdrivermoduletest.c
@@ -23,7 +23,7 @@
 #include "testutils.h"
 #include "util.h"
 #include "virterror_internal.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 #include "driver.h"
 
diff --git a/tests/virhashtest.c b/tests/virhashtest.c
index 7de16d0..a2a40c6 100644
--- a/tests/virhashtest.c
+++ b/tests/virhashtest.c
@@ -9,7 +9,7 @@
 #include "virhash.h"
 #include "virhashdata.h"
 #include "testutils.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "util.h"
 #include "virlog.h"
 
diff --git a/tests/virkeyfiletest.c b/tests/virkeyfiletest.c
index c6aca86..ad5a516 100644
--- a/tests/virkeyfiletest.c
+++ b/tests/virkeyfiletest.c
@@ -26,7 +26,7 @@
 #include "testutils.h"
 #include "util.h"
 #include "virterror_internal.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 
 #include "virkeyfile.h"
diff --git a/tests/virlockspacetest.c b/tests/virlockspacetest.c
index c95f5d8..80478d9 100644
--- a/tests/virlockspacetest.c
+++ b/tests/virlockspacetest.c
@@ -27,7 +27,7 @@
 #include "testutils.h"
 #include "util.h"
 #include "virterror_internal.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 
 #include "virlockspace.h"
diff --git a/tests/virnetmessagetest.c b/tests/virnetmessagetest.c
index c20f5e6..e3517e8 100644
--- a/tests/virnetmessagetest.c
+++ b/tests/virnetmessagetest.c
@@ -26,7 +26,7 @@
 #include "testutils.h"
 #include "util.h"
 #include "virterror_internal.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 
 #include "rpc/virnetmessage.h"
diff --git a/tests/virnetsockettest.c b/tests/virnetsockettest.c
index ba281e9..399c4fd 100644
--- a/tests/virnetsockettest.c
+++ b/tests/virnetsockettest.c
@@ -30,7 +30,7 @@
 #include "testutils.h"
 #include "util.h"
 #include "virterror_internal.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 #include "virfile.h"
 
diff --git a/tests/virnettlscontexttest.c b/tests/virnettlscontexttest.c
index 0236659..27078ea 100644
--- a/tests/virnettlscontexttest.c
+++ b/tests/virnettlscontexttest.c
@@ -29,7 +29,7 @@
 #include "testutils.h"
 #include "util.h"
 #include "virterror_internal.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 #include "virfile.h"
 #include "vircommand.h"
diff --git a/tests/virstringtest.c b/tests/virstringtest.c
index 27e490f..a8f4c79 100644
--- a/tests/virstringtest.c
+++ b/tests/virstringtest.c
@@ -25,7 +25,7 @@
 #include "testutils.h"
 #include "util.h"
 #include "virterror_internal.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 
 #include "virstring.h"
diff --git a/tests/virtimetest.c b/tests/virtimetest.c
index c8e9a2e..7d7a2d6 100644
--- a/tests/virtimetest.c
+++ b/tests/virtimetest.c
@@ -26,7 +26,7 @@
 #include "testutils.h"
 #include "util.h"
 #include "virterror_internal.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 
 #include "virtime.h"
diff --git a/tests/viruritest.c b/tests/viruritest.c
index 46964b3..57d3895 100644
--- a/tests/viruritest.c
+++ b/tests/viruritest.c
@@ -26,7 +26,7 @@
 #include "testutils.h"
 #include "util.h"
 #include "virterror_internal.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virlog.h"
 
 #include "viruri.h"
diff --git a/tests/vmx2xmltest.c b/tests/vmx2xmltest.c
index e523d1c..712536b 100644
--- a/tests/vmx2xmltest.c
+++ b/tests/vmx2xmltest.c
@@ -7,7 +7,7 @@
 # include <unistd.h>
 
 # include "internal.h"
-# include "memory.h"
+# include "viralloc.h"
 # include "testutils.h"
 # include "vmx/vmx.h"
 
diff --git a/tests/xmconfigtest.c b/tests/xmconfigtest.c
index 3de68fd..a3943e2 100644
--- a/tests/xmconfigtest.c
+++ b/tests/xmconfigtest.c
@@ -34,7 +34,7 @@
 #include "xenxs/xen_xm.h"
 #include "testutils.h"
 #include "testutilsxen.h"
-#include "memory.h"
+#include "viralloc.h"
 
 static virCapsPtr caps;
 
diff --git a/tests/xml2vmxtest.c b/tests/xml2vmxtest.c
index 94dfcf2..17af6a4 100644
--- a/tests/xml2vmxtest.c
+++ b/tests/xml2vmxtest.c
@@ -7,7 +7,7 @@
 # include <unistd.h>
 
 # include "internal.h"
-# include "memory.h"
+# include "viralloc.h"
 # include "testutils.h"
 # include "vmx/vmx.h"
 
diff --git a/tools/console.c b/tools/console.c
index dbdaab7..1d21189 100644
--- a/tools/console.c
+++ b/tools/console.c
@@ -41,7 +41,7 @@
 # include "virlog.h"
 # include "util.h"
 # include "virfile.h"
-# include "memory.h"
+# include "viralloc.h"
 # include "threads.h"
 # include "virterror_internal.h"
 
diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c
index 0006c11..a443988 100644
--- a/tools/virsh-domain-monitor.c
+++ b/tools/virsh-domain-monitor.c
@@ -34,7 +34,7 @@
 #include "internal.h"
 #include "conf/domain_conf.h"
 #include "intprops.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virmacaddr.h"
 #include "virsh-domain.h"
 #include "xml.h"
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 76d9d51..b0b0c94 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -42,7 +42,7 @@
 #include "c-ctype.h"
 #include "conf/domain_conf.h"
 #include "console.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "util.h"
 #include "virfile.h"
 #include "virkeycode.h"
diff --git a/tools/virsh-host.c b/tools/virsh-host.c
index 6f129d1..2d59a75 100644
--- a/tools/virsh-host.c
+++ b/tools/virsh-host.c
@@ -33,7 +33,7 @@
 
 #include "internal.h"
 #include "virbuffer.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "util.h"
 #include "virsh-domain.h"
 #include "xml.h"
diff --git a/tools/virsh-interface.c b/tools/virsh-interface.c
index 956fee8..40216c6 100644
--- a/tools/virsh-interface.c
+++ b/tools/virsh-interface.c
@@ -33,7 +33,7 @@
 
 #include "internal.h"
 #include "virbuffer.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "util.h"
 #include "xml.h"
 
diff --git a/tools/virsh-network.c b/tools/virsh-network.c
index c5d494a..66ee7e3 100644
--- a/tools/virsh-network.c
+++ b/tools/virsh-network.c
@@ -33,7 +33,7 @@
 
 #include "internal.h"
 #include "virbuffer.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "util.h"
 #include "xml.h"
 #include "conf/network_conf.h"
diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c
index 52cd874..7e569b3 100644
--- a/tools/virsh-nodedev.c
+++ b/tools/virsh-nodedev.c
@@ -33,7 +33,7 @@
 
 #include "internal.h"
 #include "virbuffer.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "util.h"
 #include "xml.h"
 #include "conf/node_device_conf.h"
diff --git a/tools/virsh-nwfilter.c b/tools/virsh-nwfilter.c
index 3108d1b..c3dba0c 100644
--- a/tools/virsh-nwfilter.c
+++ b/tools/virsh-nwfilter.c
@@ -33,7 +33,7 @@
 
 #include "internal.h"
 #include "virbuffer.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "util.h"
 #include "xml.h"
 
diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c
index 4a78467..6e29604 100644
--- a/tools/virsh-pool.c
+++ b/tools/virsh-pool.c
@@ -33,7 +33,7 @@
 
 #include "internal.h"
 #include "virbuffer.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "util.h"
 #include "xml.h"
 #include "conf/storage_conf.h"
diff --git a/tools/virsh-secret.c b/tools/virsh-secret.c
index ee79b97..d81e8ce 100644
--- a/tools/virsh-secret.c
+++ b/tools/virsh-secret.c
@@ -34,7 +34,7 @@
 #include "internal.h"
 #include "base64.h"
 #include "virbuffer.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "util.h"
 #include "xml.h"
 
diff --git a/tools/virsh-snapshot.c b/tools/virsh-snapshot.c
index d6a381d..3fecde6 100644
--- a/tools/virsh-snapshot.c
+++ b/tools/virsh-snapshot.c
@@ -35,7 +35,7 @@
 
 #include "internal.h"
 #include "virbuffer.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "util.h"
 #include "virsh-domain.h"
 #include "xml.h"
diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c
index 1bad6b1..ebfe52d 100644
--- a/tools/virsh-volume.c
+++ b/tools/virsh-volume.c
@@ -35,7 +35,7 @@
 
 #include "internal.h"
 #include "virbuffer.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "util.h"
 #include "virfile.h"
 #include "virsh-pool.h"
diff --git a/tools/virsh.c b/tools/virsh.c
index 5cb2e06..e894aff 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -59,7 +59,7 @@
 #include "virbuffer.h"
 #include "console.h"
 #include "util.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "xml.h"
 #include "libvirt/libvirt-qemu.h"
 #include "virfile.h"
diff --git a/tools/virt-host-validate-common.c b/tools/virt-host-validate-common.c
index 5bbb5e9..cd75eba 100644
--- a/tools/virt-host-validate-common.c
+++ b/tools/virt-host-validate-common.c
@@ -28,7 +28,7 @@
 #include <sys/utsname.h>
 
 #include "util.h"
-#include "memory.h"
+#include "viralloc.h"
 #include "virfile.h"
 #include "virt-host-validate-common.h"
 
-- 
1.7.11.7


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