Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

gust_new.h

Go to the documentation of this file.
00001 /* LIBGUL - Geometry Utility Library
00002  * Copyright (C) 1998-1999 Norbert Irmer
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Library General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2 of the License, or (at your option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Library General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Library General Public
00015  * License along with this library; if not, write to the
00016  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00017  * Boston, MA 02111-1307, USA.
00018  */
00019  
00020 #ifndef GUST_NEW_H
00021 #define GUST_NEW_H
00022 
00023 #if defined(_MSC_VER) || defined(__WXMSW__)
00024   #ifdef new
00025     #undef new
00026   #endif
00027   // #include <new.h>
00028 #else
00029   // #include <new.h>
00030 #endif
00031 
00032 #define reserve_stack(T,n) (T *)alloca((n)*sizeof(T))
00033 
00034 namespace gust {
00035 
00036 // using namespace gul;
00037 
00038 /* -------------------------------------------------------------------------
00039   Low level memory management
00040 -------------------------------------------------------------------------- */
00041 
00042 enum Storage
00043 {
00044   dumb,
00045   place,
00046   heap,
00047   pool
00048 };
00049 
00050 inline void release( void *buf, unsigned int t, unsigned int s )
00051 {
00052   if( (t <= place) || (buf == NULL) ) return;
00053   if( t == heap ) { free(buf); return; }
00054   PreferPoolFree( buf, s );
00055 }
00056 
00057 inline void *reserve_global( size_t s, size_t *ret_s )
00058 {
00059   void *p = malloc( s );
00060   if( p == NULL ) throw gul::AllocError();
00061   *ret_s = s;
00062   return(p);
00063 }
00064 
00065 inline void *reserve_pool( size_t s, size_t *ret_s )
00066 {
00067   void *p = PreferPoolAlloc( s, ret_s);
00068   if( p == NULL ) throw gul::AllocError();
00069   return(p);
00070 }
00071 
00072 
00073 
00074 
00075 
00076 }
00077 
00078 
00079 
00080 #endif
00081  

Generated on Mon Jan 21 04:17:42 2002 for GUL 0.6 - Geometry Utility Library by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001