[PATCH 4/5] Match FREE and MALLOC/STRDUP/REALLOC

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

 



In _DEBUG_ mode, MALLOC/STRDUP/REALLOC and FREE will record
the memory usage. Match them.

Signed-off-by: Lixiaokeng <lixiaokeng@xxxxxxxxxx>
---
 kpartx/dasd.c                        | 5 +++--
 kpartx/kpartx.c                      | 7 ++++---
 libmultipath/blacklist.c             | 6 +++---
 libmultipath/checkers/emc_clariion.c | 2 +-
 libmultipath/config.c                | 4 ++--
 libmultipath/configure.c             | 4 ++--
 libmultipath/dmparser.c              | 2 +-
 libmultipath/parser.c                | 2 +-
 libmultipath/structs.c               | 2 +-
 multipathd/main.c                    | 2 +-
 10 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/kpartx/dasd.c b/kpartx/dasd.c
index f0398645..14744048 100644
--- a/kpartx/dasd.c
+++ b/kpartx/dasd.c
@@ -40,6 +40,7 @@
 #include "kpartx.h"
 #include "byteorder.h"
 #include "dasd.h"
+#include "memory.h"

 unsigned long long sectors512(unsigned long long sectors, int blocksize)
 {
@@ -100,10 +101,10 @@ read_dasd_pt(int fd, __attribute__((unused)) struct slice all,
 		 * Get the first target and operate on that instead.
 		 */
 		if (!(dev = dm_get_first_dep(devname))) {
-			free(devname);
+			FREE(devname);
 			return -1;
 		}
-		free(devname);
+		FREE(devname);

 		if ((unsigned int)major(dev) != 94) {
 			/* Not a DASD */
diff --git a/kpartx/kpartx.c b/kpartx/kpartx.c
index 7bc64543..5e59063d 100644
--- a/kpartx/kpartx.c
+++ b/kpartx/kpartx.c
@@ -39,6 +39,7 @@
 #include "lopart.h"
 #include "kpartx.h"
 #include "version.h"
+#include "memory.h"

 #define SIZE(a) (sizeof(a)/sizeof((a)[0]))

@@ -177,7 +178,7 @@ get_hotplug_device(void)

 	/* Dirname + mapname + \0 */
 	if (!(device = (char *)malloc(sizeof(char) * (off + len + 1)))) {
-		free(mapname);
+		FREE(mapname);
 		return NULL;
 	}

@@ -187,10 +188,10 @@ get_hotplug_device(void)

 	if (strlen(device) != (off + len)) {
 		free(device);
-		free(mapname);
+		FREE(mapname);
 		return NULL;
 	}
-	free(mapname);
+	FREE(mapname);
 	return device;
 }

diff --git a/libmultipath/blacklist.c b/libmultipath/blacklist.c
index 4e315c97..573df152 100644
--- a/libmultipath/blacklist.c
+++ b/libmultipath/blacklist.c
@@ -39,7 +39,7 @@ int store_ble(vector blist, const char *str, int origin)
 	if (!str)
 		return 0;

-	strdup_str = strdup(str);
+	strdup_str = STRDUP(str);
 	if (!strdup_str)
 		return 1;

@@ -134,8 +134,8 @@ out1:
 		ble->vendor = NULL;
 	}
 out:
-	free(vendor_str);
-	free(product_str);
+	FREE(vendor_str);
+	FREE(product_str);
 	return 1;
 }

diff --git a/libmultipath/checkers/emc_clariion.c b/libmultipath/checkers/emc_clariion.c
index 5cd63aca..b3f0aded 100644
--- a/libmultipath/checkers/emc_clariion.c
+++ b/libmultipath/checkers/emc_clariion.c
@@ -128,7 +128,7 @@ int libcheck_mp_init (struct checker * c)

 void libcheck_free (struct checker * c)
 {
-	free(c->context);
+	FREE(c->context);
 }

 int libcheck_check (struct checker * c)
diff --git a/libmultipath/config.c b/libmultipath/config.c
index 30046a17..667b500b 100644
--- a/libmultipath/config.c
+++ b/libmultipath/config.c
@@ -1051,10 +1051,10 @@ int parse_uid_attrs(char *uid_attrs, struct config *conf)
 		if (!tmp) {
 			condlog(2, "invalid record in uid_attrs: %s",
 				uid_attr_record);
-			free(uid_attr_record);
+			FREE(uid_attr_record);
 			ret = 1;
 		} else if (!vector_alloc_slot(attrs)) {
-			free(uid_attr_record);
+			FREE(uid_attr_record);
 			ret = 1;
 		} else
 			vector_set_slot(attrs, uid_attr_record);
diff --git a/libmultipath/configure.c b/libmultipath/configure.c
index 7edb355b..9545854b 100644
--- a/libmultipath/configure.c
+++ b/libmultipath/configure.c
@@ -738,8 +738,8 @@ void select_action (struct multipath *mpp, const struct _vector *curmp,
 		condlog(1, "%s: can't use alias \"%s\" used by %s, falling back to WWID",
 			mpp->wwid, mpp->alias, cmpp_by_name->wwid);
 		/* We can do this because wwid wasn't found */
-		free(mpp->alias);
-		mpp->alias = strdup(mpp->wwid);
+		FREE(mpp->alias);
+		mpp->alias = STRDUP(mpp->wwid);
 		mpp->action = ACT_CREATE;
 		condlog(3, "%s: set ACT_CREATE (map does not exist, name changed)",
 			mpp->alias);
diff --git a/libmultipath/dmparser.c b/libmultipath/dmparser.c
index 4ba7f339..96beeb6d 100644
--- a/libmultipath/dmparser.c
+++ b/libmultipath/dmparser.c
@@ -30,7 +30,7 @@ merge_words(char **dst, const char *word)
 	*dst = REALLOC(*dst, len);

 	if (!*dst) {
-		free(p);
+		FREE(p);
 		return 1;
 	}

diff --git a/libmultipath/parser.c b/libmultipath/parser.c
index 68262d0e..f0047c4d 100644
--- a/libmultipath/parser.c
+++ b/libmultipath/parser.c
@@ -364,7 +364,7 @@ set_value(vector strvec)
 	for (i = 2; i < VECTOR_SIZE(strvec); i++) {
 		str = VECTOR_SLOT(strvec, i);
 		if (!str) {
-			free(alloc);
+			FREE(alloc);
 			condlog(0, "parse error for option '%s'",
 				(char *)VECTOR_SLOT(strvec, 0));
 			return NULL;
diff --git a/libmultipath/structs.c b/libmultipath/structs.c
index 6e5a1038..e8cacb4b 100644
--- a/libmultipath/structs.c
+++ b/libmultipath/structs.c
@@ -106,7 +106,7 @@ alloc_path (void)
 		dm_path_to_gen(pp)->ops = &dm_gen_path_ops;
 		pp->hwe = vector_alloc();
 		if (pp->hwe == NULL) {
-			free(pp);
+			FREE(pp);
 			return NULL;
 		}
 	}
diff --git a/multipathd/main.c b/multipathd/main.c
index 1defeaf1..82ab3ed1 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -3555,7 +3555,7 @@ void *  mpath_pr_event_handler_fn (void * pathp )
 		goto out;
 	}

-	param = (struct prout_param_descriptor *)MALLOC(sizeof(struct prout_param_descriptor));
+	param = (struct prout_param_descriptor *)calloc(1, sizeof(struct prout_param_descriptor));
 	if (!param)
 		goto out;

-- 

--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://listman.redhat.com/mailman/listinfo/dm-devel




[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux