libroot: avoid excessive stack usage in __find_directory()
create_path() is inlined in __find_directory().
This commit is contained in:
committed by
waddlesplash
parent
70422d06a9
commit
48c1ae929e
@@ -19,6 +19,7 @@
|
|||||||
#include <directories.h>
|
#include <directories.h>
|
||||||
#include <FindDirectory.h>
|
#include <FindDirectory.h>
|
||||||
#include <fs_info.h>
|
#include <fs_info.h>
|
||||||
|
#include <StackOrHeapArray.h>
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
@@ -195,13 +196,14 @@ static const char *kUserDirectories[] = {
|
|||||||
static int
|
static int
|
||||||
create_path(const char *path, mode_t mode)
|
create_path(const char *path, mode_t mode)
|
||||||
{
|
{
|
||||||
char buffer[B_PATH_NAME_LENGTH + 1];
|
|
||||||
int pathLength;
|
int pathLength;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
if (path == NULL || ((pathLength = strlen(path)) > B_PATH_NAME_LENGTH))
|
if (path == NULL || ((pathLength = strlen(path)) > B_PATH_NAME_LENGTH))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
|
||||||
|
BStackOrHeapArray<char, 128> buffer(pathLength + 1);
|
||||||
|
|
||||||
while (++i < pathLength) {
|
while (++i < pathLength) {
|
||||||
char *slash = strchr(&path[i], '/');
|
char *slash = strchr(&path[i], '/');
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|||||||
Reference in New Issue
Block a user