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

[PATCH 05/36] xen/xmalloc: add kmalloc() and kfree() aliases



From: Denis Mukhin <dmukhin@xxxxxxxx>

Move existing aliases to a common header so those could be used in the new
code.

The code looks simpler w/ kmalloc(): type specification of the
object being allocated is not required, e.g.:
...
  struct my_obj_s *obj;

  obj = kmalloc(sizeof(*obj), 0);
...

Signed-off-by: Denis Mukhin <dmukhin@xxxxxxxx>
---
 xen/drivers/passthrough/arm/smmu.c | 4 ----
 xen/include/xen/xmalloc.h          | 5 +++++
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/xen/drivers/passthrough/arm/smmu.c 
b/xen/drivers/passthrough/arm/smmu.c
index 
aa6a968b574dce7cc753e8070fad3a6e585cd9e7..b343dbc32282136ccb95654ae2756eaa8a51149f
 100644
--- a/xen/drivers/passthrough/arm/smmu.c
+++ b/xen/drivers/passthrough/arm/smmu.c
@@ -136,11 +136,7 @@ typedef enum irqreturn irqreturn_t;
 #define dev_name(dev) dt_node_full_name(dev_to_dt(dev))
 
 /* Alias to Xen allocation helpers */
-#define kfree xfree
-#define kmalloc(size, flags)           _xmalloc(size, sizeof(void *))
-#define kzalloc(size, flags)           _xzalloc(size, sizeof(void *))
 #define devm_kzalloc(dev, size, flags) _xzalloc(size, sizeof(void *))
-#define kmalloc_array(size, n, flags)  _xmalloc_array(size, sizeof(void *), n)
 #define devm_kcalloc(dev, n, size, flags)                      \
        _xzalloc_array(size, sizeof(void *), n)
 
diff --git a/xen/include/xen/xmalloc.h b/xen/include/xen/xmalloc.h
index 
b903fa2e26e198fc80fc6010c3165cc50b1197c7..eea8cced51d9fe784b558201a68648e1672d624f
 100644
--- a/xen/include/xen/xmalloc.h
+++ b/xen/include/xen/xmalloc.h
@@ -16,6 +16,11 @@
 #define xmalloc(_type) ((_type *)_xmalloc(sizeof(_type), __alignof__(_type)))
 #define xzalloc(_type) ((_type *)_xzalloc(sizeof(_type), __alignof__(_type)))
 
+#define kfree                           xfree
+#define kmalloc(size, flags)            _xmalloc(size, sizeof(void *))
+#define kzalloc(size, flags)            _xzalloc(size, sizeof(void *))
+#define kmalloc_array(size, n, flags)   _xmalloc_array(size, sizeof(void *), n)
+
 /*
  * Allocate space for a typed object and copy an existing instance.
  *

-- 
2.34.1





 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.