Files
compiler-the-translators/library/boundscheck.c
Scarlett 44f0e0f5af 🪃🪃
2025-05-06 18:24:43 -04:00

23 lines
486 B
C

#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
int BoundsError(int d){
printf("You are trying to access memory that isn't yours.\n");
exit(1);
}
void BoundsCheck(int argc, void * start, ...){
va_list argptr;
va_start(argptr, start);
int index = 0;
while (argc){
argc--;
index = va_arg(argptr, int);
if(index > *(int*)start){
BoundsError(index);
}
start += sizeof(int);
}
va_end(argptr);
}