New helper function "char *dup_filename(const char *fn)" in common.h.

It allocates a buffer of size BMAX_PATH and copies the passed string into it.

git-svn-id: https://svn.eduke32.com/eduke32@2560 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2012-03-28 19:43:39 +00:00
parent 0e3adea64e
commit 77918caf9c
2 changed files with 12 additions and 0 deletions

View file

@ -60,4 +60,6 @@ int32_t fnlist_getnames(fnlist_t *fnl, const char *dirname, const char *pattern,
void G_LoadGroupsInDir(const char *dirname);
void G_DoAutoload(const char *dirname);
char *dup_filename(const char *fn);
#endif

View file

@ -167,3 +167,13 @@ void G_DoAutoload(const char *dirname)
Bsnprintf(buf, sizeof(buf), "autoload/%s", dirname);
G_LoadGroupsInDir(buf);
}
////
// returns a buffer of size BMAX_PATH
char *dup_filename(const char *fn)
{
char *buf = Bmalloc(BMAX_PATH);
return Bstrncpyz(buf, fn, BMAX_PATH);
}