aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/gfx
diff options
context:
space:
mode:
authorMax Horn2009-03-24 12:14:22 +0000
committerMax Horn2009-03-24 12:14:22 +0000
commit608b839720a028b5ecffa5955b024387740583d7 (patch)
tree663bd1fcc7f958a93b5f96e75863639cc4f482b8 /engines/sci/gfx
parentc1be6e1ed68fdb9826a5fe189f01c520238e37af (diff)
downloadscummvm-rg350-608b839720a028b5ecffa5955b024387740583d7.tar.gz
scummvm-rg350-608b839720a028b5ecffa5955b024387740583d7.tar.bz2
scummvm-rg350-608b839720a028b5ecffa5955b024387740583d7.zip
SCI: moved sci_strndup to menubar.cpp
svn-id: r39661
Diffstat (limited to 'engines/sci/gfx')
-rw-r--r--engines/sci/gfx/menubar.cpp23
1 files changed, 23 insertions, 0 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() {