Newer
Older
libkc / modules / src / kc_memory_mark.c

/**
 * @file  kc_memory_mark.c
 * @brief  KC メモリ管理 メモリ状態を扱うサブモジュール (mark)
 * @copyright  2003 - 2023  Nomura Kei
 */
#include <kc_memory_mark.h>

/**
 * 指定されたメモリ状態(mark)に対応する文字列表現を返します。
 * 返される文字列は、次の通り
 * - alloc  : malloc, calloc, realloc によりメモリが確保された
 * - new    : new によりメモリが確保された
 * - new[]  : new[] によりメモリが確保された
 * - delete : 削除済みメモリ
 * - other  : 不明
 *
 * @param mark メモリ状態
 * @return メモリ状態に対応する文字列表現
 */
const char *KcMemoryMark_to_string(int mark)
{
    switch (mark)
    {
    case KC_MEMORY_DELETED:
        return "delete";
    case KC_MEMORY_ALLOCATED:
        return "alloc ";
    case KC_MEMORY_ALLOCATED_NEW:
        return "new   ";
    case KC_MEMORY_ALLOCATED_NEW_ARRAY:
        return "new[] ";
    default:
        return "other ";
    }
}