ADMB Documentation  -a65f1c97
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
dfpool.h
Go to the documentation of this file.
1 /*
2  * $Id$
3  *
4  * Author: David Fournier
5  * Copyright (c) 2008-2012 Regents of the University of California
6  *
7  * ADModelbuilder and associated libraries and documentations are
8  * provided under the general terms of the "BSD" license.
9  *
10  * License:
11  *
12  * Redistribution and use in source and binary forms, with or without
13  * modification, are permitted provided that the following conditions are
14  * met:
15  *
16  * 1. Redistributions of source code must retain the above copyright
17  * notice, this list of conditions and the following disclaimer.
18  *
19  * 2. Redistributions in binary form must reproduce the above copyright
20  * notice, this list of conditions and the following disclaimer in the
21  * documentation and/or other materials provided with the distribution.
22  *
23  * 3. Neither the name of the University of California, Otter Research,
24  * nor the ADMB Foundation nor the names of its contributors may be used
25  * to endorse or promote products derived from this software without
26  * specific prior written permission.
27  *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39  *
40  */
45 #if !defined(__DF_POOL__)
46 #define __DF_POOL__
47 #include <fvar.hpp>
48 extern void * pchecker;
49 //#define __CHECK_MEMORY__
50 class link;
51 
56 class dfpool
57 {
59 public:
60  int nvar;
61  int& on_dfpool_vector(void) {return dfpool_vector_flag;}
62  char * last_chunk;
63  struct link { link * next; };
66  size_t nelem;
67  size_t size;
69  double * first;
70  void grow(void);
71 #if defined(__CHECK_MEMORY__)
72  int maxchunks;
73  char * minaddress[100];
74  char * maxaddress[100];
75  int * pvalues;
76  int nalloc;
77 #endif
78 
79 public:
80  dfpool();
81  dfpool(const dfpool&) = delete;
82  dfpool(const size_t);
83  virtual ~dfpool();
84 
85  dfpool& operator=(const dfpool&) = delete;
86 
87  void clean(void);
88  void set_size(const size_t);
89  void * alloc(void);
90  void free(void * b);
91  void deallocate(void);
92 #if defined(__CHECK_MEMORY__)
93  int bad(link * p);
94  int badaddress(link * p);
95  void sanity_check(void);
96  void sanity_check(void *);
97  void sanity_check2(void);
98  void write_pointers(int m,int max);
99 #endif
100 };
101 
106 class tsdfpool : public dfpool
107 {
108 public:
109  tsdfpool(int n);
110  void * alloc(void);
111  void free(void * b);
112 };
113 
114 #endif //defined(__DF_POOL__)
int nvar
Definition: dfpool.h:60
void free(void *b)
void grow(void)
Description not yet available.
Definition: dfpool.cpp:536
void free(void *b)
Description not yet available.
Definition: dfpool.cpp:373
size_t size
Definition: dfpool.h:67
dfpool & operator=(const dfpool &)=delete
void set_size(const size_t)
Description not yet available.
Definition: dfpool.cpp:479
int num_chunks
Definition: dfpool.h:65
tsdfpool(int n)
void deallocate(void)
Description not yet available.
Definition: dfpool.cpp:491
int & on_dfpool_vector(void)
Definition: dfpool.h:61
virtual ~dfpool()
Destructor.
Definition: dfpool.cpp:471
Author: David Fournier Copyright (c) 2008-2012 Regents of the University of California.
void * alloc(void)
Description not yet available.
Definition: dfpool.cpp:235
void * pchecker
double * first
Definition: dfpool.h:69
Description not yet available.
Definition: dfpool.h:106
link * head
Definition: dfpool.h:68
Description not yet available.
Definition: dfpool.h:56
int num_allocated
Definition: dfpool.h:64
int dfpool_vector_flag
Definition: dfpool.h:58
#define max(a, b)
Definition: cbivnorm.cpp:189
size_t nelem
Definition: dfpool.h:66
dfpool()
Default constructor.
Definition: dfpool.cpp:430
void clean(void)
Description not yet available.
Definition: dfpool.cpp:608
char * last_chunk
Definition: dfpool.h:62
void * alloc(void)