46 lines
1.2 KiB
Diff
46 lines
1.2 KiB
Diff
|
|
From 08348f1b72de27681549894f7a506674fba19ff2 Mon Sep 17 00:00:00 2001
|
||
|
|
From: Alexander Amelkin <alexander@amelkin.msk.ru>
|
||
|
|
Date: Wed, 20 Feb 2019 14:56:37 +0300
|
||
|
|
Subject: [PATCH 114/119] Refactor free_n() function
|
||
|
|
|
||
|
|
Make the argument to free_n() compatible with any pointers,
|
||
|
|
thus reducing the number of compilation warnings.
|
||
|
|
|
||
|
|
End-user-impact: None
|
||
|
|
Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
|
||
|
|
---
|
||
|
|
include/ipmitool/helper.h | 10 ++++++----
|
||
|
|
1 file changed, 6 insertions(+), 4 deletions(-)
|
||
|
|
|
||
|
|
diff --git a/include/ipmitool/helper.h b/include/ipmitool/helper.h
|
||
|
|
index c03c931..0d4f6e3 100644
|
||
|
|
--- a/include/ipmitool/helper.h
|
||
|
|
+++ b/include/ipmitool/helper.h
|
||
|
|
@@ -37,6 +37,7 @@
|
||
|
|
#include <inttypes.h>
|
||
|
|
#include <stdio.h>
|
||
|
|
#include <string.h>
|
||
|
|
+#include <stdlib.h> /* For free() */
|
||
|
|
|
||
|
|
#ifndef TRUE
|
||
|
|
#define TRUE 1
|
||
|
|
@@ -115,10 +116,11 @@ uint16_t ipmi_get_oem_id(struct ipmi_intf *intf);
|
||
|
|
* Free the memory and clear the pointer.
|
||
|
|
* @param[in] ptr - a pointer to your pointer to free.
|
||
|
|
*/
|
||
|
|
-static inline void free_n(void **ptr) {
|
||
|
|
- if (ptr && *ptr) {
|
||
|
|
- free(*ptr);
|
||
|
|
- *ptr = NULL;
|
||
|
|
+static inline void free_n(void *ptr) {
|
||
|
|
+ void **pptr = (void **)ptr;
|
||
|
|
+ if (pptr && *pptr) {
|
||
|
|
+ free(*pptr);
|
||
|
|
+ *pptr = NULL;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
--
|
||
|
|
2.19.1
|
||
|
|
|