# HG changeset patch # User Paul Boddie # Date 1666478528 -7200 # Node ID a3e0ab0227022a0baa5513f6be1f4e634ea670d7 # Parent c7c2be2784ea856e465cacb5a8b1ee54a60e0a42 Removed superfluous buffer allocation: this is done automatically by the underlying ext2fs_dir_iterate2 function. diff -r c7c2be2784ea -r a3e0ab022702 libe2access/lib/src/image.c --- a/libe2access/lib/src/image.c Sat Oct 22 23:51:52 2022 +0200 +++ b/libe2access/lib/src/image.c Sun Oct 23 00:42:08 2022 +0200 @@ -237,7 +237,6 @@ errcode_t image_resolve_by_path(ext2_filsys fs, const char **path, ext2_ino_t *ino) { - char *buf; ext2_ino_t ino_dir; errcode_t retval; @@ -245,11 +244,6 @@ *ino = 0; - retval = ext2fs_get_mem(fs->blocksize, &buf); - - if (retval) - return retval; - /* Skip any leading root marker. */ if (**path == '/') @@ -266,7 +260,7 @@ while (**path) { - retval = image_resolve_next(fs, ino_dir, path, buf, ino); + retval = image_resolve_next(fs, ino_dir, path, 0, ino); if (retval) { *ino = ino_dir; @@ -278,8 +272,6 @@ ino_dir = *ino; } - ext2fs_free_mem(&buf); - return retval; } @@ -323,17 +315,7 @@ errcode_t image_find_file_by_inode(ext2_filsys fs, ext2_ino_t ino_parent, const char *basename, ext2_ino_t *ino) { - char *buf; - errcode_t retval = ext2fs_get_mem(fs->blocksize, &buf); - - if (retval) - return retval; - - retval = ext2fs_lookup(fs, ino_parent, basename, strlen(basename), buf, ino); - - ext2fs_free_mem(&buf); - - return retval; + return ext2fs_lookup(fs, ino_parent, basename, strlen(basename), 0, ino); } /* Obtain the inode for the object with the given path. */ @@ -381,38 +363,26 @@ void *), void *data) { - char *buf; ext2_ino_t ino; errcode_t retval; - retval = ext2fs_get_mem(fs->blocksize, &buf); - if (retval) - return retval; - /* Locate the object and test whether it is a directory. */ retval = image_find_by_path(fs, path, &ino); if (retval) - { - ext2fs_free_mem(&buf); return retval; - } if (!image_isdir_by_inode(fs, ino)) return 1; /* List the directory contents. */ - retval = ext2fs_dir_iterate(fs, ino, 0, buf, proc, data); + retval = ext2fs_dir_iterate(fs, ino, 0, 0, proc, data); if (retval) - { - ext2fs_free_mem(&buf); return retval; - } - ext2fs_free_mem(&buf); return 0; }