static void unload_voice_plugins(SList *plugins, s_erc *error) { SIterator *itr; SObject *plugin; S_CLR_ERR(error); itr = S_ITERATOR_GET(plugins, error); if (S_CHK_ERR(error, S_CONTERR, "unload_voice_plugins", "Call to \"S_ITERATOR_GET\" failed")) return; while (itr != NULL) { plugin = SIteratorUnlink(itr, error); if (S_CHK_ERR(error, S_CONTERR, "unload_voice_plugins", "Call to \"SIteratorUnlink\" failed")) { S_DELETE(itr, "unload_voice_plugins", error); return; } S_DELETE(plugin, "unload_voice_plugins", error); itr = SIteratorNext(itr); } S_DELETE(plugins, "unload_voice_plugins", error); }
/* plug-in register function */ static void plugin_register_function(s_erc *error) { S_CLR_ERR(error); /* load phoneset plug-in */ phonesetPlugin = s_pm_load_plugin("phoneset.spi", error); if (S_CHK_ERR(error, S_CONTERR, SPCT_PLUGIN_REG_STR, "Call to \"s_pm_load_plugin\" failed")) return; /* register plug-in classes here */ _s_phoneset_json_class_reg(error); if (S_CHK_ERR(error, S_CONTERR, SPCT_PLUGIN_REG_STR, SPCT_PLUGIN_REG_FAIL_STR)) { S_DELETE(phonesetPlugin, SPCT_PLUGIN_REG_STR, error); return; } _s_serialized_json_phoneset_reg(error); if (S_CHK_ERR(error, S_CONTERR, SPCT_PLUGIN_REG_STR, "Failed to register SJSONPhonesetFile class")) { s_erc local_err = S_SUCCESS; S_DELETE(phonesetPlugin, SPCT_PLUGIN_REG_STR, error); _s_phoneset_json_class_free(&local_err); return; } }
/* plug-in register function */ static void plugin_register_function(s_erc *error) { S_CLR_ERR(error); /* * load the ebml plug-in */ ebmlPlugin = s_pm_load_plugin("ebml.spi", error); if (S_CHK_ERR(error, S_CONTERR, SPCT_PLUGIN_REG_STR, "Call to \"s_pm_load_plugin\" failed")) return; trackFloatPlugin = s_pm_load_plugin("track_float.spi", error); if (S_CHK_ERR(error, S_CONTERR, SPCT_PLUGIN_REG_STR, "Call to \"s_pm_load_plugin\" failed")) { S_DELETE(ebmlPlugin, SPCT_PLUGIN_REG_STR, error); return; } /* register plug-in classes here */ _s_serialized_ebml_track_float_reg(error); if (S_CHK_ERR(error, S_CONTERR, SPCT_PLUGIN_REG_STR, SPCT_PLUGIN_REG_FAIL_STR)) { S_DELETE(trackFloatPlugin, SPCT_PLUGIN_REG_STR, error); S_DELETE(ebmlPlugin, SPCT_PLUGIN_REG_STR, error); return; } }
S_API void STokenstreamFileInit(STokenstreamFile **self, const char *path, s_erc *error) { S_CLR_ERR(error); if (path == NULL) { S_CTX_ERR(error, S_ARGERROR, "STokenstreamFileInit", "Argument \"path\" is NULL"); return; } (*self)->ds = SFilesourceOpenFile(path, "r", error); if (S_CHK_ERR(error, S_CONTERR, "STokenstreamFileInit", "Call to \"SFilesourceOpenFile\" failed")) { S_DELETE(*self, "STokenstreamFileInit", error); *self = NULL; return; } /* get the first character */ STokenstreamGetChar(S_TOKENSTREAM(*self), error); if (S_CHK_ERR(error, S_CONTERR, "STokenstreamFileInit", "Call to \"STokenstreamGetChar\" failed")) { S_DELETE(*self, "STokenstreamFileInit", error); *self = NULL; return; } }
D3DShaderManager::~D3DShaderManager() { // Safely delete all the shader objects. S_DELETE(m_TextureShader); S_DELETE(m_D3DLightShader); S_DELETE(m_BumpMapShader); }
/* plug-in register function */ static void plugin_register_function(s_erc *error) { S_CLR_ERR(error); /* load plug-ins */ syllabificationPlugin = s_pm_load_plugin("syllabification.spi", error); if (S_CHK_ERR(error, S_CONTERR, SPCT_PLUGIN_REG_STR, "Call to \"s_pm_load_plugin\" failed")) return; /* register plug-in classes here */ _s_syllabification_rewrites_rule_class_reg(error); if (S_CHK_ERR(error, S_CONTERR, SPCT_PLUGIN_REG_STR, "Failed to register SSyllabificationRewritesRule class")) { S_DELETE(syllabificationPlugin, SPCT_PLUGIN_REG_STR, error); return; } _s_syllabification_rewrites_class_reg(error); if (S_CHK_ERR(error, S_CONTERR, SPCT_PLUGIN_REG_STR, SPCT_PLUGIN_REG_FAIL_STR)) { s_erc local_err = S_SUCCESS; _s_syllabification_rewrites_rule_class_free(&local_err); S_DELETE(syllabificationPlugin, SPCT_PLUGIN_REG_STR, error); return; } }
State::~State() { // Give the state access to the DirectX systems S_DELETE(m_CpuMonitor); S_DELETE(m_HPRTimer); S_DELETE(m_RenderToTexture); S_DELETE( m_MouseBitmap ); }
static s_bool _item_match(const char *PATT, const char *THING, const SMap *sets, s_erc *error) { int rv; s_bool is_present; const SObject *tmp; const SList *setList; SObject *thingObject; S_CLR_ERR(error); rv = s_strcmp(PATT, THING, error); if (S_CHK_ERR(error, S_CONTERR, "_item_match", "Call to \"s_strcmp\" failed")) return FALSE; if (rv == 0) return TRUE; if (sets == NULL) return FALSE; tmp = SMapGetObjectDef(sets, PATT, NULL, error); if (S_CHK_ERR(error, S_CONTERR, "_item_match", "Call to \"SMapGetObjectDef\" failed")) return FALSE; if (tmp == NULL) return FALSE; setList = S_CAST(tmp, SList, error); if (S_CHK_ERR(error, S_CONTERR, "_item_match", "Call to \"S_CAST(SList)\" failed")) return FALSE; thingObject = SObjectSetString(THING, error); if (S_CHK_ERR(error, S_CONTERR, "_item_match", "Call to \"SObjectSetString\" failed")) return FALSE; is_present = SListValPresent(setList, thingObject, error); if (S_CHK_ERR(error, S_CONTERR, "_item_match", "Call to \"SListValPresent\" failed")) { S_DELETE(thingObject, "_item_match", error); return FALSE; } S_DELETE(thingObject, "_item_match", error); return is_present; }
static void Destroy(void *obj, s_erc *error) { SViterbiPath *self = obj; S_CLR_ERR(error); if (self->features != NULL) S_DELETE(self->features, "Destroy", error); if (self->next != NULL) S_DELETE(self->next, "Destroy", error); }
static void DestroyMapPy(void *obj, s_erc *error) { SMapPy *self = obj; S_CLR_ERR(error); if (self->pyObject != NULL) S_DELETE(self->pyObject, "DestroyMapPy", error); if (self->staticObjects != NULL) S_DELETE(self->staticObjects, "DestroyMapPy", error); }
/* plug-in exit function */ static void plugin_exit_function(s_erc *error) { S_CLR_ERR(error); /* free plug-in classes here */ _s_serialized_ebml_track_float_free(error); S_CHK_ERR(error, S_CONTERR, SPCT_PLUGIN_EXIT_STR, SPCT_PLUGIN_EXIT_FAIL_STR); S_DELETE(ebmlPlugin, SPCT_PLUGIN_EXIT_STR, error); S_DELETE(trackFloatPlugin, SPCT_PLUGIN_EXIT_STR, error); }
static void Destroy(void *obj, s_erc *error) { STokenstreamFile *self = obj; S_CLR_ERR(error); if (self->ds != NULL) S_DELETE(self->ds, "Destroy", error); if (--num_file_tokenstreams == 0) S_DELETE(tokenstream, "Destroy", error); }
static void s_compute_stresses ( const SFeatProcessor* proc, SItem* word, s_erc *error ) { S_CLR_ERR(error); SItem *wordAsSylStructure = SItemAs(word, "SylStructure", error); if (S_CHK_ERR(error, S_CONTERR, "s_compute_stresses", "Call to \"SItemAs\" failed")) return; SItem *syllable = SItemDaughter(wordAsSylStructure, error); if (S_CHK_ERR(error, S_CONTERR, "s_compute_stresses", "Call to \"SItemDaughter\" failed")) return; SObject* result = NULL; while (syllable != NULL) { result = SFeatProcessorRun ( proc, syllable, error); if (S_CHK_ERR(error, S_CONTERR, "s_compute_stresses", "Call to \"SItemPathToFeatProc\" failed")) goto s_compute_stresses_cleanup; const char* resultString = SObjectGetString ( result, error ); if (S_CHK_ERR(error, S_CONTERR, "s_compute_stresses", "Call to \"SObjectGetInt\" failed")) goto s_compute_stresses_cleanup; SItemSetString ( syllable, "stress", resultString, error ); if (S_CHK_ERR(error, S_CONTERR, "s_compute_stresses", "Call to \"SItemSetInt\" failed")) goto s_compute_stresses_cleanup; syllable = SItemNext ( syllable, error ); if (S_CHK_ERR(error, S_CONTERR, "s_compute_stresses", "Call to \"SItemNext\" failed")) goto s_compute_stresses_cleanup; if(result != NULL) { S_DELETE(result, "s_compute_stresses", error); } } s_compute_stresses_cleanup: if(result != NULL) { S_DELETE(result, "s_compute_stresses", error); } }
static void DestroyUtt(void *obj, s_erc *error) { SUtterance *self = obj; SIterator *itr; SRelation *rel; S_CLR_ERR(error); s_mutex_lock(&(self->utt_mutex)); S_DELETE(self->features, "DestroyUtt", error); /* Relations don't delete their contents (no dispose) */ itr = S_ITERATOR_GET(self->relations, error); if (S_CHK_ERR(error, S_CONTERR, "DestroyUtt", "Call to \"S_ITERATOR_GET\" failed")) { S_DELETE(self->relations, "DestroyUtt", error); s_mutex_unlock(&(self->utt_mutex)); s_mutex_destroy(&(self->utt_mutex)); return; } while (itr) { rel = S_RELATION(SIteratorUnlink(itr, error)); if (S_CHK_ERR(error, S_CONTERR, "DestroyUtt", "Call to \"SMapIteratorUnlink\" failed")) { S_DELETE(self->relations, "DestroyUtt", error); S_DELETE(itr, "DestroyUtt", error); s_mutex_unlock(&(self->utt_mutex)); s_mutex_destroy(&(self->utt_mutex)); return; } S_FORCE_DELETE(rel, "DestroyUtt", error); itr = SIteratorNext(itr); } S_DELETE(self->relations, "DestroyUtt", error); s_mutex_unlock(&(self->utt_mutex)); s_mutex_destroy(&(self->utt_mutex)); s_mutex_destroy(&(self->utt_id_mutex)); }
S_API void SMapPyInit(SMapPy **self, PyObject *object, s_erc *error) { S_CLR_ERR(error); if ((*self) == NULL) { S_CTX_ERR(error, S_ARGERROR, "SMapPyInit", "Argument \"self\" is NULL"); goto error_clean_up; } if (object == NULL) { S_CTX_ERR(error, S_ARGERROR, "SMapPyInit", "Argument \"self\" is NULL"); goto error_clean_up; } /* set this map's Python object */ SPyObjectSet((*self)->pyObject, object, error); if (S_CHK_ERR(error, S_ARGERROR, "SMapPyInit", "Call to \"SPyObjectSet\" failed")) goto error_clean_up; /* all OK */ return; /* clean up code */ error_clean_up: S_DELETE((*self), "SMapPyInit", error); (*self) = NULL; }
/* plug-in exit function */ static void plugin_exit_function(s_erc *error) { s_erc local_err = S_SUCCESS; S_CLR_ERR(error); /* free plug-in classes here */ _s_serialized_json_phoneset_free(&local_err); S_CHK_ERR(&local_err, S_CONTERR, SPCT_PLUGIN_EXIT_STR, "Failed to free SJSONPhonesetFile class"); _s_phoneset_json_class_free(error); S_CHK_ERR(error, S_CONTERR, SPCT_PLUGIN_EXIT_STR, SPCT_PLUGIN_EXIT_FAIL_STR); if ((error != NULL) && (*error == S_SUCCESS) && (local_err != S_SUCCESS)) *error = local_err; S_DELETE(phonesetPlugin, SPCT_PLUGIN_EXIT_STR, error); }
/* plug-in exit function */ static void plugin_exit_function(s_erc *error) { s_erc local_err = S_SUCCESS; S_CLR_ERR(error); /* free plug-in classes here */ _s_syllabification_rewrites_rule_class_free(error); if (S_CHK_ERR(error, S_CONTERR, SPCT_PLUGIN_EXIT_STR, "Failed to free SSyllabificationRewritesRule class")) if (error != NULL) local_err = *error; _s_syllabification_rewrites_class_free(error); if (S_CHK_ERR(error, S_CONTERR, SPCT_PLUGIN_EXIT_STR, SPCT_PLUGIN_EXIT_FAIL_STR)) if (error != NULL) local_err = *error; if ((error != NULL) && (*error == S_SUCCESS) && (local_err != S_SUCCESS)) *error = local_err; S_DELETE(syllabificationPlugin, SPCT_PLUGIN_EXIT_STR, error); }
S_API SObject *SObjectSetString(const char *s, s_erc *error) { SString *self; S_CLR_ERR(error); if (s == NULL) { S_CTX_ERR(error, S_ARGERROR, "SObjectSetString", "Argument \"s\" is NULL"); return NULL; } self = S_NEW(SString, error); if (S_CHK_ERR(error, S_FAILURE, "SObjectSetString", "Failed to create new SString object")) return NULL; self->s = s_strdup(s, error); if (S_CHK_ERR(error, S_CONTERR, "SObjectSetString", "Failed to copy string")) { S_DELETE(self, "SObjectSetString", error); return NULL; } return S_OBJECT(self); }
bool MatchPool::pop(int size_type, MatchRes &res) { std::vector<MatchEntity*> camps; for (int i = 0;i < _camp_size; i++) { MatchEntity *ent = E_NEW MatchEntity; ent->camp = i; camps.push_back(ent); } int success = pop(size_type, camps); // merge result res.type = _type; for (size_t i = 0;i < camps.size(); i++) { TeamSet members; camps[i]->get_members(members); if (!success) { // restore TeamSet::iterator itr = members.begin(); for (;itr != members.end(); ++itr) { MatchEntity *ent = get_entity(*itr); if (ent) { ent->status = MATCH_PENDING; } } } else { res.teams.push_back(members); } S_DELETE(camps[i]); } return success; }
static void DestroyItmContent(void *obj, s_erc *error) { SItmContent *self = obj; S_CLR_ERR(error); s_mutex_lock(&(self->content_mutex)); if (self->relations != NULL) S_DELETE(self->relations, "DestroyItmContent", error); if (self->features != NULL) S_DELETE(self->features, "DestroyItmContent", error); s_mutex_unlock(&(self->content_mutex)); s_mutex_destroy(&(self->content_mutex)); }
static void Destroy(void *obj, s_erc *error) { SViterbiCandidate *self = obj; S_CLR_ERR(error); if (self->next != NULL) S_DELETE(self->next, "Destroy", error); }
static void DestroyDataWriter(void *obj, s_erc *error) { SDataWriter *self = obj; S_CLR_ERR(error); if (self->ds != NULL) S_DELETE(self->ds, "DestroyDataWriter", error); }
S_API SDatasource *SMMapFilesourceOpenFile(const char *path, s_erc *error) { SMMapFilesource *self; uint8 *mem; size_t map_size; s_mmap_file_handle *handle; S_CLR_ERR(error); self = S_NEW(SMMapFilesource, error); if (S_CHK_ERR(error, S_CONTERR, "SMMapFilesourceOpenFile", "Failed to create new object")) return NULL; self->path = s_strdup(path, error); if (S_CHK_ERR(error, S_CONTERR, "SMMapFilesourceOpenFile", "Failed to duplicate file path")) { S_DELETE(self, "SMMapFilesourceOpenFile", error); return NULL; } handle = s_mmapfile_open(path, &map_size, &mem, error); if (S_CHK_ERR(error, S_CONTERR, "SMMapFilesourceOpenFile" "Call to \"s_mmapfile_open\" failed for file \"%s\"", path)) { S_DELETE(self, "SMMapFilesourceOpenFile", error); return NULL; } self->handle = handle; self->mem = mem; self->map_size = map_size; return S_DATASOURCE(self); }
/* plug-in exit function */ static void plugin_exit_function(s_erc *error) { S_CLR_ERR(error); /* free plug-in classes here */ _s_word_pos_class_free(error); S_CHK_ERR(error, S_CONTERR, SPCT_PLUGIN_EXIT_STR, SPCT_PLUGIN_EXIT_FAIL_STR); S_DELETE(costFuncPlugin, SPCT_PLUGIN_EXIT_STR, error); }
/* plug-in exit function */ static void plugin_exit_function(s_erc *error) { S_CLR_ERR(error); /* free plug-in classes here */ _s_hts_engine_synth_utt_proc_104_class_free(error); S_CHK_ERR(error, S_CONTERR, SPCT_PLUGIN_EXIT_STR, SPCT_PLUGIN_EXIT_FAIL_STR); S_DELETE(audioPlugin, SPCT_PLUGIN_EXIT_STR, error); }
/* plug-in exit function */ static void plugin_exit_function(s_erc *error) { S_CLR_ERR(error); /* free plug-in classes here */ _s_serialized_json_syllabification_rewrites_free(error); S_CHK_ERR(error, S_CONTERR, SPCT_PLUGIN_EXIT_STR, SPCT_PLUGIN_EXIT_FAIL_STR); S_DELETE(syllabificationRewritesPlugin, SPCT_PLUGIN_EXIT_STR, error); }
static int _ds_close(void * context) { s_erc error; SDatasource * ds = (SDatasource*) context; S_CLR_ERR(&error); if (ds != NULL) S_DELETE(ds, "_ds_close", &error); if (S_CHK_ERR(&error, S_CONTERR, "_ds_close", "Call to \"xmlOutputClose\" failed")) return -1; return 0; }
static void Destroy(void *obj, s_erc *error) { S_CLR_ERR(error); SPhraseTypeFeatProc *castSelf = S_CAST(obj, SPhraseTypeFeatProc, error); if (S_CHK_ERR(error, S_CONTERR, "Destroy", "Call to S_CAST failed")) return; if(castSelf->symbols != NULL) { /* delete the symbols map */ S_DELETE(castSelf->symbols, "Destroy", error); castSelf->symbols = NULL; } }
static void SetFeature(const SCostFunction *self, SItem *item, s_erc *error) { SObject *extractedFeature = NULL; S_CLR_ERR(error); if (item == NULL) { S_CTX_ERR(error, S_ARGERROR, "SetFeature", "Argument \"item\" is NULL"); goto quit_error; } extractedFeature = SItemPathToFeatProc(item, "R:SylStructure.parent.parent.word_num_syls", error); if (S_CHK_ERR(error, S_CONTERR, "SetFeature", "Call to \"SItemPathToFeatProc\" failed")) goto quit_error; if (extractedFeature == NULL) { /* segment item might not have a word, e.g inserted silences. */ extractedFeature = SObjectSetInt(0, error); if (S_CHK_ERR(error, S_CONTERR, "SetFeature", "Call to \"SObjectSetInt\" failed")) goto quit_error; } SItemSetObject(item, self->feature_name, extractedFeature, error); if (S_CHK_ERR(error, S_CONTERR, "SetFeature", "Call to \"SItemSetObject\" failed")) goto quit_error; /* all OK here */ return; /* errors be here */ quit_error: if (extractedFeature != NULL) S_DELETE(extractedFeature, "SetFeature", error); }
S_API SObject *SObjectSetVoid(void *ptr, const char *type_name, s_svoid_free_fp free_func, s_erc *error) { SVoid *self; S_CLR_ERR(error); if (ptr == NULL) { S_CTX_ERR(error, S_ARGERROR, "SObjectSetVoid", "Argument \"ptr\" is NULL"); return NULL; } if (type_name == NULL) { S_CTX_ERR(error, S_ARGERROR, "SObjectSetVoid", "Argument \"type_name\" is NULL"); return NULL; } self = S_NEW(SVoid, error); if (S_CHK_ERR(error, S_FAILURE, "SObjectSetVoid", "Failed to create new 'SVoid' object")) return NULL; self->ptr = ptr; self->free_func = free_func; self->type_name = s_strdup(type_name, error); if (S_CHK_ERR(error, S_CONTERR, "SObjectSetVoid", "Failed to copy type name")) { S_DELETE(self, "SObjectSetVoid", error); return NULL; } return S_OBJECT(self); }