knight/shared/KeCodeAllocator.h
author David Anderson <dvander@alliedmods.net>
Wed Feb 25 20:10:12 2009 -0500 (2009-02-25)
changeset 2610 8be4ff862bf0
parent 2226 d10b38524be3
child 3980 dc7dfcd855dc
permissions -rw-r--r--
Added tag sourcemod-1.1.1 for changeset ffa740152efd
     1 #ifndef _INCLUDE_KNIGHT_KE_CODE_ALLOCATOR_H_
     2 #define _INCLUDE_KNIGHT_KE_CODE_ALLOCATOR_H_
     3 
     4 #include <KeLinking.h>
     5 #include <KeStdTypes.h>
     6 
     7 namespace Knight
     8 {
     9 	class KeCodeCache;
    10 
    11 	/**
    12 	 * @brief Creates a new code cache/allocator.
    13 	 *
    14 	 * @return				New code cache allocator.
    15 	 */
    16 	extern KeCodeCache *KE_CreateCodeCache();
    17 
    18 	/**
    19 	 * @brief Destroys a code cache allocator.
    20 	 *
    21 	 * @param cache			Code cache object.
    22 	 */
    23 	extern void KE_DestroyCodeCache(KeCodeCache *cache);
    24 
    25 	/**
    26 	 * @brief Allocates code memory that is readable, writable, 
    27 	 * and executable.
    28 	 *
    29 	 * The address returned wlil be aligned, minimally, on a 16-byte 
    30 	 * boundary.
    31 	 *
    32 	 * @param cache			Code cache object.
    33 	 * @param size			Amount of memory needed.
    34 	 * @return				Address pointing to the memory.
    35 	 */
    36 	extern void *KE_AllocCode(KeCodeCache *cache, size_t size);
    37 
    38 	/**
    39 	 * @brief Frees code memory.
    40 	 *
    41 	 * @param cache			Code cache object.
    42 	 * @param code			Address of code memory.
    43 	 */
    44 	extern void KE_FreeCode(KeCodeCache *cache, void *code);
    45 }
    46 
    47 #endif //_INCLUDE_KNIGHT_KE_CODE_ALLOCATOR_H_