Mercurial > hg > octave-nkf
annotate liboctave/util/oct-locbuf.cc @ 19183:a66548dc07b0 stable release-3-8-2
Version 3.8.2 released.
* configure.ac (OCTAVE_VERSION): Now 3.8.2.
(OCTAVE_MINOR_VERSION): Now 2.
(OCTAVE_RELEASE_DATE): Set to 2014-06-06.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 07 Aug 2014 11:41:28 -0400 |
parents | 49a5a4be04a1 |
children | 95c533ed464b |
rev | line source |
---|---|
8400
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
1 /* |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
2 |
17744
d63878346099
maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents:
15271
diff
changeset
|
3 Copyright (C) 2008-2013 Jaroslav Hajek |
8400
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
4 |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
5 This file is part of Octave. |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
6 |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
7 Octave is free software; you can redistribute it and/or modify it |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
8 under the terms of the GNU General Public License as published by the |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
9 Free Software Foundation; either version 3 of the License, or (at your |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
10 option) any later version. |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
11 |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
15 for more details. |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
16 |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
17 You should have received a copy of the GNU General Public License |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
18 along with Octave; see the file COPYING. If not, see |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
19 <http://www.gnu.org/licenses/>. |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
20 |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
21 */ |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
22 |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
23 #ifdef HAVE_CONFIG_H |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
24 #include <config.h> |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
25 #endif |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
26 |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
27 #include <iostream> |
13981
5f8bc2f145f5
clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
28 |
5f8bc2f145f5
clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
29 #include "lo-error.h" |
8400
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
30 #include "oct-locbuf.h" |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
31 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
32 // FIXME: Maybe we should querying for available physical memory? |
13981
5f8bc2f145f5
clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
33 |
8400
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
34 #ifndef OCTAVE_LOCBUF_CHUNKSIZE_MB |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
35 #define OCTAVE_LOCBUF_CHUNKSIZE_MB 32 |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
36 #endif |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
37 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
38 // Each chunk will be at least this big. |
13981
5f8bc2f145f5
clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
39 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
40 const size_t octave_chunk_buffer::chunk_size = |
8400
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
41 static_cast<size_t> (OCTAVE_LOCBUF_CHUNKSIZE_MB) << 20; |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
42 |
13981
5f8bc2f145f5
clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
43 char *octave_chunk_buffer::top = 0; |
5f8bc2f145f5
clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
44 char *octave_chunk_buffer::chunk = 0; |
8400
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
45 size_t octave_chunk_buffer::left = 0; |
13981
5f8bc2f145f5
clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
46 size_t octave_chunk_buffer::active = 0; |
8400
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
47 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
48 octave_chunk_buffer::octave_chunk_buffer (size_t size) : cnk (0), dat (0) |
8400
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
49 { |
13981
5f8bc2f145f5
clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
50 // Alignment mask. The size of double or long int, whichever is |
5f8bc2f145f5
clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
51 // greater. All data will be aligned to this size. If it's not |
5f8bc2f145f5
clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
52 // enough for a type, that type should not be declared as POD. |
5f8bc2f145f5
clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
53 |
8400
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
54 static const size_t align_mask = (sizeof (long) < sizeof (double) |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
55 ? sizeof (double) |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
56 : sizeof (long)) - 1; |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
57 |
13981
5f8bc2f145f5
clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
58 active++; |
5f8bc2f145f5
clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
59 |
5f8bc2f145f5
clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
60 if (! size) |
5f8bc2f145f5
clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
61 return; |
5f8bc2f145f5
clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
62 |
8400
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
63 // Align size. Note that size_t is unsigned, so size-1 must correctly |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
64 // wrap around. |
13981
5f8bc2f145f5
clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
65 |
8400
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
66 size = ((size - 1) | align_mask) + 1; |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
67 |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
68 if (size > left) |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
69 { |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
70 // Big buffers (> 1/8 chunk) will be allocated as stand-alone and |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
71 // won't disrupt the chain. |
13981
5f8bc2f145f5
clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
72 |
8400
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
73 if (size > chunk_size >> 3) |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
74 { |
13981
5f8bc2f145f5
clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
75 // Use new [] to get std::bad_alloc if out of memory. |
5f8bc2f145f5
clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
76 |
15020
560317fd5977
maint: Cuddle open bracket used for indexing C++ arrays in source code.
Rik <rik@octave.org>
parents:
15018
diff
changeset
|
77 dat = new char [size]; |
8400
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
78 return; |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
79 } |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
80 |
15020
560317fd5977
maint: Cuddle open bracket used for indexing C++ arrays in source code.
Rik <rik@octave.org>
parents:
15018
diff
changeset
|
81 dat = new char [chunk_size]; |
8400
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
82 chunk = top = dat; |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
83 left = chunk_size; |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
84 } |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
85 |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
86 // Now allocate memory from the chunk and update state. |
13981
5f8bc2f145f5
clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
87 |
8400
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
88 cnk = chunk; |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
89 dat = top; |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
90 left -= size; |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
91 top += size; |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
92 } |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
93 |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
94 octave_chunk_buffer::~octave_chunk_buffer (void) |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
95 { |
13981
5f8bc2f145f5
clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
96 active--; |
5f8bc2f145f5
clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
97 |
8400
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
98 if (cnk == chunk) |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
99 { |
13981
5f8bc2f145f5
clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
100 // Our chunk is still the active one. Just restore the state. |
5f8bc2f145f5
clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
101 |
8400
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
102 left += top - dat; |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
103 top = dat; |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
104 } |
13981
5f8bc2f145f5
clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
105 else |
8400
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
106 { |
13981
5f8bc2f145f5
clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
107 if (cnk) |
5f8bc2f145f5
clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
108 { |
5f8bc2f145f5
clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
109 // Responsible for deletion. |
5f8bc2f145f5
clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
110 |
5f8bc2f145f5
clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
111 delete [] chunk; |
5f8bc2f145f5
clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
112 chunk = cnk; |
5f8bc2f145f5
clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
113 top = dat; |
5f8bc2f145f5
clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
114 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
115 // FIXME: the following calcuation of remaining data will |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
116 // only work if each chunk has the same chunk_size. |
13981
5f8bc2f145f5
clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
117 |
5f8bc2f145f5
clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
118 left = chunk_size - (dat - cnk); |
5f8bc2f145f5
clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
119 } |
5f8bc2f145f5
clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
120 else |
5f8bc2f145f5
clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
121 { |
5f8bc2f145f5
clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
122 // We were a stand-alone buffer. |
5f8bc2f145f5
clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
123 |
5f8bc2f145f5
clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
124 delete [] dat; |
5f8bc2f145f5
clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
125 } |
5f8bc2f145f5
clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
126 } |
5f8bc2f145f5
clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
127 } |
5f8bc2f145f5
clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
128 |
5f8bc2f145f5
clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
129 // Clear the final chunk of allocated memory. |
5f8bc2f145f5
clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
130 |
5f8bc2f145f5
clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
131 void |
5f8bc2f145f5
clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
132 octave_chunk_buffer::clear (void) |
5f8bc2f145f5
clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
133 { |
5f8bc2f145f5
clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
134 if (active == 0) |
5f8bc2f145f5
clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
135 { |
5f8bc2f145f5
clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
136 delete [] chunk; |
5f8bc2f145f5
clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
137 chunk = 0; |
5f8bc2f145f5
clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
138 top = 0; |
5f8bc2f145f5
clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
139 left = 0; |
8400
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
140 } |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
141 else |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
142 { |
13981
5f8bc2f145f5
clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
143 (*current_liboctave_warning_handler) |
5f8bc2f145f5
clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
144 ("octave_chunk_buffer::clear: %d active allocations remain!", |
5f8bc2f145f5
clean up octave_chunk_buffer storage before exit
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
145 active); |
8400
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
146 } |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
147 } |