00001 /* 00002 COSTA: Problem solving environment for data assimilation 00003 Copyright (C) 2011 Nils van Velzen 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Lesser General Public 00007 License as published by the Free Software Foundation; either 00008 version 2.1 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Lesser General Public License for more details. 00014 00015 You should have received a copy of the GNU Lesser General Public 00016 License along with this library; if not, write to the Free Software 00017 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 */ 00019 00020 /** 00021 \file cta_mem.h 00022 \brief Memory management routines. These routines are equivalent to standard C 00023 routines but allows us to do additional checking and debugging 00024 */ 00025 00026 #ifndef CTA_MEM_H 00027 #define CTA_MEM_H 00028 00029 #include <stdlib.h> 00030 #include "cta_system.h" 00031 00032 #ifdef __cplusplus 00033 extern "C" { 00034 #endif 00035 00036 /** \brief Free memory that has been allocated with CTA_Malloc or CTA_Realloc 00037 * 00038 * \param ptr I pointer to memory block to deallocate 00039 */ 00040 CTAEXPORT void CTA_Free(void *ptr); 00041 00042 /** \brief Allocates size bytes of memory and returns a pointer 00043 * to the allocated memory. 00044 * 00045 * \param size I number of bytes to allocate 00046 * 00047 * \return pointer to allocated memory. NULL is returned when allocation fails 00048 */ 00049 CTAEXPORT void * CTA_Malloc(size_t size); 00050 00051 /** \brief Changes the size of the allocated memory block pointed by ptr 00052 * Values in ptr are copied to returned memoy block 00053 * \param size I pointer to memoryblock of which the size is changed 00054 * \param size I number of bytes of returned memory block 00055 * 00056 * \return pointer to allocated memory. NULL is returned when allocation fails 00057 */ 00058 CTAEXPORT void * CTA_Realloc(void *ptr, size_t size); 00059 00060 #ifdef __cplusplus 00061 } 00062 #endif 00063 #endif 00064