Fixed memory error in exception printing.
Conflation between char* & char**.
This commit is contained in:
		@@ -78,13 +78,13 @@ void ast_num_print(ASTNumData* data, int i) {
 | 
				
			|||||||
    INDENT_END;
 | 
					    INDENT_END;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ASTExcData* ast_exc_data_init(char* msg) { return (ASTExcData*)msg; }
 | 
					ASTExcData ast_exc_data_init(char* msg) { return (ASTExcData)msg; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void ast_exc_print(ASTExcData* data, int i) {
 | 
					void ast_exc_print(ASTExcData data, int i) {
 | 
				
			||||||
    INDENT_BEGIN(i);
 | 
					    INDENT_BEGIN(i);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    INDENT_TITLE("ASTExcData", data);
 | 
					    INDENT_TITLE("ASTExcData", data);
 | 
				
			||||||
    INDENT_FIELD("msg", "\"%s\"", *data);
 | 
					    INDENT_FIELD("msg", "\"%s\"", data);
 | 
				
			||||||
    INDENT_END;
 | 
					    INDENT_END;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -72,7 +72,7 @@ AST* exec_call(AST* ast) {
 | 
				
			|||||||
        default: return ast_init(AST_TYPE_EXC, ast_exc_data_init("Good job"));
 | 
					        default: return ast_init(AST_TYPE_EXC, ast_exc_data_init("Good job"));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return ast_init(AST_TYPE_EXC, ast_exc_data_init("No such function found."));
 | 
					    return ast_init(AST_TYPE_EXC, ast_exc_data_init(strdup("No such function found.")));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
AST* exec_find(char* name) {
 | 
					AST* exec_find(char* name) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -20,7 +20,7 @@ void htab_destroy(HTab *htab) {
 | 
				
			|||||||
// Get the index of a key.
 | 
					// Get the index of a key.
 | 
				
			||||||
size_t geti(char* key) {
 | 
					size_t geti(char* key) {
 | 
				
			||||||
    uint64_t hash = fnv1a_hash(key, strlen(key));
 | 
					    uint64_t hash = fnv1a_hash(key, strlen(key));
 | 
				
			||||||
    size_t i = hash & (HTAB_SPACE - 1);
 | 
					    size_t i = hash & (HTAB_SPACE - 1); // Magic.
 | 
				
			||||||
    return i;
 | 
					    return i;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -32,7 +32,7 @@ void* htab_get(HTab* htab, char* key) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void htab_ins(HTab* htab, char* key, void* data) {
 | 
					void htab_ins(HTab* htab, char* key, void* data) {
 | 
				
			||||||
    size_t i = geti(key);
 | 
					    size_t i = geti(key);
 | 
				
			||||||
    assert((*htab)[i] == NULL);
 | 
					    //assert((*htab)[i] == NULL);
 | 
				
			||||||
    (*htab)[i] = data;
 | 
					    (*htab)[i] = data;
 | 
				
			||||||
    log_dbgf("Inserted something to hash table @ index %lu", i);
 | 
					    log_dbgf("Inserted something to hash table @ index %lu", i);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -42,9 +42,9 @@ void ast_num_print(ASTNumData*, int i);
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// An exception.
 | 
					// An exception.
 | 
				
			||||||
typedef char* ASTExcData;
 | 
					typedef char* ASTExcData;
 | 
				
			||||||
ASTExcData* ast_exc_data_init(char* msg);
 | 
					ASTExcData ast_exc_data_init(char* msg);
 | 
				
			||||||
void ast_exc_data_destroy(ASTExcData* exc);
 | 
					void ast_exc_data_destroy(ASTExcData* exc);
 | 
				
			||||||
void ast_exc_print(ASTExcData*, int i);
 | 
					void ast_exc_print(ASTExcData, int i);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// A built-in function.
 | 
					// A built-in function.
 | 
				
			||||||
typedef AST* (*ASTBIFData)(size_t argc, AST** argv);
 | 
					typedef AST* (*ASTBIFData)(size_t argc, AST** argv);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user