fs/romfs: fix size of pointer during memory allocation
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
This commit is contained in:
parent
8c8c60f70a
commit
989e8ac48f
@ -314,8 +314,7 @@ static inline int romfs_searchdir(FAR struct romfs_mountpt_s *rm,
|
|||||||
FAR struct romfs_nodeinfo_s **cnodeinfo;
|
FAR struct romfs_nodeinfo_s **cnodeinfo;
|
||||||
|
|
||||||
cnodeinfo = bsearch(entryname, nodeinfo->rn_child, nodeinfo->rn_count,
|
cnodeinfo = bsearch(entryname, nodeinfo->rn_child, nodeinfo->rn_count,
|
||||||
sizeof(struct romfs_nodeinfo_s *),
|
sizeof(*nodeinfo->rn_child), romfs_nodeinfo_search);
|
||||||
romfs_nodeinfo_search);
|
|
||||||
if (cnodeinfo)
|
if (cnodeinfo)
|
||||||
{
|
{
|
||||||
memcpy(nodeinfo, *cnodeinfo, sizeof(*nodeinfo));
|
memcpy(nodeinfo, *cnodeinfo, sizeof(*nodeinfo));
|
||||||
@ -441,9 +440,8 @@ static int romfs_cachenode(FAR struct romfs_mountpt_s *rm,
|
|||||||
{
|
{
|
||||||
FAR void *tmp;
|
FAR void *tmp;
|
||||||
|
|
||||||
tmp = kmm_realloc(nodeinfo->rn_child,
|
tmp = kmm_realloc(nodeinfo->rn_child, (num + NODEINFO_NINCR) *
|
||||||
(num + NODEINFO_NINCR) *
|
sizeof(*nodeinfo->rn_child));
|
||||||
sizeof(struct romfs_nodeinfo_s *));
|
|
||||||
if (tmp == NULL)
|
if (tmp == NULL)
|
||||||
{
|
{
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
@ -451,7 +449,7 @@ static int romfs_cachenode(FAR struct romfs_mountpt_s *rm,
|
|||||||
|
|
||||||
nodeinfo->rn_child = tmp;
|
nodeinfo->rn_child = tmp;
|
||||||
memset(nodeinfo->rn_child + num, 0, NODEINFO_NINCR *
|
memset(nodeinfo->rn_child + num, 0, NODEINFO_NINCR *
|
||||||
sizeof(struct romfs_nodeinfo_s *));
|
sizeof(*nodeinfo->rn_child));
|
||||||
num += NODEINFO_NINCR;
|
num += NODEINFO_NINCR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -478,8 +476,7 @@ static int romfs_cachenode(FAR struct romfs_mountpt_s *rm,
|
|||||||
if (nodeinfo->rn_count > 1)
|
if (nodeinfo->rn_count > 1)
|
||||||
{
|
{
|
||||||
qsort(nodeinfo->rn_child, nodeinfo->rn_count,
|
qsort(nodeinfo->rn_child, nodeinfo->rn_count,
|
||||||
sizeof(struct romfs_nodeinfo_s *),
|
sizeof(*nodeinfo->rn_child), romfs_nodeinfo_compare);
|
||||||
romfs_nodeinfo_compare);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user