Removed some duplicate code and fixed appveyor issue.

This commit is contained in:
Linus Probert 2018-01-23 23:02:26 +01:00
parent 4088357584
commit 8d865e9d94
3 changed files with 12 additions and 30 deletions

View File

@ -6,18 +6,6 @@
#include "defines.h" #include "defines.h"
#include "util.h" #include "util.h"
static void*
ec_malloc(unsigned int size)
{
void *ptr = malloc(size);
if (ptr == NULL) {
fatal("Failed to allocate hashtable");
}
return ptr;
}
Hashtable* Hashtable*
ht_create(unsigned int size) ht_create(unsigned int size)
{ {

View File

@ -1,23 +1,12 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include "linkedlist.h" #include "linkedlist.h"
#include "util.h"
static
LinkedList *linkedlist_malloc(void)
{
LinkedList *ptr;
ptr = malloc(sizeof(LinkedList));
if (ptr == NULL) {
perror("[!!] Fatal error in linkedlist_malloc() on memory allocation");
exit(-1);
}
return ptr;
}
static static
LinkedList* linkedlist_node_create(void) LinkedList* linkedlist_node_create(void)
{ {
LinkedList *newList = linkedlist_malloc(); LinkedList *newList = ec_malloc(sizeof(LinkedList));
newList->next = NULL; newList->next = NULL;
newList->data = NULL; newList->data = NULL;
return newList; return newList;

View File

@ -52,7 +52,8 @@ m_sprintf(char * dest, size_t destsz, const char * format, ...)
va_end(args); va_end(args);
} }
void debug(const char *fmt, ...) void
debug(const char *fmt, ...)
{ {
va_list args; va_list args;
printf("[--] "); printf("[--] ");
@ -62,7 +63,8 @@ void debug(const char *fmt, ...)
printf("\n"); printf("\n");
} }
void info(const char * fmt, ...) void
info(const char * fmt, ...)
{ {
va_list args; va_list args;
printf("[**] "); printf("[**] ");
@ -72,7 +74,8 @@ void info(const char * fmt, ...)
printf("\n"); printf("\n");
} }
void error(const char *fmt, ...) void
error(const char *fmt, ...)
{ {
va_list args; va_list args;
fprintf(stderr, "[!*] Error "); fprintf(stderr, "[!*] Error ");
@ -82,7 +85,8 @@ void error(const char *fmt, ...)
fprintf(stderr, "\n"); fprintf(stderr, "\n");
} }
void fatal(const char *fmt, ...) void
fatal(const char *fmt, ...)
{ {
va_list args; va_list args;
fprintf(stderr, "[!!] Fatal Error "); fprintf(stderr, "[!!] Fatal Error ");
@ -93,7 +97,8 @@ void fatal(const char *fmt, ...)
exit(-1); exit(-1);
} }
void *ec_malloc(unsigned int size) void
*ec_malloc(unsigned int size)
{ {
void *ptr; void *ptr;
ptr = malloc(size); ptr = malloc(size);