Drizzled Public API Documentation

CSMemory.h
00001 /* Copyright (C) 2008 PrimeBase Technologies GmbH, Germany
00002  *
00003  * PrimeBase Media Stream for MySQL
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation; either version 2 of the License, or
00008  * (at your option) any later version.
00009  *
00010  * This program 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
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00018  *
00019  * Original author: Paul McCullagh (H&G2JCtL)
00020  * Continued development: Barry Leslie
00021  *
00022  * 2007-06-15
00023  *
00024  * CORE SYSTEM:
00025  * Memory allocation
00026  *
00027  */
00028 
00029 #pragma once
00030 #ifndef __CSMEMORY_H__
00031 #define __CSMEMORY_H__
00032 
00033 #include "CSDefs.h"
00034 
00035 bool cs_init_memory(void);
00036 void cs_exit_memory(void);
00037 
00038 void *cs_malloc(size_t size);
00039 void *cs_calloc(size_t size);
00040 void cs_realloc(void **ptr, size_t size);
00041 void cs_free(void *);
00042 
00043 #define cs_memmove(dst, src, size)    memmove(dst, src, size)
00044 #define cs_memcpy(dst, src, size)   memcpy(dst, src, size)
00045 #define cs_memset(b, v, size)     memset(b, v, size)
00046 
00047 #ifdef DEBUG
00048 #define cs_malloc(siz)      cs_mm_malloc(CS_CONTEXT, siz)
00049 #define cs_calloc(siz)      cs_mm_calloc(CS_CONTEXT, siz)
00050 #define cs_realloc(ptr, siz)  cs_mm_realloc(CS_CONTEXT, ptr, siz)
00051 #define cs_free(ptr)      cs_mm_free(ptr)
00052 /*
00053 #define cs_memmove(dst, src, size)    cs_mm_memmove(dst, src, size)
00054 #define cs_memcpy(dst, src, size)   cs_mm_memcpy(dst, src, size)
00055 #define cs_memset(b, v, size)     cs_mm_memset(b, v, size)
00056 */
00057 
00058 bool cs_mm_scan_core(void);
00059 void cs_mm_memmove(void *block, void *dest, void *source, size_t size);
00060 void cs_mm_memcpy(void *block, void *dest, void *source, size_t size);
00061 void cs_mm_memset(void *block, void *dest, int value, size_t size);
00062 void *cs_mm_malloc(const char *func, const char *file, int line, size_t size);
00063 void *cs_mm_calloc(const char *func, const char *file, int line, size_t size);
00064 void cs_mm_realloc(const char *func, const char *file, int line, void **ptr, size_t newsize);
00065 void cs_mm_free(void *ptr);
00066 void cs_mm_pfree(void **ptr);
00067 size_t cs_mm_malloc_size(void *ptr);
00068 void cs_mm_print_track(const char *func, const char *file, uint32_t line, void *p, bool inc, uint32_t ref_cnt, int track_me);
00069 void cs_mm_track_memory(const char *func, const char *file, uint32_t line, void *p, bool inc, uint32_t ref_cnt, int track_me);
00070 uint32_t cs_mm_get_check_point();
00071 void cs_mm_assert_check_point(uint32_t check_point);
00072 #endif
00073 
00074 #endif
00075