SophiaFramework UNIVERSE 5.3 |
Regarding all the memory operations in C++ language, the functions of tracing memory on the BREW Simulator are available.
The MemoryAllocate macro provides the memory allocation function with the capability of tracing memory on the BREW Simulator.
Caution | |
---|---|
The MemoryAllocate macro does not initialize the memory. |
The MemoryAllocate macro is replaced with SFDWatcher::malloc when the TARGET_ENVIRONMENT_SIMULATOR macro is defined, and is replaced with SFXHelper::malloc when the TARGET_ENVIRONMENT_PHYSICAL macro is defined.
SInt16Ptr p = reinterpret_cast<SInt16Ptr>(MemoryAllocate(sizeof(SInt16) * 256));
Note | |
---|---|
The 256 memory blocks of SInt16 type are allocated in the above code. |
Caution | |
---|---|
In SophiaFramework, the MemoryAllocate macro is used instead of the MALLOC and ERR_MALLOC BREW helper functions. |
The MemoryReallocate macro provides the memory reallocation function with the capability of tracing memory on the BREW Simulator.
The MemoryReallocate macro is replaced with SFDWatcher::realloc when the TARGET_ENVIRONMENT_SIMULATOR macro is defined, and is replaced with SFXHelper::realloc when the TARGET_ENVIRONMENT_PHYSICAL macro is defined.
Caution | |
---|---|
The MemoryReallocate macro does not initialize the memory. |
SInt16Ptr p = reinterpret_cast<SInt16Ptr>(MemoryAllocate(sizeof(SInt16) * 256)); ... p = reinterpret_cast<SInt16Ptr>(MemoryReallocate(p, sizeof(SInt16) * 4096));
Note | |
---|---|
In the above code, allocate the 256 memory blocks of SInt16 type, and then expand them to 4096 memory blocks of SInt16 type. |
Caution | |
---|---|
In SophiaFramework, the MemoryReallocate macro is used instead of the REALLOC and ERR_REALLOC BREW helper functions. |
The MemoryFree macro provides the memory free function with the capability of tracing memory on the BREW Simulator.
The MemoryFree macro is replaced with SFDWatcher::free when the TARGET_ENVIRONMENT_SIMULATOR macro is defined, and is replaced with SFXHelper::free when the TARGET_ENVIRONMENT_PHYSICAL macro is defined.
SInt16Ptr p = reinterpret_cast<SInt16Ptr>(MemoryAllocate(sizeof(SInt16) * 256)); ... MemoryFree(p);
Note | |
---|---|
The allocated memory area has been released. |
Caution | |
---|---|
In SophiaFramework, the MemoryFree macro is used instead of the FREE BREW helper function. |
The functions called by the new / delete operator depends on the definition of the TARGET_ENVIRONMENT_SIMULATOR / TARGET_ENVIRONMENT_PHYSICAL macro regarding the validity of memory tracing function as the table below.
Table 27.2. Macro and called functions
Operator | TARGET_ENVIRONMENT_SIMULATOR (valid memory tracing function) | TARGET_ENVIRONMENT_PHYSICAL (invalid memory tracing function) |
---|---|---|
new | SFDWatcher::malloc | SFXHelper::malloc |
delete | SFDWatcher::free | SFXHelper::free |
Caution | |
---|---|
The new operator will not initialize the memory if initiation is not described in the constructor. |
In SophiaFramework, the BREW helper functions for allocating and freeing memory can not be used.
Table 27.3. Macros, operators, functions, and classes substituting the BREW helper functions that can not be used in SophiaFramework
Unavailable BREW helper functions | Substitute macros, operators, functions, and classes |
---|---|
MALLOC, ERR_MALLOC | MemoryAllocate / new |
REALLOC, ERR_REALLOC | MemoryReallocate |
FREE | MemoryFree / new |
STRDUP, ERR_STRDUP | SFXAnsiString |
WSTRDUP | SFXWideString |
When the TARGET_ENVIRONMENT_SIMULATOR macro is defined, you can trace the memory on the BREW Simulator if the SFDWatcher classs is used for memory operation.
Reference: SFDWatcher
Copyright(c) 2002 - 2024 Sophia Cradle Incorporated All Rights Reserved. |