diff --git a/Userland/Libraries/LibCore/System.cpp b/Userland/Libraries/LibCore/System.cpp index 01b882c76c..c7cc62c1aa 100644 --- a/Userland/Libraries/LibCore/System.cpp +++ b/Userland/Libraries/LibCore/System.cpp @@ -1837,4 +1837,12 @@ ErrorOr current_executable_path() return String::from_utf8({ path, strlen(path) }); } +ErrorOr allocate(size_t count, size_t size) +{ + auto* data = static_cast(calloc(count, size)); + if (!data) + return Error::from_errno(errno); + return Bytes { data, size * count }; +} + } diff --git a/Userland/Libraries/LibCore/System.h b/Userland/Libraries/LibCore/System.h index c905dae160..1774be6de7 100644 --- a/Userland/Libraries/LibCore/System.h +++ b/Userland/Libraries/LibCore/System.h @@ -280,4 +280,6 @@ char** environment(); ErrorOr current_executable_path(); +ErrorOr allocate(size_t count, size_t size); + }