The reference count is clever and convenient, but most of the processing processes involve pointers, which are cumbersome and error-prone. To address this problem, Cocos2d-x is accurate for us
A series of auxiliary macros are provided to simplify the Code. These macros are included in the header file "ccplatform Macro. H. Table 2-2 lists the macros related to memory management. ? Table 2-2 memory management-related macros in the Cocos2d-x
? Macro |
? Description |
? Cc_safe_delete (P) |
? Use the delete operator to delete a C ++ object P ,? If P is null, no operation is performed. |
? Cc_safe_delete_array (P) |
? Use the Delete [] operator to delete a C ++ array P ,? If P is null, no operation is performed. |
? Cc_safe_free (P) |
? Use the free () function to delete p. If P is null ,? No operation |
? Cc_safe_release (P) |
? Use the release () method to release the Cocos2d-x object P |
32
Cocos2d-x advanced development tutorial
|
? If P is null, no operation is performed. |
? Cc_safe_release_null (P) |
? Use the release () method to release the Cocos2d-x object P? For a single reference, P is assigned null. If P already exists ? If it is null, no operation is performed. |
? Cc_safe_retain (P) |
? Use the reatin () method to add one of the Cocos2d-x object P? . If P is null, no operation is performed. |