Use the error context API in espeak_ng_Initialize.

This commit is contained in:
Reece H. Dunn
2016-01-04 10:51:19 +00:00
parent 378490b65f
commit 013e282d1a
10 changed files with 55 additions and 25 deletions
+20 -3
View File
@@ -37,21 +37,38 @@ espeak_ng_STATUS create_file_error_context(espeak_ng_ERROR_CONTEXT *context, esp
{
if (context) {
if (*context) {
free((*context)->filename);
free((*context)->path);
} else {
*context = malloc(sizeof(espeak_ng_ERROR_CONTEXT_));
}
(*context)->filename = strdup(filename);
(*context)->path = strdup(filename);
(*context)->version = 0;
(*context)->expected_version = 0;
}
return status;
}
espeak_ng_STATUS create_version_mismatch_error_context(espeak_ng_ERROR_CONTEXT *context, const char *path_home, int version, int expected_version)
{
if (context) {
if (*context) {
free((*context)->path);
} else {
*context = malloc(sizeof(espeak_ng_ERROR_CONTEXT_));
}
(*context)->path = strdup(path_home);
(*context)->version = version;
(*context)->expected_version = expected_version;
}
return ENS_VERSION_MISMATCH;
}
#pragma GCC visibility push(default)
ESPEAK_NG_API void espeak_ng_ClearErrorContext(espeak_ng_ERROR_CONTEXT *context)
{
if (context && *context) {
free((*context)->filename);
free((*context)->path);
free(*context);
*context = NULL;
}