Here is an example of a non-null terminated list:
#include <stdio.h>
#include <stddef.h>
typedef struct buffer (buffer);
struct buffer {
void *start_address;
void *end_address;
};
static inline void print(buffer *__buffer) {
// preprocessing automata -- Input Validation
if (NULL == __buffer) {
return ;
}
void *_address = __buffer->start_address;
for (int i = 0; NULL != _address; _address = (__buffer->start_address + i)) {
// processing
const char c = *((const char *)_address);
printf("%c\n", c);
// post-processing
if (__buffer->end_address == _address) {
return ;
}
i++;
}
}
int main() {
char test[] = {'H', 'e', 'l', 'l', 'o'};
buffer _buf = {
.start_address = &test[0],
.end_address = &test[4]
};
print(&_buf);
return 0;
}