const-alize

This commit is contained in:
anon 2023-08-24 03:14:12 +02:00
parent 08b65951e6
commit a220f87278

View File

@ -1,3 +1,6 @@
#ifndef VECTOR_H
#define VECTOR_H
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -20,8 +23,8 @@ extern void vector_push(vector_t * vector,
extern void vector_pop(vector_t * vector); extern void vector_pop(vector_t * vector);
extern void * vector_get(vector_t * vector, extern void * vector_get(const vector_t * const vector,
size_t element); const size_t element);
extern void vector_set(vector_t * vector, extern void vector_set(vector_t * vector,
void * data, void * data,
@ -29,8 +32,6 @@ extern void vector_set(vector_t * vector,
extern void vector_free(vector_t * vector); extern void vector_free(vector_t * vector);
extern void example_print(example_t * example);
void vector_init(vector_t * vector, void vector_init(vector_t * vector,
size_t element_size, size_t element_size,
size_t element_count) { size_t element_count) {
@ -71,8 +72,8 @@ void vector_pop(vector_t * vector) {
(void) vector; (void) vector;
} }
void * vector_get(vector_t * vector, void * vector_get(const vector_t * const vector,
size_t element) { const size_t element) {
if (element >= vector->element_count) { if (element >= vector->element_count) {
puts("vector_get"); puts("vector_get");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
@ -97,3 +98,5 @@ void vector_set(vector_t * vector,
void vector_free(vector_t * vector) { void vector_free(vector_t * vector) {
free(vector->data); free(vector->data);
} }
#endif