From 1b6638f0739c089182ce1ecc16c58aca645c5927 Mon Sep 17 00:00:00 2001 From: Ilmir Usmanov Date: Mon, 28 Jul 2014 19:39:11 +0400 Subject: [PATCH] Add ERR_MEMORY exit code to show that there was not enough memory; fix debug.stm build --- src/globals.h | 1 + src/libjsparser/lexer.c | 2 ++ src/libruntime/jerry-exit.c | 3 +++ src/main.c | 2 +- 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/globals.h b/src/globals.h index 8e981bcc1..e8e2bd8df 100644 --- a/src/globals.h +++ b/src/globals.h @@ -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; diff --git a/src/libjsparser/lexer.c b/src/libjsparser/lexer.c index 587f1413c..ede7d67b4 100644 --- a/src/libjsparser/lexer.c +++ b/src/libjsparser/lexer.c @@ -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; diff --git a/src/libruntime/jerry-exit.c b/src/libruntime/jerry-exit.c index b82570d16..45f4368bf 100644 --- a/src/libruntime/jerry-exit.c +++ b/src/libruntime/jerry-exit.c @@ -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; diff --git a/src/main.c b/src/main.c index 1f1834f8b..c24067847 100644 --- a/src/main.c +++ b/src/main.c @@ -181,6 +181,6 @@ main(void) const size_t source_size = sizeof(generated_source); jerry_run( source_p, - source_size); + source_size, false); } #endif