#include <ctype.h>\r
#include <assert.h>\r
\r
-// Memory allocation\r
-#define C_MALLOC malloc\r
-#define C_FREE free\r
-#define C_REALLOC realloc\r
-#define C_MEMCPY memcpy\r
-\r
// Remove Prefix\r
#ifdef COMMONLIB_REMOVE_PREFIX\r
#define ASSERT c_ASSERT\r
#define ARRAY_LEN c_ARRAY_LEN\r
\r
#define da_append c_da_append\r
+#define da_free c_da_free\r
#define DYNAMIC_ARRAY_INITIAL_CAPACITY c_DYNAMIC_ARRAY_INITIAL_CAPACITY\r
// #define c_DYNAMIC_ARRAY_INITIAL_CAPACITY\r
\r
\r
#endif // COMMONLIB_REMOVE_PREFIX\r
\r
+// Memory allocation\r
+#ifndef C_MALLOC\r
+#define C_MALLOC malloc\r
+#endif\r
+#ifndef C_FREE\r
+#define C_FREE free\r
+#endif\r
+#ifndef C_REALLOC\r
+#define C_REALLOC realloc\r
+#endif\r
+#ifndef C_MEMCPY\r
+#define C_MEMCPY memcpy\r
+#endif\r
+\r
+\r
// typedefs\r
typedef unsigned int uint;\r
typedef uint8_t uint8;\r
} while (0)\r
\r
#define c_da_pop_front(da) (c_ASSERT(da.count > 0, "Array is empty"), da.count--, *da.items++)\r
+#define c_da_free(da) C_FREE(da.items)\r
\r
//\r
// OS\r
return l;
}
+void free_lexer(Lexer *l) {
+ free(l->src.data);
+}
+
bool eof(Lexer *l) {
return l->cur >= l->src.count;
}
Lexer l = make_lexer(filename);
- lex(&l);
+ Tokens tokens = lex(&l);
info("OK");
+
+ free_lexer(&l);
+
+ da_free(tokens);
return 0;
}