core: Move __getcwd_buf to Mes C Library.
* include/mes/mes.h (__getcwd_buf): Move to.. * lib/posix/getcwd.c (__getcwd_buf): ...here. (getcwd): Refactor. * src/posix.c (getcwd_): Do not use __getcwd_buf.
This commit is contained in:
parent
0d337be8ff
commit
b23c6885a6
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2016,2017,2018,2019,2020,2021 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -100,7 +100,6 @@ struct timespec *gc_end_time;
|
|||
size_t gc_time;
|
||||
|
||||
char **__execl_c_argv;
|
||||
char *__getcwd_buf;
|
||||
char *__open_boot_buf;
|
||||
char *__open_boot_file_name;
|
||||
char *__setenv_buf;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2016,2017,2018,2019,2020,2021 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -26,13 +26,17 @@
|
|||
|
||||
// CONSTANT PATH_MAX 1024
|
||||
|
||||
char *__getcwd_buf;
|
||||
|
||||
char *
|
||||
getcwd (char *buffer, int size)
|
||||
{
|
||||
if (__getcwd_buf == 0)
|
||||
if (buffer == 0)
|
||||
buffer = __getcwd_buf;
|
||||
if (buffer == 0)
|
||||
{
|
||||
__getcwd_buf = malloc (PATH_MAX);
|
||||
char *buf = __getcwd_buf;
|
||||
if (buffer != 0)
|
||||
buffer = __getcwd_buf;
|
||||
}
|
||||
return _getcwd (buffer, size);
|
||||
return _getcwd (buf, PATH_MAX);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2016,2017,2018,2019,2020,2021 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -161,7 +161,6 @@ init (char **envp)
|
|||
{
|
||||
environ = envp;
|
||||
__execl_c_argv = malloc (1024 * sizeof (char *)); /* POSIX minimum: 4096 */
|
||||
__getcwd_buf = malloc (PATH_MAX);
|
||||
__gettimeofday_time = malloc (sizeof (struct timeval));
|
||||
__get_internal_run_time_ts = malloc (sizeof (struct timespec));
|
||||
__open_boot_buf = malloc (PATH_MAX);
|
||||
|
|
|
@ -435,8 +435,7 @@ get_internal_run_time ()
|
|||
struct scm *
|
||||
getcwd_ () /*:((name . "getcwd")) */
|
||||
{
|
||||
char *buf = __getcwd_buf;
|
||||
return make_string0 (getcwd (buf, PATH_MAX));
|
||||
return make_string0 (getcwd (0, PATH_MAX));
|
||||
}
|
||||
|
||||
struct scm *
|
||||
|
|
Loading…
Reference in a new issue