Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "headers.h"
- /*********/
- void _log(char *func, char *fmt, ...)
- {
- if (func != NULL) { fprintf(stdout, "[%s]", func); };
- if (func != NULL && fmt != NULL) { fprintf(stdout, " "); };
- if (fmt != NULL)
- {
- va_list argp;
- va_start(argp, fmt);
- vfprintf(stdout, fmt, argp);
- va_end(argp);
- };
- fprintf(stdout, "\n");
- }
- /*********/
- void _error(char* func, char* fmt, ...)
- {
- fprintf(stdout, "[ERROR]\n");
- _log(func, fmt);
- exit(0);
- }
- /**********/
- void *_calloc(size_t count, size_t size)
- {
- void *p = NULL;
- p = calloc(count, size);
- if (p == NULL) { _error(__func__, "Allocation failed"); };
- return p;
- }
- /**********/
- void *_malloc(size_t size)
- {
- void *p = NULL;
- p = malloc(size);
- if (p == NULL) { _error(__func__, "Allocation failed"); };
- return p;
- }
- /**********/
- void *_realloc(void* ptr, size_t size)
- {
- void* p = NULL;
- p = realloc(ptr, size);
- if (p == NULL) { _error(__func__, "Allocation failed"); };
- return p;
- }
- /**********/
- void _free(void *p)
- {
- if (p != NULL) { free(p); };
- }
- /**********/
- int _compare_int(const void* elem1, const void* elem2)
- {
- int f = *((int*)elem1);
- int s = *((int*)elem2);
- if (f > s) return 1;
- if (f < s) return -1;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement