* ========== Copyright Header Begin ==========================================
* OpenSPARC T2 Processor File: rz3_rst_array.h
* Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
* The above named program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License version 2 as published by the Free Software Foundation.
* The above named program is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
* You should have received a copy of the GNU General Public
* License along with this work; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
* ========== Copyright Header End ============================================
* incrementally-growing array of rst records
nlines
= (maxcount
+ linesize
- 1)/linesize
;
lines
= new rstf_unionT
* [nlines
];
for (i
=0; i
<nlines
; i
++) {
bool Push(const rstf_unionT
* rec
) {
if (count
>= maxcount
) return false;
int lidx
= (count
/ linesize
);
int offs
= count
% linesize
;
if (lines
[lidx
] == NULL
) {
lines
[lidx
] = new rstf_unionT
[linesize
];
memcpy(&(lines
[lidx
][offs
]), rec
, sizeof(rstf_unionT
));
bool Get(int idx
, rstf_unionT
* where
) {
int lidx
= idx
/ linesize
;
int offs
= idx
% linesize
;
memcpy(where
, &(lines
[lidx
][offs
]), sizeof(rstf_unionT
));
const rstf_unionT
* GetPtr(int idx
) {
int offs
= idx
% linesize
;
return &(lines
[lidx
][offs
]);
bool CopyFrom(rstf_unionT
* membuf
, int howmany
) {
if (howmany
> maxcount
) return false;
int full_line_count
= (count
/ linesize
);
int partial_line_size
= (count
% linesize
);
for (i
=0; i
<full_line_count
; i
++) {
lines
[i
] = new rstf_unionT
[linesize
];
memcpy(lines
[i
], membuf
+recs_copied
, linesize
*sizeof(rstf_unionT
));
lines
[i
] = new rstf_unionT
[linesize
];
memcpy(lines
[i
], membuf
+recs_copied
, partial_line_size
*sizeof(rstf_unionT
));
// membuf must accomodate <count> records. count is returned by the Count() function
bool CopyTo(rstf_unionT
* membuf
) {
int full_line_count
= (count
/linesize
);
int partial_line_size
= (count
% linesize
);
for (i
=0; i
<full_line_count
; i
++) {
memcpy(membuf
+recs_copied
, lines
[i
], linesize
*sizeof(rstf_unionT
));
memcpy(membuf
+recs_copied
, lines
[i
], partial_line_size
* sizeof(rstf_unionT
));
for (i
=0; i
<nlines
; i
++) {
enum consts_e
{ linesize
= 512 };