[Scummvm-cvs-logs] SF.net SVN: scummvm:[34382] scummvm/trunk/backends/platform/symbian/src
anotherguest at users.sourceforge.net
anotherguest at users.sourceforge.net
Sat Sep 6 12:30:06 CEST 2008
Revision: 34382
http://scummvm.svn.sourceforge.net/scummvm/?rev=34382&view=rev
Author: anotherguest
Date: 2008-09-06 10:30:05 +0000 (Sat, 06 Sep 2008)
Log Message:
-----------
Portdefs cleanup, use snprintf from SDL and not sprintf (Which can cause memory overwrites).
Use bsearch implementation from WINCE port.
Modified Paths:
--------------
scummvm/trunk/backends/platform/symbian/src/SymbianOS.cpp
scummvm/trunk/backends/platform/symbian/src/portdefs.h
Modified: scummvm/trunk/backends/platform/symbian/src/SymbianOS.cpp
===================================================================
--- scummvm/trunk/backends/platform/symbian/src/SymbianOS.cpp 2008-09-06 08:37:03 UTC (rev 34381)
+++ scummvm/trunk/backends/platform/symbian/src/SymbianOS.cpp 2008-09-06 10:30:05 UTC (rev 34382)
@@ -479,6 +479,26 @@
return *_RFs;
}
+// Symbian bsearch implementation is flawed
+void* scumm_bsearch(const void *key, const void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *)) {
+ // Perform binary search
+ size_t lo = 0;
+ size_t hi = nmemb;
+ while (lo < hi) {
+ size_t mid = (lo + hi) / 2;
+ const void *p = ((const char *)base) + mid * size;
+ int tmp = (*compar)(key, p);
+ if (tmp < 0)
+ hi = mid;
+ else if (tmp > 0)
+ lo = mid + 1;
+ else
+ return (void *)p;
+ }
+
+ return NULL;
+}
+
FILE* symbian_fopen(const char* name, const char* mode) {
TSymbianFileEntry* fileEntry = new TSymbianFileEntry;
fileEntry->iInputPos = KErrNotFound;
Modified: scummvm/trunk/backends/platform/symbian/src/portdefs.h
===================================================================
--- scummvm/trunk/backends/platform/symbian/src/portdefs.h 2008-09-06 08:37:03 UTC (rev 34381)
+++ scummvm/trunk/backends/platform/symbian/src/portdefs.h 2008-09-06 10:30:05 UTC (rev 34382)
@@ -35,9 +35,6 @@
#include <e32std.h>
#include <math.h>
-//#define DISABLE_SCALERS // we only need 1x
-//#define DISABLE_HQ_SCALERS
-
#if defined(USE_TREMOR) && !defined(USE_VORBIS)
#define USE_VORBIS // make sure this one is defined together with USE_TREMOR!
#endif
@@ -107,29 +104,19 @@
*/
#elif defined (__WINS__) // WINS
+ extern "C" int SDL_snprintf(char *text, size_t maxlen, const char *fmt, ...);
+ extern "C" int SDL_vsnprintf(char *text, size_t maxlen, const char *fmt, va_list ap);
+ #define snprintf(buf,len,args...) SDL_snprintf(buf,len,args)
+ #define vsnprintf(buf,len,format,valist) SDL_vsnprintf(buf,len,format,valist)
- // let's just blatantly ignore this for now and just get it to work :P but does n't work from the debug function
- int inline scumm_snprintf (char *str, unsigned long /*n*/, char const *fmt, ...) {
- va_list args;
- va_start(args, fmt);
- vsprintf(str, fmt, args);
- va_end(args);
- return strlen(str);
- }
-
- int inline scumm_vsnprintf (char *str, unsigned long /*n*/, char const *fmt, va_list valist) {
- vsprintf(str, fmt, valist);
- return strlen(str);
- }
-
- #define snprintf scumm_snprintf
- #define vsnprintf scumm_vsnprintf
void* symbian_malloc (size_t _size);
#define malloc symbian_malloc
#else // GCCE and the rest
- #define snprintf(buf,len,args...) sprintf(buf,args)
- #define vsnprintf(buf,len,format,valist) vsprintf(buf,format,valist)
+ extern "C" int SDL_snprintf(char *text, size_t maxlen, const char *fmt, ...);
+ extern "C" int SDL_vsnprintf(char *text, size_t maxlen, const char *fmt, va_list ap);
+ #define snprintf(buf,len,args...) SDL_snprintf(buf,len,args)
+ #define vsnprintf(buf,len,format,valist) SDL_vsnprintf(buf,len,format,valist)
#endif
#ifndef __WINS__
@@ -138,20 +125,11 @@
#define USE_ARM_COSTUME_ASM
#define USE_ARM_SOUND_ASM
#endif
-// somehow nobody has this function...
-#define hypot(a, b) sqrt((a)*(a) + (b)*(b))
// Symbian bsearch implementation is flawed
-void inline *scumm_bsearch(const void *key, const void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *)) {
- size_t i;
+void *scumm_bsearch(const void *key, const void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *));
+#define bsearch scumm_bsearch
- for (i=0; i < nmemb; i++)
- if (compar(key, (void *)((size_t)base + size * i)) == 0)
- return (void *)((size_t)base + size * i);
- return NULL;
-}
-#define bsearch scumm_bsearch
-
// we cannot include SymbianOS.h everywhere, but this works too (functions code is in SymbianOS.cpp)
namespace Symbian {
extern void FatalError(const char *msg);
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