mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-31 13:10:34 +00:00
[qfcc] Add a function to safely get cwd
getcwd is assumed to use malloc if its buff param is null. This may need fixing in the future, but it's in one spot. The result in "saved" in the non-progs pool.
This commit is contained in:
parent
4b34bf3d95
commit
9089744290
2 changed files with 12 additions and 0 deletions
|
@ -53,6 +53,8 @@ int strpool_addstr (strpool_t *strpool, const char *str);
|
|||
*/
|
||||
const char *save_string (const char *str);
|
||||
|
||||
const char *save_cwd (void);
|
||||
|
||||
const char *make_string (char *token, char **end);
|
||||
|
||||
const char *html_string (const char *str);
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "QF/dstring.h"
|
||||
#include "QF/hash.h"
|
||||
|
@ -140,6 +141,15 @@ save_string (const char *str)
|
|||
return s;
|
||||
}
|
||||
|
||||
const char *
|
||||
save_cwd (void)
|
||||
{
|
||||
char *cwd = getcwd (0, 0);
|
||||
const char *str = save_string (cwd);
|
||||
free (cwd);
|
||||
return str;
|
||||
}
|
||||
|
||||
const char *
|
||||
make_string (char *token, char **end)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue