ft_nm/rsa/lib.c

24 lines
417 B
C

#include "rsa.h"
void *protected_malloc(size_t size, char *str) {
void *ptr = malloc(size);
if (!ptr) {
ft_log(ERROR, ft_strjoin(ft_strjoin("allocation of ", str), " failed"));
exit(1);
}
}
void ft_log(int level, char *s) {
switch (level) {
case ERROR:
printf("error: %s\n", s);
break;
case WARNING:
printf("warning: %s\n", s);
break;
case INFO:
printf("info: %s\n", s);
break;
}
}