aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Apers2006-02-11 18:31:05 +0000
committerChris Apers2006-02-11 18:31:05 +0000
commitf20193af5f3ff775bfaf785f75a1866e6de01657 (patch)
tree23254bba3e2cc87616e6510d671d16a46d3b920e
parent5638fae43908228bf5388ab60e8e76c48d6dea4e (diff)
downloadscummvm-rg350-f20193af5f3ff775bfaf785f75a1866e6de01657.tar.gz
scummvm-rg350-f20193af5f3ff775bfaf785f75a1866e6de01657.tar.bz2
scummvm-rg350-f20193af5f3ff775bfaf785f75a1866e6de01657.zip
- Get rid of MemGluePtrNew
- Fixed exit function in ARM mode - Fixed C++ compilation svn-id: r20563
-rw-r--r--backends/PalmOS/Src/missing/_stdlib.cpp48
-rw-r--r--backends/PalmOS/Src/missing/stdlib.h25
2 files changed, 54 insertions, 19 deletions
diff --git a/backends/PalmOS/Src/missing/_stdlib.cpp b/backends/PalmOS/Src/missing/_stdlib.cpp
index dbde113c34..f9e65a38d1 100644
--- a/backends/PalmOS/Src/missing/_stdlib.cpp
+++ b/backends/PalmOS/Src/missing/_stdlib.cpp
@@ -1,6 +1,7 @@
/* ScummVM - Scumm Interpreter
* Copyright (C) 2001 Ludvig Strigeus
* Copyright (C) 2001-2006 The ScummVM project
+ * Copyright (C) 2002-2006 Chris Apers - PalmOS Backend
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -23,6 +24,9 @@
#include <stdlib.h>
+#define memNewChunkFlagAllowLarge 0x1000
+extern "C" SysAppInfoPtr SysGetAppInfo(SysAppInfoPtr *uiAppPP, SysAppInfoPtr *actionCodeAppPP) SYS_TRAP(sysTrapSysGetAppInfo);
+
void *bsearch(const void *key, const void *base, UInt32 nmemb, UInt32 size, int (*compar)(const void *, const void *)) {
#ifdef PALMOS_68K
Int32 position;
@@ -52,11 +56,30 @@ long strtol(const char *s, char **endptr, int base) {
return val;
}
+MemPtr __malloc(UInt32 size) {
+ MemPtr newP = NULL;
+
+ if (size <= 65000) {
+ newP = MemPtrNew(size);
+ } else {
+ SysAppInfoPtr appInfoP;
+ UInt16 ownerID;
+ UInt16 attr;
+
+ ownerID = ((SysAppInfoPtr)SysGetAppInfo(&appInfoP, &appInfoP))->memOwnerID;
+ attr = ownerID|memNewChunkFlagAllowLarge|memNewChunkFlagNonMovable;
+
+ newP = MemChunkNew(0, size, attr);
+ }
+
+ return newP;
+}
+
MemPtr calloc(UInt32 nelem, UInt32 elsize) {
MemPtr newP;
- UInt32 size = nelem*elsize;
+ UInt32 size = (nelem * elsize);
- newP = MemGluePtrNew(size);
+ newP = malloc(size); // was MemGluePtrNew
if (newP)
MemSet(newP,size,0);
@@ -71,18 +94,17 @@ Err free(MemPtr memP) {
}
MemPtr realloc(MemPtr oldP, UInt32 size) {
-
if (oldP != NULL)
- if (MemPtrResize(oldP,size) == 0)
+ if (MemPtrResize(oldP, size) == 0)
return oldP;
- MemPtr newP = MemPtrNew(size);
-
- if (oldP!=NULL)
- {
+ MemPtr newP = malloc(size); // was MemPtrNew
+
+ if (oldP!=NULL) {
MemMove(newP,oldP,MemPtrSize(oldP));
MemPtrFree(oldP);
- }
+ }
+
return newP;
}
@@ -90,12 +112,12 @@ ErrJumpBuf stdlib_errJumpBuf;
#define ERR_MAGIC 0xDADA
void exit(Int16 status) {
-#ifdef PALMOS_68K
- EventType event;
- event.eType = keyDownEvent;
-#else
+#if (defined(PALMOS_ARM) && defined(COMPILE_ZODIAC))
SysEventType event;
event.eType = sysEventKeyDownEvent;
+#else
+ EventType event;
+ event.eType = keyDownEvent;
#endif
event.data.keyDown.chr = vchrLaunch;
event.data.keyDown.modifiers = commandKeyMask;
diff --git a/backends/PalmOS/Src/missing/stdlib.h b/backends/PalmOS/Src/missing/stdlib.h
index a56ae653c1..84f386e781 100644
--- a/backends/PalmOS/Src/missing/stdlib.h
+++ b/backends/PalmOS/Src/missing/stdlib.h
@@ -1,6 +1,7 @@
/* ScummVM - Scumm Interpreter
* Copyright (C) 2001 Ludvig Strigeus
* Copyright (C) 2001-2006 The ScummVM project
+ * Copyright (C) 2002-2006 Chris Apers - PalmOS Backend
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -30,8 +31,16 @@
#include "MemGlue.h"
#endif
-#if defined(COMPILE_ZODIAC) && defined(PALMOS_ARM)
-#define MemGluePtrNew MemPtrNew
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if defined(COMPILE_ZODIAC)
+# define malloc MemPtrNew
+#elif defined(COMPILE_OS5) && defined(PALMOS_ARM)
+# define malloc __malloc
+#else
+# define malloc MemGluePtrNew
#endif
extern ErrJumpBuf stdlib_errJumpBuf;
@@ -42,13 +51,12 @@ extern ErrJumpBuf stdlib_errJumpBuf;
#define atoi StrAToI
#define atol StrAToI
#define abs(a) ((a) < 0 ? -(a) : (a))
-#define malloc(a) MemGluePtrNew(a)
#ifdef PALMOS_68K
-#define qsort(a,b,c,d) SysQSort((a), (b), (c), (CmpFuncPtr)(&d), 0);
+# define qsort(a,b,c,d) SysQSort((a), (b), (c), (CmpFuncPtr)(&d), 0);
#else
-typedef int (*_compare_function)(const void*, const void*);
-extern "C" void qsort(void * table_base, size_t num_members, size_t member_size, _compare_function compare_members);
+ typedef int (*_compare_function)(const void*, const void*);
+ void qsort(void * table_base, UInt32 num_members, UInt32 member_size, _compare_function compare_members);
#endif
#define rand() SysRandom(0)
@@ -56,10 +64,15 @@ extern "C" void qsort(void * table_base, size_t num_members, size_t member_size,
#define strtoul(a,b,c) ((unsigned long)strtol(a,b,c))
void *bsearch (const void *key, const void *base, UInt32 nmemb, UInt32 size, int (*compar)(const void *, const void *));
+MemPtr __malloc (UInt32);
MemPtr calloc (UInt32 nelem, UInt32 elsize);
void exit (Int16 status);
Err free (MemPtr memP);
MemPtr realloc (MemPtr oldP, UInt32 size);
long strtol (const char *s, char **endptr, int base);
+#ifdef __cplusplus
+}
+#endif
+
#endif