summaryrefslogtreecommitdiff
path: root/arch/sandbox/cpu/os.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2018-11-15 18:44:06 -0700
committerTom Rini <trini@konsulko.com>2018-11-26 08:25:37 -0500
commitfc1f58a4da74a8c123241f42a87200d59ee08e81 (patch)
treed73157df72c6ba0dde7a4ba44cb712a7096d57d3 /arch/sandbox/cpu/os.c
parent7b5ea1452742be72a28f52f4602c986eb342779b (diff)
sandbox: Use malloc() and free() from os layer
At present sandbox calls malloc() from various places in the OS layer and this results in calls to U-Boot's malloc() implementation. It is better to use the on in the OS layer, since it does not mix allocations with the main U-Boot code. Fix this by replacing calls with malloc() to os_malloc(), etc. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Joe Hershberger <joe.hershberger@ni.com>
Diffstat (limited to 'arch/sandbox/cpu/os.c')
-rw-r--r--arch/sandbox/cpu/os.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c
index acc5e70d2d3..d817dcc4794 100644
--- a/arch/sandbox/cpu/os.c
+++ b/arch/sandbox/cpu/os.c
@@ -381,7 +381,7 @@ void os_dirent_free(struct os_dirent_node *node)
while (node) {
next = node->next;
- free(node);
+ os_free(node);
node = next;
}
}
@@ -406,7 +406,7 @@ int os_dirent_ls(const char *dirname, struct os_dirent_node **headp)
/* Create a buffer upfront, with typically sufficient size */
dirlen = strlen(dirname) + 2;
len = dirlen + 256;
- fname = malloc(len);
+ fname = os_malloc(len);
if (!fname) {
ret = -ENOMEM;
goto done;
@@ -419,7 +419,7 @@ int os_dirent_ls(const char *dirname, struct os_dirent_node **headp)
ret = errno;
break;
}
- next = malloc(sizeof(*node) + strlen(entry->d_name) + 1);
+ next = os_malloc(sizeof(*node) + strlen(entry->d_name) + 1);
if (!next) {
os_dirent_free(head);
ret = -ENOMEM;
@@ -428,10 +428,10 @@ int os_dirent_ls(const char *dirname, struct os_dirent_node **headp)
if (dirlen + strlen(entry->d_name) > len) {
len = dirlen + strlen(entry->d_name);
old_fname = fname;
- fname = realloc(fname, len);
+ fname = os_realloc(fname, len);
if (!fname) {
- free(old_fname);
- free(next);
+ os_free(old_fname);
+ os_free(next);
os_dirent_free(head);
ret = -ENOMEM;
goto done;
@@ -465,7 +465,7 @@ int os_dirent_ls(const char *dirname, struct os_dirent_node **headp)
done:
closedir(dir);
- free(fname);
+ os_free(fname);
return ret;
}
@@ -582,7 +582,7 @@ static int add_args(char ***argvp, char *add_args[], int count)
for (argv = *argvp, argc = 0; (*argvp)[argc]; argc++)
;
- argv = malloc((argc + count + 1) * sizeof(char *));
+ argv = os_malloc((argc + count + 1) * sizeof(char *));
if (!argv) {
printf("Out of memory for %d argv\n", count);
return -ENOMEM;
@@ -645,7 +645,7 @@ static int os_jump_to_file(const char *fname)
os_exit(2);
err = execv(fname, argv);
- free(argv);
+ os_free(argv);
if (err)
return err;