// Written by retoor@molodetz.nl

// This source code demonstrates memory allocation, deallocation, and formatted output using custom functions.

// Custom functions/modules from external sources are not used in this example.

// MIT License

#include <stdlib.h>
#include <string.h>
#include <stdio.h>

void *rmalloc(size_t);
void *rfree(void *);
int rtest_end(char *);
void rprintgf(FILE *f, char *format, ...);

int main() {
    for (int i = 0; i < 100; ++i) {
        void *data = rmalloc(5000);
        if (data == NULL) {
            fprintf(stderr, "Memory allocation failed\n");
            return 1;
        }
        memset(data, 0, 5000);
        rfree(data);
    }
    rprintgf(stdout, "Hello from .so library!\n");
    return rtest_end("");
}