mirror of
https://github.com/pnx/m16vm
synced 2026-06-16 03:44:55 +02:00
lib: adding vector module
This commit is contained in:
parent
adbe0006f5
commit
a305c34b39
2 changed files with 95 additions and 0 deletions
41
lib/include/vector.h
Normal file
41
lib/include/vector.h
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
/* vector.h
|
||||
*
|
||||
* Copyright (C) 2018 Henrik Hautakoski <henrik@fiktivkod.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This 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 program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
* MA 02110-1301, USA.
|
||||
*/
|
||||
#ifndef VECTOR_H
|
||||
#define VECTOR_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
struct vector {
|
||||
size_t blk_sz;
|
||||
size_t alloc;
|
||||
size_t size;
|
||||
void *base;
|
||||
};
|
||||
|
||||
#define VECTOR_INIT(block_size) { block_size, 0, 0, NULL }
|
||||
|
||||
void vector_init(struct vector* v, size_t block_size);
|
||||
|
||||
void vector_destory(struct vector* v);
|
||||
|
||||
void vector_append(struct vector* v, const void *ptr, size_t n);
|
||||
|
||||
#endif /* VECTOR_H */
|
||||
Loading…
Add table
Add a link
Reference in a new issue