00001 #ifndef _FIX_ALLOC_HH_
00002 #define _FIX_ALLOC_HH_
00003
00004 #include <semLib.h>
00005
00006 #define FIX_ALLOC_TMOUT 1000 // 10 seconds...
00007
00008 class fixAlloc
00009 {
00010 public:
00011 fixAlloc(char *wh, int bnum, int bytes) ;
00012 ~fixAlloc() ;
00013
00014 void resize(char *wh, int bnum, int bytes) ;
00015
00016 char *alloc(int bytes, int block=1) ;
00017 int free(void *wh) ;
00018 void clear(void) ;
00019 void shrink(void *wh, int real) ;
00020 int check(void *wh) ;
00021 int getblk(void *wh) ;
00022
00023 int take_mutex(void) { return semTake(semutex,FIX_ALLOC_TMOUT) ; } ;
00024 int take_semfree(void) { return semTake(semfree,FIX_ALLOC_TMOUT) ; } ;
00025 int give_mutex(void) { return semGive(semutex) ; } ;
00026 int give_semfree(void) { return semGive(semfree) ; } ;
00027 int alloced ;
00028
00029 int blbytes ;
00030 int blnum ;
00031 private:
00032 char *where ;
00033 int myalloc ;
00034 int cleared ;
00035 int *desc ;
00036
00037 int last_free ;
00038 int last_free_blks ;
00039
00040 SEM_ID semutex ;
00041 SEM_ID semfree ;
00042
00043 } ;
00044
00045
00046 #endif