aboutsummaryrefslogtreecommitdiff
path: root/extras/browse.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2021-04-08 12:04:33 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2021-06-07 14:35:40 +0200
commit7a2e1a0a7a575c64eaf050c8ec08e5b36e4acfad (patch)
treec3fda7a6c0202341612fd1ab489974abe2ce7e00 /extras/browse.c
parenta49a5bc6253883f8dab06d5bae7e5453008da164 (diff)
Fix: libsquashfs: add sqfs_free() function
On systems like Windows, the dynamic library and applications can easily end up being linked against different runtime libraries, so applications cannot be expected to be able to free() any malloc'd pointer that the library returns. This commit adds an sqfs_free function so the application can pass pointers back to the library to call the correct free() implementation. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'extras/browse.c')
-rw-r--r--extras/browse.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/extras/browse.c b/extras/browse.c
index 86ce788..8b96c15 100644
--- a/extras/browse.c
+++ b/extras/browse.c
@@ -70,12 +70,12 @@ static void list_directory(const char *dirname)
sqfs_dir_reader_get_root_inode(dr, &root);
ret = sqfs_dir_reader_find_by_path(dr, root, dirname, &inode);
- free(root);
+ sqfs_free(root);
if (ret)
goto fail_resolve;
ret = sqfs_dir_reader_open_dir(dr, inode, 0);
- free(inode);
+ sqfs_free(inode);
if (ret)
goto fail_open;
} else {
@@ -85,7 +85,7 @@ static void list_directory(const char *dirname)
goto fail_resolve;
ret = sqfs_dir_reader_open_dir(dr, inode, 0);
- free(inode);
+ sqfs_free(inode);
if (ret)
goto fail_open;
}
@@ -102,7 +102,7 @@ static void list_directory(const char *dirname)
}
len = ent->size + 1;
- free(ent);
+ sqfs_free(ent);
}
col_count = 79 / (max_len + 1);
@@ -148,7 +148,7 @@ static void list_directory(const char *dirname)
printf("%.*s", ent->size + 1, ent->name);
fputs("\033[0m", stdout);
- free(ent);
+ sqfs_free(ent);
++i;
if (i == col_count) {
@@ -231,7 +231,7 @@ static void stat_cmd(const char *filename)
if (*filename == '/') {
sqfs_dir_reader_get_root_inode(dr, &root);
ret = sqfs_dir_reader_find_by_path(dr, root, filename, &inode);
- free(root);
+ sqfs_free(root);
if (ret)
goto fail_resolve;
} else {
@@ -398,12 +398,12 @@ static void stat_cmd(const char *filename)
printf("\tSize: %u\n", idx->size + 1);
printf("\tEntry: %.*s\n\n", idx->size + 1, idx->name);
- free(idx);
+ sqfs_free(idx);
}
break;
}
- free(inode);
+ sqfs_free(inode);
return;
fail_resolve:
printf("Error resolving '%s', error code %d\n", filename, ret);
@@ -429,7 +429,7 @@ static void cat_cmd(const char *filename)
if (*filename == '/') {
sqfs_dir_reader_get_root_inode(dr, &root);
ret = sqfs_dir_reader_find_by_path(dr, root, filename, &inode);
- free(root);
+ sqfs_free(root);
} else {
ret = sqfs_dir_reader_find_by_path(dr, working_dir,
filename, &inode);
@@ -459,7 +459,7 @@ static void cat_cmd(const char *filename)
offset += diff;
}
- free(inode);
+ sqfs_free(inode);
}
/*****************************************************************************/