-#include <stdint.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <limits.h>
#include "slvm.h"
#include "parser.h"
#include "pal.h"
if (*(ArgStack) > STRING)
{
/* Free the mem */
- free(p_str);
+ pal_free(p_str);
}
}
if (*(ArgStack))
{
size_t namesz = strlen((char*)*(ArgStack));
- name = (char*)malloc( namesz );
+ name = (char*)pal_allocate( namesz );
strcpy(name, (char*)*(ArgStack));
}
/* Create the word entry */
- word_t* word = (word_t*)malloc(sizeof(word_t));
+ word_t* word = (word_t*)pal_allocate(sizeof(word_t));
word->link = (word_t*)latest_val;
/* Initialize the flags (hidden and non-immediate by default) */
word->flags.attr.immed = 0;
/* Initialize the name, codeword, and bytecode */
word->name = name;
word->codeword = &docolon;
- word->code = (val_t*)malloc(sizeof(val_t));
+ word->code = (val_t*)pal_allocate(sizeof(val_t));
word->code[0] = (val_t)&ret;
/* Update Latest and Return the new word */
latest_val = (val_t)word;
ArgStack--;
/* Resize the code section and relocate if necessary */
word->flags.attr.codesize++;
- word->code = (val_t*)realloc(word->code, word->flags.attr.codesize * sizeof(val_t));
+ word->code = (val_t*)pal_reallocate(word->code, word->flags.attr.codesize * sizeof(val_t));
/* Update "here" and terminate the code section */
word->code[word->flags.attr.codesize-1] = (val_t)&ret;
}
else
{
/* Ask the user what gives */
- printf("%s ?\n", p_str);
+ pal_unknown_word(p_str);
/* Consume the token */
ArgStack--;
}
}
/* If we saved off a pointer, we're done with it so free the memory */
- if(p_str) free(p_str);
+ if(p_str) pal_free(p_str);
}
defcode("quit", quit, 0, &interp){