From 77918caf9c3ac640ec338b9a3f663757b17edc2b Mon Sep 17 00:00:00 2001 From: helixhorned Date: Wed, 28 Mar 2012 19:43:39 +0000 Subject: [PATCH] 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 --- polymer/eduke32/build/include/common.h | 2 ++ polymer/eduke32/source/common.c | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/polymer/eduke32/build/include/common.h b/polymer/eduke32/build/include/common.h index 742c89a03..76757a900 100644 --- a/polymer/eduke32/build/include/common.h +++ b/polymer/eduke32/build/include/common.h @@ -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 diff --git a/polymer/eduke32/source/common.c b/polymer/eduke32/source/common.c index 651032f5e..eecd4f7f6 100644 --- a/polymer/eduke32/source/common.c +++ b/polymer/eduke32/source/common.c @@ -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); +}