summaryrefslogtreecommitdiff
path: root/lib/common
diff options
context:
space:
mode:
Diffstat (limited to 'lib/common')
-rw-r--r--lib/common/comp_lzo.c6
-rw-r--r--lib/common/mkdir_p.c21
-rw-r--r--lib/common/serialize_fstree.c2
-rw-r--r--lib/common/write_export_table.c2
4 files changed, 8 insertions, 23 deletions
diff --git a/lib/common/comp_lzo.c b/lib/common/comp_lzo.c
index 473b76f..cf5a362 100644
--- a/lib/common/comp_lzo.c
+++ b/lib/common/comp_lzo.c
@@ -176,7 +176,7 @@ static sqfs_compressor_t *lzo_create_copy(sqfs_compressor_t *cmp)
lzo_compressor_t *other = (lzo_compressor_t *)cmp;
lzo_compressor_t *lzo;
- lzo = alloc_flex(sizeof(*lzo), 1, lzo_algs[other->algorithm].bufsize);
+ lzo = calloc(1, sizeof(*lzo) + lzo_algs[other->algorithm].bufsize);
if (lzo == NULL)
return NULL;
@@ -209,8 +209,8 @@ sqfs_compressor_t *lzo_compressor_create(const sqfs_compressor_config_t *cfg)
return NULL;
}
- lzo = alloc_flex(sizeof(*lzo), 1,
- lzo_algs[cfg->opt.lzo.algorithm].bufsize);
+ lzo = calloc(1,
+ sizeof(*lzo) + lzo_algs[cfg->opt.lzo.algorithm].bufsize);
base = (sqfs_compressor_t *)lzo;
if (lzo == NULL)
diff --git a/lib/common/mkdir_p.c b/lib/common/mkdir_p.c
index a568567..0413495 100644
--- a/lib/common/mkdir_p.c
+++ b/lib/common/mkdir_p.c
@@ -12,9 +12,6 @@
#include <errno.h>
#ifdef _WIN32
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-
/*
Supported paths:
- <letter>:\ <absolute path>
@@ -85,25 +82,13 @@ static WCHAR *skip_prefix(WCHAR *ptr)
int mkdir_p(const char *path)
{
WCHAR *wpath, *ptr, *end;
- DWORD length, error;
+ DWORD error;
bool done;
- length = MultiByteToWideChar(CP_UTF8, 0, path, -1, NULL, 0) + 1;
- wpath = alloc_array(sizeof(wpath[0]), length);
- if (wpath == NULL) {
- fprintf(stderr, "Converting UTF-8 path to UTF-16: %ld\n",
- GetLastError());
+ wpath = path_to_windows(path);
+ if (wpath == NULL)
return -1;
- }
-
- MultiByteToWideChar(CP_UTF8, 0, path, -1, wpath, length);
- wpath[length - 1] = '\0';
-
- for (ptr = wpath; *ptr != '\0'; ++ptr) {
- if (*ptr == '/')
- *ptr = '\\';
- }
ptr = skip_prefix(wpath);
if (ptr == NULL) {
diff --git a/lib/common/serialize_fstree.c b/lib/common/serialize_fstree.c
index 14a5a4e..42843e2 100644
--- a/lib/common/serialize_fstree.c
+++ b/lib/common/serialize_fstree.c
@@ -19,7 +19,7 @@ static sqfs_inode_generic_t *tree_node_to_inode(tree_node_t *node)
if (S_ISLNK(node->mode))
extra = strlen(node->data.slink_target);
- inode = alloc_flex(sizeof(*inode), 1, extra);
+ inode = calloc(1, sizeof(*inode) + extra);
if (inode == NULL) {
perror("creating inode");
return NULL;
diff --git a/lib/common/write_export_table.c b/lib/common/write_export_table.c
index c797577..c0d4993 100644
--- a/lib/common/write_export_table.c
+++ b/lib/common/write_export_table.c
@@ -20,7 +20,7 @@ int write_export_table(const char *filename, sqfs_file_t *file,
if (fs->inode_tbl_size < 1)
return 0;
- table = alloc_array(sizeof(sqfs_u64), fs->inode_tbl_size);
+ table = calloc(1, sizeof(sqfs_u64) * fs->inode_tbl_size);
if (table == NULL) {
perror("Allocating NFS export table");