circlemud_squared_0.5.153/cnf/
circlemud_squared_0.5.153/etc/
circlemud_squared_0.5.153/etc/etc/
circlemud_squared_0.5.153/etc/house/
circlemud_squared_0.5.153/etc/misc/
circlemud_squared_0.5.153/etc/plralias/A-E/
circlemud_squared_0.5.153/etc/plralias/F-J/
circlemud_squared_0.5.153/etc/plralias/K-O/
circlemud_squared_0.5.153/etc/plralias/P-T/
circlemud_squared_0.5.153/etc/plralias/U-Z/
circlemud_squared_0.5.153/etc/plralias/ZZZ/
circlemud_squared_0.5.153/etc/plrobjs/
circlemud_squared_0.5.153/etc/plrobjs/A-E/
circlemud_squared_0.5.153/etc/plrobjs/F-J/
circlemud_squared_0.5.153/etc/plrobjs/K-O/
circlemud_squared_0.5.153/etc/plrobjs/P-T/
circlemud_squared_0.5.153/etc/plrobjs/U-Z/
circlemud_squared_0.5.153/etc/plrobjs/ZZZ/
circlemud_squared_0.5.153/etc/text/
circlemud_squared_0.5.153/etc/text/help/
circlemud_squared_0.5.153/src/util/
circlemud_squared_0.5.153/src/util/worldconv/
/**
 * @file memory.h
 *
 * Memory allocation wrappers.
 *
 * @author Geoff Davis <geoff@circlemudsquared.org>
 * @ingroup common
 * @license All rights reserved.  See license.doc for complete information.
 * @package cs
 * @since v1.0
 *
 * Copyright (C) 1993, 94 by the Trustees of the Johns Hopkins University
 * CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991.
 */

#ifndef __MEMORY_H__
#define __MEMORY_H__

/**
 * Allocates enough memory for an array of the specified type consisting of
 * the specified number of elements.
 * @param typeName the name of the type of each element
 * @param elemCount the number of elements to be allocated
 * @return a pointer to the allocated memory, or NULL
 */
#define CIRCLE_ALLOCN(typeName, elemCount) \
    ((sizeof(typeName) * (elemCount)) > 0 ? \
        ((typeName*) calloc((elemCount), sizeof(typeName))) : (typeName*) 0)

/**
 * Copies array elements (instead of bytes) from one place to another.
 * @param dest the location to which elements are to be written
 * @param src the location from which elements are to be read
 * @param typeName the name of the type of each element
 * @param elemCount the number of elements to be copied
 * @return none
 */
#define CIRCLE_COPYN(dest, src, typeName, elemCount) \
    do { \
        if ((dest) && (src) && (dest) != (src) && \
           ((elemCount) * sizeof(typeName)) > 0) { \
            memmove((dest), (src), sizeof(typeName) * (elemCount)); \
        } \
    } while (0)

/**
 * Frees the specified pointer.
 * @param p the pointer to the heap-allocated block to be freed
 * @return none
 */
#define CIRCLE_FREE(p) \
    do { \
        if ((p)) { \
            free(p); \
            (p) = NULL; \
        } \
    } while (0)

#endif /* __MEMORY_H__ */