// SPDX-License-Identifier: Apache-2.0
/*
 * Copyright 2001-2026 Richard Lesh
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

///////////////////////////////////////////////////////////////////////////////
// Vector
// Implements a growable list of integers.  Is thread safe.
// Vector Data is a heap allocated block with the following structure:
//-1:	int		total capacity + 1 + HEAP_BLOCK_HEADER_SIZE (number of elements allocated)
// 0:	int		current length (number of elements used)
// 1..n:	int		elements
///////////////////////////////////////////////////////////////////////////////

#define	_VECTOR_DATA	0				// Heap allocated block for the vector data
#define	_VECTOR_MUTEX	1				// Mutex used for concurrent access
#define	_VECTOR_END		2

#def_macro ZERO_VECTOR()
	#macro	ALLOC(_VECTOR_END)
	move	r1, r0
	store	0, r1[_VECTOR_MUTEX]		// To do: Initialize mutex
	#macro	ALLOC(1)
	store	r0, r1[_VECTOR_DATA]		// Create storage array
	store	0, r0						// Leading count to 0
	move	r0, r1
#end_macro
