aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/sci/gfx/menubar.cpp23
-rw-r--r--engines/sci/sci_memory.cpp20
-rw-r--r--engines/sci/sci_memory.h11
3 files changed, 23 insertions, 31 deletions
diff --git a/engines/sci/gfx/menubar.cpp b/engines/sci/gfx/menubar.cpp
index 7a01cac7c9..242bba3f42 100644
--- a/engines/sci/gfx/menubar.cpp
+++ b/engines/sci/gfx/menubar.cpp
@@ -36,6 +36,29 @@
namespace Sci {
+
+/* Copies a string into a newly allocated memory part, up to a certain length.
+** Parameters: (char *) src: The source string
+** (int) length: The maximum length of the string (not counting
+** a trailing \0).
+** Returns : (char *) The resulting copy, allocated with sci_malloc().
+** To free this string, use the free() command.
+** See _SCI_MALLOC() for more information if call fails.
+*/
+char *sci_strndup(const char *src, size_t length) {
+ assert(src);
+
+ size_t rlen = (int)MIN(strlen(src), length) + 1;
+ char *strres = (char *)malloc(rlen);
+ assert(strres);
+
+ strncpy(strres, src, rlen);
+ strres[rlen - 1] = 0;
+
+ return strres;
+}
+
+
#define SIZE_INF 32767
Menu::Menu() {
diff --git a/engines/sci/sci_memory.cpp b/engines/sci/sci_memory.cpp
index 7fa3a5d4aa..c7bd78c16e 100644
--- a/engines/sci/sci_memory.cpp
+++ b/engines/sci/sci_memory.cpp
@@ -95,24 +95,4 @@ char *sci_strdup(const char *src) {
return (char*)res;
}
-char *sci_strndup(const char *src, size_t length) {
- void *res;
- char *strres;
- size_t rlen = (int)MIN(strlen(src), length) + 1;
-
- if (!src) {
- fprintf(stderr, "_SCI_STRNDUP() [%s (%s) : %u]\n",
- __FILE__, "", __LINE__);
- fprintf(stderr, " attempt to strndup NULL pointer\n");
- BREAKPOINT();
- }
- ALLOC_MEM((res = malloc(rlen)), rlen, __FILE__, __LINE__, "")
-
- strres = (char *)res;
- strncpy(strres, src, rlen);
- strres[rlen - 1] = 0;
-
- return strres;
-}
-
} // End of namespace Sci
diff --git a/engines/sci/sci_memory.h b/engines/sci/sci_memory.h
index d3bc4a16d9..8aec598876 100644
--- a/engines/sci/sci_memory.h
+++ b/engines/sci/sci_memory.h
@@ -75,17 +75,6 @@ extern char *sci_strdup(const char *src);
** See _SCI_MALLOC() for more information if call fails.
*/
-
-extern char *sci_strndup(const char *src, size_t length);
-/* Copies a string into a newly allocated memory part, up to a certain length.
-** Parameters: (char *) src: The source string
-** (int) length: The maximum length of the string (not counting
-** a trailing \0).
-** Returns : (char *) The resulting copy, allocated with sci_malloc().
-** To free this string, use the free() command.
-** See _SCI_MALLOC() for more information if call fails.
-*/
-
} // End of namespace Sci
#endif // SCI_SCI_MEMORY_H