From: Holger Schemel Date: Fri, 23 Feb 2024 15:02:27 +0000 (+0100) Subject: added function to allocate and copy memory X-Git-Tag: 4.4.0.0-test-1~309 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=ac60e2c46ea31c5dc6a71a393c0ea3fcf60ceb7a;p=rocksndiamonds.git added function to allocate and copy memory --- diff --git a/src/libgame/misc.c b/src/libgame/misc.c index 5fd8e3c2..c96fa177 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -1084,6 +1084,24 @@ char *getBasePath(char *filename) } +// ---------------------------------------------------------------------------- +// various string functions +// ---------------------------------------------------------------------------- + +void *getMemCopy(const void *m, size_t size) +{ + void *m_copy; + + if (m == NULL) + return NULL; + + m_copy = checked_malloc(size); + memcpy(m_copy, m, size); + + return m_copy; +} + + // ---------------------------------------------------------------------------- // various string functions // ---------------------------------------------------------------------------- diff --git a/src/libgame/misc.h b/src/libgame/misc.h index e78185c5..111610f8 100644 --- a/src/libgame/misc.h +++ b/src/libgame/misc.h @@ -168,6 +168,8 @@ char *getBaseName(char *); char *getBaseNamePtr(char *); char *getBaseNameNoSuffix(char *); +void *getMemCopy(const void *, size_t); + char *getStringCat2WithSeparator(const char *, const char *, const char *); char *getStringCat3WithSeparator(const char *, const char *, const char *, const char *); char *getStringCat2(const char *, const char *);