summaryrefslogtreecommitdiffstats
path: root/api/src/glfs-fops.c
diff options
context:
space:
mode:
authorKinglong Mee <mijinlong@open-fs.com>2017-08-30 17:54:09 +0800
committerJeff Darcy <jeff@pl.atyp.us>2017-09-01 15:32:55 +0000
commitd7ccdb33c2e84bab25bf0898866104f8a85b4217 (patch)
tree451568625f26dc732e52c318f414e777c8b2e19a /api/src/glfs-fops.c
parent75223c0a1b3c7bd65bb0c59449ed1fb0663cfdd3 (diff)
gfapi: adds a glfs_mem_header for exported memory
glfs_free releases different types of data depends on memory type. Drop the depends of memory type of memory accounting, new macro GLFS_CALLOC/GLFS_MALLOC/GLFS_REALLOC/GLFS_FREE are added to support assign release function dynamically, it adds a separate memory header named glfs_mem_header for gfapi. Updates: #312 Change-Id: Ie608e5227cbaa05d3f4681a515e83a50d5b17c3f Signed-off-by: Kinglong Mee <mijinlong@open-fs.com> Reviewed-on: https://review.gluster.org/18092 Smoke: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Niels de Vos <ndevos@redhat.com> Tested-by: Niels de Vos <ndevos@redhat.com> Reviewed-by: Jeff Darcy <jeff@pl.atyp.us> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Diffstat (limited to 'api/src/glfs-fops.c')
-rw-r--r--api/src/glfs-fops.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/api/src/glfs-fops.c b/api/src/glfs-fops.c
index c8ddeea196e..e6ed07a68a9 100644
--- a/api/src/glfs-fops.c
+++ b/api/src/glfs-fops.c
@@ -4104,8 +4104,8 @@ glfs_realpath_common (struct glfs *fs, const char *path, char *resolved_path,
"glfs_realpath()");
}
} else {
- retpath = allocpath = GF_CALLOC (1, PATH_MAX + 1,
- glfs_mt_realpath_t);
+ retpath = allocpath = GLFS_CALLOC (1, PATH_MAX + 1, NULL,
+ glfs_mt_realpath_t);
}
if (!retpath) {
@@ -4140,7 +4140,7 @@ out:
if (warn_deprecated && allocpath)
free (allocpath);
else if (allocpath)
- GF_FREE (allocpath);
+ GLFS_FREE (allocpath);
retpath = NULL;
}
@@ -4619,6 +4619,14 @@ invalid_fs:
return ret;
}
+static void glfs_release_xreaddirp_stat (void *ptr)
+{
+ struct glfs_xreaddirp_stat *to_free = ptr;
+
+ if (to_free->object)
+ glfs_h_close (to_free->object);
+}
+
/*
* Given glfd of a directory, this function does readdirp and returns
* xstat along with dirents.
@@ -4652,8 +4660,9 @@ pub_glfs_xreaddirplus_r (struct glfs_fd *glfd, uint32_t flags,
if (!buf)
goto out;
- xstat = GF_CALLOC(1, sizeof(struct glfs_xreaddirp_stat),
- glfs_mt_xreaddirp_stat_t);
+ xstat = GLFS_CALLOC(1, sizeof(struct glfs_xreaddirp_stat),
+ glfs_release_xreaddirp_stat,
+ glfs_mt_xreaddirp_stat_t);
if (!xstat)
goto out;
@@ -4677,7 +4686,7 @@ pub_glfs_xreaddirplus_r (struct glfs_fd *glfd, uint32_t flags,
*xstat_p = NULL;
/* free xstat as applications shall not be using it */
- glfs_free (xstat);
+ GLFS_FREE (xstat);
goto out;
}
@@ -4728,7 +4737,7 @@ out:
strerror(errno));
if (xstat)
- glfs_free (xstat);
+ GLFS_FREE (xstat);
}
__GLFS_EXIT_FS;