trying not to leak memory
This commit is contained in:
+7
-8
@@ -98,7 +98,6 @@ namespace Parser {
|
||||
|
||||
// get the atom
|
||||
String* ret = Memory::create_string("", atom_length);
|
||||
// char* atom = (char*)malloc(atom_length*sizeof(char)+1); // plus null char
|
||||
strcpy(&ret->data, text+(*index_in_text));
|
||||
|
||||
// restore the original string
|
||||
@@ -448,7 +447,7 @@ namespace Parser {
|
||||
|
||||
}
|
||||
|
||||
proc write_expanded_file(String* file_name, Array_List<Lisp_Object*> program) -> void {
|
||||
proc write_expanded_file(String* file_name, Array_List<Lisp_Object*>* program) -> void {
|
||||
const char* ext = ".expanded";
|
||||
char* newName = (char*)calloc(10 + file_name->length, sizeof(char));
|
||||
strcpy(newName, Memory::get_c_str(file_name));
|
||||
@@ -465,21 +464,21 @@ namespace Parser {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
for (int i = 0; i < program.next_index; ++i) {
|
||||
for (int i = 0; i < program->next_index; ++i) {
|
||||
// a macro will parse as nil for now, so we skip those
|
||||
if (program.data[i] == Memory::nil)
|
||||
if (program->data[i] == Memory::nil)
|
||||
continue;
|
||||
print(program.data[i], true, f);
|
||||
print(program->data[i], true, f);
|
||||
fprintf(f, "\n\n");
|
||||
}
|
||||
}
|
||||
|
||||
proc parse_program(String* file_name, char* text) -> Array_List<Lisp_Object*> {
|
||||
proc parse_program(String* file_name, char* text) -> Array_List<Lisp_Object*>* {
|
||||
parser_file = file_name;
|
||||
parser_line = 1;
|
||||
parser_col = 0;
|
||||
|
||||
Array_List<Lisp_Object*> program;
|
||||
Array_List<Lisp_Object*>* program = new Array_List<Lisp_Object*>;
|
||||
|
||||
int index_in_text = 0;
|
||||
|
||||
@@ -490,7 +489,7 @@ namespace Parser {
|
||||
try_struct {
|
||||
parsed = parse_expression(text, &index_in_text);
|
||||
}
|
||||
program.append(parsed);
|
||||
program->append(parsed);
|
||||
} break;
|
||||
case ';':
|
||||
case ' ':
|
||||
|
||||
Reference in New Issue
Block a user