Newer
Older
libj / include / j / memory_mark.hpp
/**
 * @file memory_mark.hpp
 * @brief J Library Memory Mark ヘッダファイル。
 * @copyright  2001 - 2024  Nomura Kei
 * @depends
 *   j.hpp
 */
#ifndef J_MEMORY_MARK_HPP
#define J_MEMORY_MARK_HPP

#include <j.hpp>

namespace j
{

    /**
     * メモリ状態
     */
    enum MemoryMark
    {
        DELETED = 0x55AA0000,                    //!< 解放済みメモリ
        ALLOCATED = 0x55AA1111,                  //!< 確保済みメモリ
        ALLOCATED_ALIGNED = 0x55AA11FF,          //!< 確保済みメモリ(aligned)
        ALLOCATED_NEW = 0x55AA2222,              //!< 確保済みメモリ(new)
        ALLOCATED_NEW_ALIGNED = 0x55AA22FF,      //!< 確保済みメモリ(new)
        ALLOCATED_NEW_ARRAY = 0x55AA4444,        //!< 確保済みメモリ(new[])
        ALLOCATED_NEW_ARRAY_ALIGNED = 0x55AA44FF //!< 確保済みメモリ(new[])
    };

#define IS_MANAGED_MEMORY(mark) ((mark & 0xFFFF0000) == 0x55AA0000)
#define IS_MANAGED_ALIGNED(mark) ((mark & 0xFFFF00FF) == 0x55AA00FF)
#define TO_NO_ALIGNED(mark) (((mark | 0x0000FF00) >> 8) | (mark & 0xFFFFFF00))

} // namespace j

#endif // J_MEMORY_MARK_HPP