~kdsch/c-modules

05c44941484c912722d896f4e744f209ff440f53 — Karl Schultheisz 5 months ago 11e8e7c
dynamic-array: add header file for dynamic array
2 files changed, 21 insertions(+), 13 deletions(-)

M dynamic-array.c
A dynamic-array.h
M dynamic-array.c => dynamic-array.c +1 -13
@@ 1,21 1,9 @@
#include <assert.h>
#include "dynamic-array.h"
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>

enum status {
	STATUS_OK,
	STATUS_ERROR_OOM,
};

struct array {
	size_t capacity;
	size_t length;
	uint32_t *members;
};

void
array_init(struct array *const a)
{

A dynamic-array.h => dynamic-array.h +20 -0
@@ 0,0 1,20 @@
#ifndef DYNAMIC_ARRAY_H
#define DYNAMIC_ARRAY_H
#include <stddef.h>
#include <stdint.h>

enum status {
	STATUS_OK,
	STATUS_ERROR_OOM,
};

struct array {
	size_t capacity;
	size_t length;
	uint32_t *members;
};

void array_init(struct array *const a);
enum status array_append(struct array *const a, const uint32_t x);
void array_free(struct array *const a);
#endif