jack-compiler/util.h

27 lines
572 B
C
Raw Normal View History

2020-12-20 13:58:10 -05:00
#ifndef UTIL_H
#define UTIL_H
#include <stdio.h>
2020-12-21 13:05:49 -05:00
/* util
* Random utilities. */
2020-12-20 13:58:10 -05:00
2020-12-21 16:11:23 -05:00
// Macros
#define eprintf(...) fprintf (stderr, __VA_ARGS__)
#define count(array, type) ((sizeof(array)) / (sizeof(type)))
#define strcount(array) count(array, char*)
2020-12-21 13:05:49 -05:00
typedef struct stringlist {
2020-12-20 13:58:10 -05:00
char* content;
2020-12-21 13:05:49 -05:00
struct stringlist* next;
} STRINGLIST;
2020-12-20 13:58:10 -05:00
2020-12-21 13:05:49 -05:00
char* heapstr(char* str, int len);
char* ezheapstr(char* str);
int countplaces(int n);
2020-12-20 13:58:10 -05:00
char* itoa(int i);
2020-12-21 14:49:37 -05:00
void* copy(void* v, int sz);
2020-12-21 13:05:49 -05:00
void printstrlist(STRINGLIST* strlist, FILE* stream);
void freestrlist(STRINGLIST* strlist);
2020-12-20 13:58:10 -05:00
#endif