2024-03-09 18:37:04 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2024-04-01 23:23:10 +02:00
|
|
|
#include <string.h>
|
2024-03-09 18:37:04 +01:00
|
|
|
|
|
|
|
void die(char *reason)
|
|
|
|
{
|
2024-03-10 11:54:08 +01:00
|
|
|
fprintf(stderr, "%s\n", reason);
|
2024-03-09 18:37:04 +01:00
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
void *memalloc(size_t size)
|
|
|
|
{
|
|
|
|
void *ptr = malloc(size);
|
|
|
|
if (!ptr) {
|
2024-04-01 23:23:10 +02:00
|
|
|
perror("ccc");
|
2024-03-09 18:37:04 +01:00
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
|
2024-04-01 23:23:10 +02:00
|
|
|
void *estrdup(void *ptr)
|
|
|
|
{
|
2024-11-01 00:19:58 +01:00
|
|
|
void *dup = strdup(ptr);
|
|
|
|
if (!dup) {
|
2024-04-01 23:23:10 +02:00
|
|
|
perror("ccc");
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
2024-11-01 00:19:58 +01:00
|
|
|
return dup;
|
2024-04-01 23:23:10 +02:00
|
|
|
}
|
|
|
|
|
2024-03-09 18:37:04 +01:00
|
|
|
void *rememalloc(void *ptr, size_t size)
|
|
|
|
{
|
|
|
|
ptr = realloc(ptr, size);
|
|
|
|
if (!ptr) {
|
|
|
|
perror("ccc");
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
return ptr;
|
|
|
|
}
|