[Scummvm-cvs-logs] SF.net SVN: scummvm:[39661] scummvm/trunk/engines/sci

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Tue Mar 24 13:14:23 CET 2009


Revision: 39661
          http://scummvm.svn.sourceforge.net/scummvm/?rev=39661&view=rev
Author:   fingolfin
Date:     2009-03-24 12:14:22 +0000 (Tue, 24 Mar 2009)

Log Message:
-----------
SCI: moved sci_strndup to menubar.cpp

Modified Paths:
--------------
    scummvm/trunk/engines/sci/gfx/menubar.cpp
    scummvm/trunk/engines/sci/sci_memory.cpp
    scummvm/trunk/engines/sci/sci_memory.h

Modified: scummvm/trunk/engines/sci/gfx/menubar.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/menubar.cpp	2009-03-24 12:01:54 UTC (rev 39660)
+++ scummvm/trunk/engines/sci/gfx/menubar.cpp	2009-03-24 12:14:22 UTC (rev 39661)
@@ -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() {

Modified: scummvm/trunk/engines/sci/sci_memory.cpp
===================================================================
--- scummvm/trunk/engines/sci/sci_memory.cpp	2009-03-24 12:01:54 UTC (rev 39660)
+++ scummvm/trunk/engines/sci/sci_memory.cpp	2009-03-24 12:14:22 UTC (rev 39661)
@@ -95,24 +95,4 @@
 	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

Modified: scummvm/trunk/engines/sci/sci_memory.h
===================================================================
--- scummvm/trunk/engines/sci/sci_memory.h	2009-03-24 12:01:54 UTC (rev 39660)
+++ scummvm/trunk/engines/sci/sci_memory.h	2009-03-24 12:14:22 UTC (rev 39661)
@@ -75,17 +75,6 @@
 ** 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


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list