summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVijay Bellur <vbellur@redhat.com>2019-02-27 16:02:43 -0800
committerPranith Kumar Karampuri <pkarampu@redhat.com>2019-04-12 13:08:28 +0000
commitc261eb6c1fa41b6a0eadabbb3a2f64dc194ec254 (patch)
tree93eb38d3e003c998a53844cc7a0081d1a9cf9b40
parent0e1223491e964096384edfae5032ed0d50d028ad (diff)
Replace memdup() with gf_memdup()
memdup() and gf_memdup() have the same implementation. Removed one API as the presence of both can be confusing. Change-Id: I562130c668457e13e4288e592792872d2e49887e updates: bz#1193929 Signed-off-by: Vijay Bellur <vbellur@redhat.com>
-rw-r--r--libglusterfs/src/default-args.c3
-rw-r--r--libglusterfs/src/dict.c4
-rw-r--r--libglusterfs/src/glusterfs/common-utils.h13
-rw-r--r--libglusterfs/src/glusterfs/mem-pool.h2
-rw-r--r--xlators/cluster/afr/src/afr-self-heald.c2
-rw-r--r--xlators/lib/src/libxlator.c6
-rw-r--r--xlators/protocol/client/src/client-helpers.c2
-rw-r--r--xlators/protocol/server/src/server-handshake.c3
8 files changed, 11 insertions, 24 deletions
diff --git a/libglusterfs/src/default-args.c b/libglusterfs/src/default-args.c
index cfceabd..9d40704 100644
--- a/libglusterfs/src/default-args.c
+++ b/libglusterfs/src/default-args.c
@@ -1137,7 +1137,8 @@ args_rchecksum_cbk_store(default_args_cbk_t *args, int32_t op_ret,
args->op_errno = op_errno;
if (op_ret >= 0) {
args->weak_checksum = weak_checksum;
- args->strong_checksum = memdup(strong_checksum, SHA256_DIGEST_LENGTH);
+ args->strong_checksum = gf_memdup(strong_checksum,
+ SHA256_DIGEST_LENGTH);
}
if (xdata)
args->xdata = dict_ref(xdata);
diff --git a/libglusterfs/src/dict.c b/libglusterfs/src/dict.c
index 6b63b8f..2374ab0 100644
--- a/libglusterfs/src/dict.c
+++ b/libglusterfs/src/dict.c
@@ -306,7 +306,7 @@ data_copy(data_t *old)
newdata->len = old->len;
if (old->data) {
- newdata->data = memdup(old->data, old->len);
+ newdata->data = gf_memdup(old->data, old->len);
if (!newdata->data)
goto err_out;
}
@@ -3139,7 +3139,7 @@ dict_unserialize(char *orig_buf, int32_t size, dict_t **fill)
goto out;
}
value->len = vallen;
- value->data = memdup(buf, vallen);
+ value->data = gf_memdup(buf, vallen);
value->data_type = GF_DATA_TYPE_STR_OLD;
value->is_static = _gf_false;
buf += vallen;
diff --git a/libglusterfs/src/glusterfs/common-utils.h b/libglusterfs/src/glusterfs/common-utils.h
index 0140f7b..56ea83c 100644
--- a/libglusterfs/src/glusterfs/common-utils.h
+++ b/libglusterfs/src/glusterfs/common-utils.h
@@ -682,19 +682,6 @@ iov_0filled(const struct iovec *vector, int count)
return ret;
}
-static inline void *
-memdup(const void *ptr, size_t size)
-{
- void *newptr = NULL;
-
- newptr = GF_MALLOC(size, gf_common_mt_memdup);
- if (!newptr)
- return NULL;
-
- memcpy(newptr, ptr, size);
- return newptr;
-}
-
typedef enum {
gf_timefmt_default = 0,
gf_timefmt_FT = 0, /* YYYY-MM-DD hh:mm:ss */
diff --git a/libglusterfs/src/glusterfs/mem-pool.h b/libglusterfs/src/glusterfs/mem-pool.h
index 0250b59..1f2b1a9 100644
--- a/libglusterfs/src/glusterfs/mem-pool.h
+++ b/libglusterfs/src/glusterfs/mem-pool.h
@@ -193,7 +193,7 @@ gf_memdup(const void *src, size_t size)
{
void *dup_mem = NULL;
- dup_mem = GF_MALLOC(size, gf_common_mt_strdup);
+ dup_mem = GF_MALLOC(size, gf_common_mt_memdup);
if (!dup_mem)
goto out;
diff --git a/xlators/cluster/afr/src/afr-self-heald.c b/xlators/cluster/afr/src/afr-self-heald.c
index fe8ca02..29714f5 100644
--- a/xlators/cluster/afr/src/afr-self-heald.c
+++ b/xlators/cluster/afr/src/afr-self-heald.c
@@ -387,7 +387,7 @@ afr_shd_sweep_done(struct subvol_healer *healer)
shd = &(((afr_private_t *)healer->this->private)->shd);
time(&event->end_time);
- history = memdup(event, sizeof(*event));
+ history = gf_memdup(event, sizeof(*event));
event->start_time = 0;
if (!history)
diff --git a/xlators/lib/src/libxlator.c b/xlators/lib/src/libxlator.c
index 075229d..724ceef 100644
--- a/xlators/lib/src/libxlator.c
+++ b/xlators/lib/src/libxlator.c
@@ -267,17 +267,17 @@ cluster_markeruuid_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
goto unlock;
} else if (volmark->retval) {
GF_FREE(local->volmark);
- local->volmark = memdup(volmark, sizeof(*volmark));
+ local->volmark = gf_memdup(volmark, sizeof(*volmark));
local->retval = volmark->retval;
} else if ((volmark->sec > local->volmark->sec) ||
((volmark->sec == local->volmark->sec) &&
(volmark->usec >= local->volmark->usec))) {
GF_FREE(local->volmark);
- local->volmark = memdup(volmark, sizeof(*volmark));
+ local->volmark = gf_memdup(volmark, sizeof(*volmark));
}
} else {
- local->volmark = memdup(volmark, sizeof(*volmark));
+ local->volmark = gf_memdup(volmark, sizeof(*volmark));
VALIDATE_OR_GOTO(local->volmark, unlock);
gf_uuid_unparse(volmark->uuid, vol_uuid);
if (volmark->retval)
diff --git a/xlators/protocol/client/src/client-helpers.c b/xlators/protocol/client/src/client-helpers.c
index 53b4484..42b5410 100644
--- a/xlators/protocol/client/src/client-helpers.c
+++ b/xlators/protocol/client/src/client-helpers.c
@@ -209,7 +209,7 @@ unserialize_rsp_direntp(xlator_t *this, fd_t *fd, struct gfs3_readdirp_rsp *rsp,
if (trav->dict.dict_val) {
/* Dictionary is sent along with response */
- buf = memdup(trav->dict.dict_val, trav->dict.dict_len);
+ buf = gf_memdup(trav->dict.dict_val, trav->dict.dict_len);
if (!buf)
goto out;
diff --git a/xlators/protocol/server/src/server-handshake.c b/xlators/protocol/server/src/server-handshake.c
index 382f241..a0ff163 100644
--- a/xlators/protocol/server/src/server-handshake.c
+++ b/xlators/protocol/server/src/server-handshake.c
@@ -36,7 +36,6 @@ gf_compare_client_version(rpcsvc_request_t *req, int fop_prognum,
return ret;
}
-
int
server_getspec(rpcsvc_request_t *req)
{
@@ -267,7 +266,7 @@ server_setvolume(rpcsvc_request_t *req)
*/
config_params = dict_copy_with_ref(this->options, NULL);
- buf = memdup(args.dict.dict_val, args.dict.dict_len);
+ buf = gf_memdup(args.dict.dict_val, args.dict.dict_len);
if (buf == NULL) {
op_ret = -1;
op_errno = ENOMEM;