sprint 1-alpha
sprint/utils/mem.h
Go to the documentation of this file.
00001 /******************************************************************************
00002 *   SPRINT::utils::mem
00003 *
00004 *   Copyright (C) 2005-2010  Paolo Medici <www.pmx.it>
00005 *
00006  *  This library is free software; you can redistribute it and/or
00007  *  modify it under the terms of the GNU Lesser General Public
00008  *  License as published by the Free Software Foundation; either
00009  *  version 2.1 of the License, or (at your option) any later version.
00010  *
00011  *  This library is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  *  Lesser General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU Lesser General Public
00017  *  License along with this library; if not, write to the Free Software
00018  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00019  *
00020  *******************************************************************************/
00021 
00022 #ifndef _SPRINT_UTILS_MEM_H
00023 #define _SPRINT_UTILS_MEM_H
00024 
00029 #ifdef __cplusplus
00030 extern "C" {
00031 #endif
00032 
00033 /*
00034 extern HANDLE _crtheap;
00035 
00036 #define my_alloc(size)  HeapAlloc(_crtheap,0,size);
00037 #define my_free(ptr)    HeapFree(_crtheap,0,ptr);
00038 */
00039 
00040 #define my_alloc(size)  malloc(size)
00041 #define mem_free(ptr)   free(ptr)
00042 #define my_free(ptr)    if(ptr) free(ptr)
00043 
00044 unsigned int my_getsize(void *ptr);
00045 
00046 /* definite in strmem.cpp */
00047 char *clone_string(const char *src);
00048 char *concatenate_string(const char *a, const char *b);
00049 char *concatenate_string3(const char *a, const char *b, const char *c);
00050 
00051 #define clonestring(s)  clone_string(s)
00052 
00053 char *clone_string_ext(const char *src, int max);
00054 char *create_string(const char *format, ...);
00055 
00056 const char *memchrr(const char *src, char c, int len);
00057 int crlfstr(char *dst, const char *src, int line_size);
00058 char *clone_string_ext(const char *src, int max);
00059 
00060 void *clone_structure(void *source, unsigned int size);
00061 
00062 
00063 typedef struct _HEAPSTATS
00064 {
00065         unsigned int nblock;
00066         unsigned int totalmemory;
00067 } HEAPSTATS, *LPHEAPSTATS;
00068 
00069 
00071 void GetHeapStatistics(LPHEAPSTATS lphp);
00072 
00073 
00074 #ifdef __cplusplus
00075 }
00076 #endif
00077 
00078 #ifdef __cplusplus
00079 
00080 /*
00081 inline void * operator new( unsigned int cb )
00082 {
00083 return  my_alloc(cb);
00084 }
00085 
00086 inline void operator delete(void *p)
00087 {
00088         my_free(p);
00089 }
00090 */
00091 
00092 /*
00093 inline void * operator new( unsigned int cb );
00094 inline void operator delete( void * p );
00095 */
00096 
00097 #endif
00098 
00099 #endif
00100 
00101 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines