mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 13:37:45 +00:00
Userland: Use kmalloc_array() where appropriate
This commit is contained in:
parent
3609ac4cf9
commit
84656788bf
4 changed files with 14 additions and 14 deletions
|
@ -255,7 +255,7 @@ int scandir(const char* dir_name,
|
|||
}
|
||||
|
||||
const int size = tmp_names.size();
|
||||
auto names = (struct dirent**)malloc(size * sizeof(struct dirent*));
|
||||
auto** names = static_cast<struct dirent**>(kmalloc_array(size, sizeof(struct dirent*)));
|
||||
for (auto i = 0; i < size; i++) {
|
||||
names[i] = tmp_names[i];
|
||||
}
|
||||
|
|
|
@ -350,7 +350,7 @@ int putenv(char* new_var)
|
|||
|
||||
// At this point, we need to append the new var.
|
||||
// 2 here: one for the new var, one for the sentinel value.
|
||||
char** new_environ = (char**)malloc((environ_size + 2) * sizeof(char*));
|
||||
auto** new_environ = static_cast<char**>(kmalloc_array(environ_size + 2, sizeof(char*)));
|
||||
if (new_environ == nullptr) {
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue