Add ERR_MEMORY exit code to show that there was not enough memory; fix debug.stm build

This commit is contained in:
Ilmir Usmanov 2014-07-28 19:39:11 +04:00
parent d927d3e320
commit 1b6638f073
4 changed files with 7 additions and 1 deletions

View File

@ -53,6 +53,7 @@ typedef enum
ERR_INT_LITERAL = -7,
ERR_STRING = -8,
ERR_PARSER = -9,
ERR_MEMORY = -10,
ERR_GENERAL = -255
} jerry_status_t;

View File

@ -277,6 +277,8 @@ current_token (void)
JERRY_ASSERT (token_start <= buffer);
size_t length = (size_t) (buffer - token_start);
char *res = (char *) mem_heap_alloc_block (length + 1, MEM_HEAP_ALLOC_SHORT_TERM);
if (res == NULL)
parser_fatal (ERR_MEMORY);
__strncpy (res, token_start, length);
res[length] = '\0';
token_start = NULL;

View File

@ -66,6 +66,9 @@ jerry_exit( jerry_status_t code) /**< status code */
case ERR_PARSER:
__printf("ERR_PARSER\n");
break;
case ERR_MEMORY:
__printf("ERR_MEMORY\n");
break;
case ERR_GENERAL:
__printf("ERR_GENERAL\n");
break;

View File

@ -181,6 +181,6 @@ main(void)
const size_t source_size = sizeof(generated_source);
jerry_run( source_p,
source_size);
source_size, false);
}
#endif