From 74db6dac632c7b71376488c927dd76c7dd26f312 Mon Sep 17 00:00:00 2001 From: "Reece H. Dunn" Date: Sat, 2 Jan 2016 10:49:37 +0000 Subject: [PATCH] Use the ENOMEM errno code instead of ENE_OUT_OF_MEMORY. --- src/include/espeak-ng/espeak_ng.h | 5 ++--- src/libespeak-ng/compiledata.c | 3 ++- src/libespeak-ng/speak_lib.c | 5 +++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/include/espeak-ng/espeak_ng.h b/src/include/espeak-ng/espeak_ng.h index 65095507..acfbf94e 100644 --- a/src/include/espeak-ng/espeak_ng.h +++ b/src/include/espeak-ng/espeak_ng.h @@ -31,15 +31,14 @@ extern "C" #endif typedef enum { - /* Success Codes (>= 0) */ - ENS_OK = 0, + /* 0 to 255 : errno */ + /* Error Codes (< 0) */ ENE_READ_ERROR = -1, ENE_WRITE_ERROR = -2, - ENE_OUT_OF_MEMORY = -3, ENE_COMPILE_ERRORS = -4, ENE_VERSION_MISMATCH = -5, } espeak_ng_STATUS; diff --git a/src/libespeak-ng/compiledata.c b/src/libespeak-ng/compiledata.c index 90583a7d..2b7c9a74 100644 --- a/src/libespeak-ng/compiledata.c +++ b/src/libespeak-ng/compiledata.c @@ -19,6 +19,7 @@ #include "config.h" +#include #include #include #include @@ -2862,7 +2863,7 @@ espeak_ng_STATUS espeak_ng_CompileIntonation(FILE *log) fprintf(f_errors, "Failed to allocate data for tunes\n"); fclose(f_in); fclose(f_errors); - return ENE_OUT_OF_MEMORY; + return ENOMEM; } sprintf(buf, "%s/intonations", path_home); diff --git a/src/libespeak-ng/speak_lib.c b/src/libespeak-ng/speak_lib.c index 447092bf..0bfa482e 100644 --- a/src/libespeak-ng/speak_lib.c +++ b/src/libespeak-ng/speak_lib.c @@ -19,6 +19,7 @@ #include "config.h" +#include "errno.h" #include "stdio.h" #include "ctype.h" #include "string.h" @@ -224,13 +225,13 @@ ESPEAK_NG_API espeak_ng_STATUS espeak_ng_InitializeOutput(espeak_ng_OUTPUT_MODE outbuf_size = (buffer_length * samplerate)/500; outbuf = (unsigned char *)realloc(outbuf, outbuf_size); if ((out_start = outbuf) == NULL) - return ENE_OUT_OF_MEMORY; + return ENOMEM; // allocate space for event list. Allow 200 events per second. // Add a constant to allow for very small buf_length n_event_list = (buffer_length*200)/1000 + 20; if ((event_list = (espeak_EVENT *)realloc(event_list, sizeof(espeak_EVENT) * n_event_list)) == NULL) - return ENE_OUT_OF_MEMORY; + return ENOMEM; return ENS_OK; }