/**
* @file kc_memory_mark.h
* @brief KC メモリ管理 メモリ状態を扱うサブモジュール (mark)
* @copyright 2003 - 2023 Nomura Kei
* @depends
* kc.h
*
* 本ヘッダファイルを直接 include せず、kc_memory.h を include してください。
*/
#ifndef KC_MEMORY_MARK_H
#define KC_MEMORY_MARK_H
#include <kc.h>
#ifdef __cplusplus
extern "C"
{
namespace kc
{
using namespace std;
#endif
/**
* 指定された KcMemoryMark の値が、管理メモリか否かを判定します。
*
* @param mark 判定する KcMemoryMark
* @return true/false (管理メモリ/管理メモリ外)
*/
#define KC_MEMORY_IS_MANAGED(mark) ((mark & 0xFFFF0000) == 0x55AA0000)
/**
* メモリ状態
*/
typedef enum
{
KC_MEMORY_DELETED = 0x55AA0000, //!< 解放済み
KC_MEMORY_ALLOCATED = 0x55AA1111, //!< 確保済み
KC_MEMORY_ALLOCATED_ALIGNED = 0x55AA1155 //!< 確保済み(aligned)
// KC_MEMORY_ALLOCATED_NEW = 0x55AA2222, //!< new により確保済み
// KC_MEMORY_ALLOCATED_NEW_ARRAY = 0x55AA4444 //!< new[] により確保済み
} KcMemoryMark;
/**
* 指定されたメモリ状態に対応する文字列表現を返します。
* 返される文字列は、次の通り
* - alloc : malloc, calloc, realloc によりメモリが確保された
* - new : new によりメモリが確保された
* - new[] : new[] によりメモリが確保された
* - delete : 削除済みメモリ
* - other : 不明
*
* @param mark メモリ状態
* @return メモリ状態に対応する文字列表現
*/
const char *KcMemoryMark_to_string(int mark);
#ifdef __cplusplus
} // namespace kc
} // extern "C"
#endif
#endif // KC_MEMORY_MARK_H