const-alize
This commit is contained in:
parent
08b65951e6
commit
a220f87278
@ -1,3 +1,6 @@
|
||||
#ifndef VECTOR_H
|
||||
#define VECTOR_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.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_get(vector_t * vector,
|
||||
size_t element);
|
||||
extern void * vector_get(const vector_t * const vector,
|
||||
const size_t element);
|
||||
|
||||
extern void vector_set(vector_t * vector,
|
||||
void * data,
|
||||
@ -29,8 +32,6 @@ extern void vector_set(vector_t * vector,
|
||||
|
||||
extern void vector_free(vector_t * vector);
|
||||
|
||||
extern void example_print(example_t * example);
|
||||
|
||||
void vector_init(vector_t * vector,
|
||||
size_t element_size,
|
||||
size_t element_count) {
|
||||
@ -71,8 +72,8 @@ void vector_pop(vector_t * vector) {
|
||||
(void) vector;
|
||||
}
|
||||
|
||||
void * vector_get(vector_t * vector,
|
||||
size_t element) {
|
||||
void * vector_get(const vector_t * const vector,
|
||||
const size_t element) {
|
||||
if (element >= vector->element_count) {
|
||||
puts("vector_get");
|
||||
exit(EXIT_FAILURE);
|
||||
@ -97,3 +98,5 @@ void vector_set(vector_t * vector,
|
||||
void vector_free(vector_t * vector) {
|
||||
free(vector->data);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user