void *MemPtrNewLarge(Int32 size) { // Allocate a chunk of memory where the size of the memory might exceed // 64k. There are a few potential problems here: // (a) the memory cannot be saved to a database // (b) if you forget to free the large chunk before // you application quits, you will cause a MEMORY LEAK on // Palm OS 5 and 5.1 . if (size > 65500) { SysAppInfoType *unusedAppInfoP; UInt16 currentOwnerID = SysGetAppInfo(&unusedAppInfoP, &unusedAppInfoP)->memOwnerID; return MemChunkNew(0, size, currentOwnerID | memNewChunkFlagNonMovable | memNewChunkFlagAllowLarge); } return MemPtrNew(size); }
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; }