Mercurial > hg > octave-nkf
annotate liboctave/oct-locbuf.h @ 11586:12df7854fa7c
strip trailing whitespace from source files
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 20 Jan 2011 17:24:59 -0500 |
parents | fd0a3ac60b0e |
children | 5f8bc2f145f5 |
rev | line source |
---|---|
8377 | 1 /* |
2 | |
11523 | 3 Copyright (C) 2008-2011 Jaroslav Hajek |
8377 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
9 Free Software Foundation; either version 3 of the License, or (at your | |
10 option) any later version. | |
11 | |
12 Octave is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
18 along with Octave; see the file COPYING. If not, see | |
19 <http://www.gnu.org/licenses/>. | |
20 | |
21 */ | |
22 | |
23 #if !defined (octave_local_buffer_h) | |
24 #define octave_local_buffer_h 1 | |
25 | |
26 #include <cstddef> | |
8400
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
8379
diff
changeset
|
27 #include "oct-cmplx.h" |
8377 | 28 |
29 // The default local buffer simply encapsulates an *array* pointer that gets | |
30 // delete[]d automatically. For common POD types, we provide specializations. | |
31 | |
32 template <class T> | |
33 class octave_local_buffer | |
34 { | |
35 public: | |
36 octave_local_buffer (size_t size) | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
37 : data (0) |
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
38 { |
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
39 if (size) |
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
40 data = new T[size]; |
8377 | 41 } |
42 ~octave_local_buffer (void) { delete [] data; } | |
43 operator T *() const { return data; } | |
11506
964b7fd379f1
more constructor/destructor fixes
John W. Eaton <jwe@octave.org>
parents:
9237
diff
changeset
|
44 |
8377 | 45 private: |
46 T *data; | |
11506
964b7fd379f1
more constructor/destructor fixes
John W. Eaton <jwe@octave.org>
parents:
9237
diff
changeset
|
47 |
964b7fd379f1
more constructor/destructor fixes
John W. Eaton <jwe@octave.org>
parents:
9237
diff
changeset
|
48 // No copying! |
964b7fd379f1
more constructor/destructor fixes
John W. Eaton <jwe@octave.org>
parents:
9237
diff
changeset
|
49 octave_local_buffer (const octave_local_buffer&); |
964b7fd379f1
more constructor/destructor fixes
John W. Eaton <jwe@octave.org>
parents:
9237
diff
changeset
|
50 octave_local_buffer& operator = (const octave_local_buffer&); |
8377 | 51 }; |
52 | |
8400
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
8379
diff
changeset
|
53 // For buffers of POD types, we'll be more smart. There is one thing that |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
8379
diff
changeset
|
54 // differentiates a local buffer from a dynamic array - the local buffers, if |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
8379
diff
changeset
|
55 // not manipulated improperly, have a FIFO semantics, meaning that if buffer B |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
8379
diff
changeset
|
56 // is allocated after buffer A, B *must* be deallocated before A. This is |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
8379
diff
changeset
|
57 // *guaranteed* if you use local buffer exclusively through the |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
8379
diff
changeset
|
58 // OCTAVE_LOCAL_BUFFER macro, because the C++ standard *mandates* explicit |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
8379
diff
changeset
|
59 // local objects be destroyed in reverse order of declaration. |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
8379
diff
changeset
|
60 // Therefore, we can avoid memory fragmentation by allocating fairly large |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
8379
diff
changeset
|
61 // chunks of memory and serving local buffers from them in a stack-like manner. |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
8379
diff
changeset
|
62 // The first returning buffer in previous chunk will be responsible for |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
8379
diff
changeset
|
63 // deallocating the chunk. |
8377 | 64 |
8400
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
8379
diff
changeset
|
65 class octave_chunk_buffer |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
8379
diff
changeset
|
66 { |
11506
964b7fd379f1
more constructor/destructor fixes
John W. Eaton <jwe@octave.org>
parents:
9237
diff
changeset
|
67 public: |
964b7fd379f1
more constructor/destructor fixes
John W. Eaton <jwe@octave.org>
parents:
9237
diff
changeset
|
68 |
964b7fd379f1
more constructor/destructor fixes
John W. Eaton <jwe@octave.org>
parents:
9237
diff
changeset
|
69 OCTAVE_API octave_chunk_buffer (size_t size); |
964b7fd379f1
more constructor/destructor fixes
John W. Eaton <jwe@octave.org>
parents:
9237
diff
changeset
|
70 |
964b7fd379f1
more constructor/destructor fixes
John W. Eaton <jwe@octave.org>
parents:
9237
diff
changeset
|
71 OCTAVE_API virtual ~octave_chunk_buffer (void); |
964b7fd379f1
more constructor/destructor fixes
John W. Eaton <jwe@octave.org>
parents:
9237
diff
changeset
|
72 |
964b7fd379f1
more constructor/destructor fixes
John W. Eaton <jwe@octave.org>
parents:
9237
diff
changeset
|
73 char *data (void) const { return dat; } |
964b7fd379f1
more constructor/destructor fixes
John W. Eaton <jwe@octave.org>
parents:
9237
diff
changeset
|
74 |
964b7fd379f1
more constructor/destructor fixes
John W. Eaton <jwe@octave.org>
parents:
9237
diff
changeset
|
75 private: |
8400
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
8379
diff
changeset
|
76 static const size_t chunk_size; |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
8379
diff
changeset
|
77 |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
8379
diff
changeset
|
78 static char *top, *chunk; |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
8379
diff
changeset
|
79 static size_t left; |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
8379
diff
changeset
|
80 |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
8379
diff
changeset
|
81 char *cnk; |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
8379
diff
changeset
|
82 char *dat; |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
8379
diff
changeset
|
83 |
11506
964b7fd379f1
more constructor/destructor fixes
John W. Eaton <jwe@octave.org>
parents:
9237
diff
changeset
|
84 // No copying! |
964b7fd379f1
more constructor/destructor fixes
John W. Eaton <jwe@octave.org>
parents:
9237
diff
changeset
|
85 octave_chunk_buffer (const octave_chunk_buffer&); |
964b7fd379f1
more constructor/destructor fixes
John W. Eaton <jwe@octave.org>
parents:
9237
diff
changeset
|
86 octave_chunk_buffer& operator = (const octave_chunk_buffer&); |
8400
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
8379
diff
changeset
|
87 }; |
8377 | 88 |
8400
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
8379
diff
changeset
|
89 // This specializes octave_local_buffer to use the chunked buffer mechanism |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
8379
diff
changeset
|
90 // for POD types. |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
8379
diff
changeset
|
91 #define SPECIALIZE_POD_BUFFER(TYPE) \ |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
8379
diff
changeset
|
92 template <> \ |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
8379
diff
changeset
|
93 class octave_local_buffer<TYPE> : private octave_chunk_buffer \ |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
8379
diff
changeset
|
94 { \ |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
8379
diff
changeset
|
95 public: \ |
11506
964b7fd379f1
more constructor/destructor fixes
John W. Eaton <jwe@octave.org>
parents:
9237
diff
changeset
|
96 octave_local_buffer (size_t size) \ |
964b7fd379f1
more constructor/destructor fixes
John W. Eaton <jwe@octave.org>
parents:
9237
diff
changeset
|
97 : octave_chunk_buffer (size * sizeof (TYPE)) { } \ |
964b7fd379f1
more constructor/destructor fixes
John W. Eaton <jwe@octave.org>
parents:
9237
diff
changeset
|
98 \ |
964b7fd379f1
more constructor/destructor fixes
John W. Eaton <jwe@octave.org>
parents:
9237
diff
changeset
|
99 operator TYPE *() const \ |
964b7fd379f1
more constructor/destructor fixes
John W. Eaton <jwe@octave.org>
parents:
9237
diff
changeset
|
100 { \ |
964b7fd379f1
more constructor/destructor fixes
John W. Eaton <jwe@octave.org>
parents:
9237
diff
changeset
|
101 return reinterpret_cast<TYPE *> (this->data ()); \ |
964b7fd379f1
more constructor/destructor fixes
John W. Eaton <jwe@octave.org>
parents:
9237
diff
changeset
|
102 } \ |
8400
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
8379
diff
changeset
|
103 } |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
8379
diff
changeset
|
104 |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
8379
diff
changeset
|
105 SPECIALIZE_POD_BUFFER (bool); |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
8379
diff
changeset
|
106 SPECIALIZE_POD_BUFFER (char); |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
8379
diff
changeset
|
107 SPECIALIZE_POD_BUFFER (unsigned short); |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
8379
diff
changeset
|
108 SPECIALIZE_POD_BUFFER (short); |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
8379
diff
changeset
|
109 SPECIALIZE_POD_BUFFER (int); |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
8379
diff
changeset
|
110 SPECIALIZE_POD_BUFFER (unsigned int); |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
8379
diff
changeset
|
111 SPECIALIZE_POD_BUFFER (long); |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
8379
diff
changeset
|
112 SPECIALIZE_POD_BUFFER (unsigned long); |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
8379
diff
changeset
|
113 SPECIALIZE_POD_BUFFER (float); |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
8379
diff
changeset
|
114 SPECIALIZE_POD_BUFFER (double); |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
8379
diff
changeset
|
115 // FIXME: Are these guaranteed to be POD and satisfy alignment? |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
8379
diff
changeset
|
116 SPECIALIZE_POD_BUFFER (Complex); |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
8379
diff
changeset
|
117 SPECIALIZE_POD_BUFFER (FloatComplex); |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
8379
diff
changeset
|
118 // MORE ? |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
8379
diff
changeset
|
119 |
8660
f274fbc29747
chunked buffer allocation for pointers
Jaroslav Hajek <highegg@gmail.com>
parents:
8400
diff
changeset
|
120 // All pointers and const pointers are also POD types. |
f274fbc29747
chunked buffer allocation for pointers
Jaroslav Hajek <highegg@gmail.com>
parents:
8400
diff
changeset
|
121 template <class T> |
f274fbc29747
chunked buffer allocation for pointers
Jaroslav Hajek <highegg@gmail.com>
parents:
8400
diff
changeset
|
122 class octave_local_buffer<T *> : private octave_chunk_buffer |
f274fbc29747
chunked buffer allocation for pointers
Jaroslav Hajek <highegg@gmail.com>
parents:
8400
diff
changeset
|
123 { |
f274fbc29747
chunked buffer allocation for pointers
Jaroslav Hajek <highegg@gmail.com>
parents:
8400
diff
changeset
|
124 public: |
11506
964b7fd379f1
more constructor/destructor fixes
John W. Eaton <jwe@octave.org>
parents:
9237
diff
changeset
|
125 octave_local_buffer (size_t size) |
964b7fd379f1
more constructor/destructor fixes
John W. Eaton <jwe@octave.org>
parents:
9237
diff
changeset
|
126 : octave_chunk_buffer (size * sizeof (T *)) |
964b7fd379f1
more constructor/destructor fixes
John W. Eaton <jwe@octave.org>
parents:
9237
diff
changeset
|
127 { } |
964b7fd379f1
more constructor/destructor fixes
John W. Eaton <jwe@octave.org>
parents:
9237
diff
changeset
|
128 |
8660
f274fbc29747
chunked buffer allocation for pointers
Jaroslav Hajek <highegg@gmail.com>
parents:
8400
diff
changeset
|
129 operator T **() const { return reinterpret_cast<T **> (this->data ()); } |
f274fbc29747
chunked buffer allocation for pointers
Jaroslav Hajek <highegg@gmail.com>
parents:
8400
diff
changeset
|
130 }; |
f274fbc29747
chunked buffer allocation for pointers
Jaroslav Hajek <highegg@gmail.com>
parents:
8400
diff
changeset
|
131 |
f274fbc29747
chunked buffer allocation for pointers
Jaroslav Hajek <highegg@gmail.com>
parents:
8400
diff
changeset
|
132 template <class T> |
f274fbc29747
chunked buffer allocation for pointers
Jaroslav Hajek <highegg@gmail.com>
parents:
8400
diff
changeset
|
133 class octave_local_buffer<const T *> : private octave_chunk_buffer |
f274fbc29747
chunked buffer allocation for pointers
Jaroslav Hajek <highegg@gmail.com>
parents:
8400
diff
changeset
|
134 { |
f274fbc29747
chunked buffer allocation for pointers
Jaroslav Hajek <highegg@gmail.com>
parents:
8400
diff
changeset
|
135 public: |
11506
964b7fd379f1
more constructor/destructor fixes
John W. Eaton <jwe@octave.org>
parents:
9237
diff
changeset
|
136 octave_local_buffer (size_t size) |
964b7fd379f1
more constructor/destructor fixes
John W. Eaton <jwe@octave.org>
parents:
9237
diff
changeset
|
137 : octave_chunk_buffer (size * sizeof (const T *)) |
964b7fd379f1
more constructor/destructor fixes
John W. Eaton <jwe@octave.org>
parents:
9237
diff
changeset
|
138 { } |
964b7fd379f1
more constructor/destructor fixes
John W. Eaton <jwe@octave.org>
parents:
9237
diff
changeset
|
139 |
964b7fd379f1
more constructor/destructor fixes
John W. Eaton <jwe@octave.org>
parents:
9237
diff
changeset
|
140 operator const T **() const |
964b7fd379f1
more constructor/destructor fixes
John W. Eaton <jwe@octave.org>
parents:
9237
diff
changeset
|
141 { |
964b7fd379f1
more constructor/destructor fixes
John W. Eaton <jwe@octave.org>
parents:
9237
diff
changeset
|
142 return reinterpret_cast<const T **> (this->data ()); |
964b7fd379f1
more constructor/destructor fixes
John W. Eaton <jwe@octave.org>
parents:
9237
diff
changeset
|
143 } |
8660
f274fbc29747
chunked buffer allocation for pointers
Jaroslav Hajek <highegg@gmail.com>
parents:
8400
diff
changeset
|
144 }; |
f274fbc29747
chunked buffer allocation for pointers
Jaroslav Hajek <highegg@gmail.com>
parents:
8400
diff
changeset
|
145 |
8400
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
8379
diff
changeset
|
146 // If the compiler supports dynamic stack arrays, we can use the attached hack |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
8379
diff
changeset
|
147 // to place small buffer arrays on the stack. It may be even faster than our |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
8379
diff
changeset
|
148 // obstack-like optimization, but is dangerous because stack is a very limited |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
8379
diff
changeset
|
149 // resource, so we disable it. |
7b6e1fc1cb90
implement obstack-like optimization of local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
8379
diff
changeset
|
150 #if 0 //defined (HAVE_DYNAMIC_AUTO_ARRAYS) |
8377 | 151 |
152 // Maximum buffer size (in bytes) to be placed on the stack. | |
153 | |
154 #define OCTAVE_LOCAL_BUFFER_MAX_STACK_SIZE 8192 | |
155 | |
156 // If we have automatic arrays, we use an automatic array if the size is small | |
157 // enough. To avoid possibly evaluating `size' multiple times, we first cache | |
158 // it. Note that we always construct both the stack array and the | |
159 // octave_local_buffer object, but only one of them will be nonempty. | |
160 | |
161 #define OCTAVE_LOCAL_BUFFER(T, buf, size) \ | |
162 const size_t _bufsize_ ## buf = size; \ | |
163 const bool _lbufaut_ ## buf = _bufsize_ ## buf * sizeof (T) \ | |
164 <= OCTAVE_LOCAL_BUFFER_MAX_STACK_SIZE; \ | |
165 T _bufaut_ ## buf [_lbufaut_ ## buf ? _bufsize_ ## buf : 0]; \ | |
166 octave_local_buffer<T> _bufheap_ ## buf (!_lbufaut_ ## buf ? _bufsize_ ## buf : 0); \ | |
8379
ad8ed668e0a4
allow initialized local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
8377
diff
changeset
|
167 T *buf = _lbufaut_ ## buf ? _bufaut_ ## buf : static_cast<T *> (_bufheap_ ## buf) |
8377 | 168 |
169 #else | |
170 | |
171 // If we don't have automatic arrays, we simply always use octave_local_buffer. | |
172 | |
173 #define OCTAVE_LOCAL_BUFFER(T, buf, size) \ | |
174 octave_local_buffer<T> _buffer_ ## buf (size); \ | |
8379
ad8ed668e0a4
allow initialized local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
8377
diff
changeset
|
175 T *buf = _buffer_ ## buf |
8377 | 176 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
177 #endif |
8377 | 178 |
8379
ad8ed668e0a4
allow initialized local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
8377
diff
changeset
|
179 // Yeah overloading macros would be nice. |
ad8ed668e0a4
allow initialized local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
8377
diff
changeset
|
180 // Note: we use weird variables in the for loop to avoid warnings about |
ad8ed668e0a4
allow initialized local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
8377
diff
changeset
|
181 // shadowed parameters. |
ad8ed668e0a4
allow initialized local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
8377
diff
changeset
|
182 #define OCTAVE_LOCAL_BUFFER_INIT(T, buf, size, value) \ |
ad8ed668e0a4
allow initialized local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
8377
diff
changeset
|
183 OCTAVE_LOCAL_BUFFER(T, buf, size); \ |
ad8ed668e0a4
allow initialized local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
8377
diff
changeset
|
184 for (size_t _buf_iter = 0, _buf_size = size; \ |
ad8ed668e0a4
allow initialized local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
8377
diff
changeset
|
185 _buf_iter < _buf_size; _buf_iter++) buf[_buf_iter] = value |
ad8ed668e0a4
allow initialized local buffers
Jaroslav Hajek <highegg@gmail.com>
parents:
8377
diff
changeset
|
186 |
8377 | 187 #endif |
188 |