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>
|
|
|
|
#include <wchar.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)
|
|
|
|
{
|
|
|
|
void *duped = strdup(ptr);
|
|
|
|
if (!duped) {
|
|
|
|
perror("ccc");
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
return duped;
|
|
|
|
}
|
|
|
|
|
|
|
|
void *ewcsdup(void *ptr)
|
|
|
|
{
|
|
|
|
void *duped = wcsdup(ptr);
|
|
|
|
if (!duped) {
|
|
|
|
perror("ccc");
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
return duped;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|