project_files/frontlib/model/scheme.c
changeset 7482 d70a5b0d1190
parent 7320 e704706008d4
child 7497 7e1d72fc03c7
equal deleted inserted replaced
7479:c8c552ee3acb 7482:d70a5b0d1190
    46 		}
    46 		}
    47 		free(meta);
    47 		free(meta);
    48 	}
    48 	}
    49 }
    49 }
    50 
    50 
    51 static void flib_scheme_destroy(flib_scheme* scheme) {
       
    52 	if(scheme) {
       
    53 		flib_metascheme_release(scheme->meta);
       
    54 		free(scheme->mods);
       
    55 		free(scheme->settings);
       
    56 		free(scheme->name);
       
    57 		free(scheme);
       
    58 	}
       
    59 }
       
    60 
       
    61 static flib_metascheme *flib_metascheme_from_ini_handleError(flib_metascheme *result, flib_ini *ini) {
    51 static flib_metascheme *flib_metascheme_from_ini_handleError(flib_metascheme *result, flib_ini *ini) {
    62 	flib_metascheme_destroy(result);
    52 	flib_metascheme_destroy(result);
    63 	flib_ini_destroy(ini);
    53 	flib_ini_destroy(ini);
    64 	return NULL;
    54 	return NULL;
    65 }
    55 }
   164 		flib_metascheme_destroy(meta);
   154 		flib_metascheme_destroy(meta);
   165 	}
   155 	}
   166 }
   156 }
   167 
   157 
   168 flib_scheme *flib_scheme_create(flib_metascheme *meta, const char *schemeName) {
   158 flib_scheme *flib_scheme_create(flib_metascheme *meta, const char *schemeName) {
   169 	flib_scheme *result = flib_scheme_retain(flib_calloc(1, sizeof(flib_scheme)));
   159 	flib_scheme *result = flib_calloc(1, sizeof(flib_scheme));
   170 	if(log_badargs_if2(meta==NULL, schemeName==NULL) || result==NULL) {
   160 	if(log_badargs_if2(meta==NULL, schemeName==NULL) || result==NULL) {
   171 		return NULL;
   161 		return NULL;
   172 	}
   162 	}
   173 
   163 
   174 	result->meta = flib_metascheme_retain(meta);
   164 	result->meta = flib_metascheme_retain(meta);
   197 		}
   187 		}
   198 	}
   188 	}
   199 	return result;
   189 	return result;
   200 }
   190 }
   201 
   191 
   202 flib_scheme *flib_scheme_retain(flib_scheme *scheme) {
   192 void flib_scheme_destroy(flib_scheme* scheme) {
   203 	if(scheme) {
   193 	if(scheme) {
   204 		flib_retain(&scheme->_referenceCount, "flib_scheme");
   194 		flib_metascheme_release(scheme->meta);
   205 	}
   195 		free(scheme->mods);
   206 	return scheme;
   196 		free(scheme->settings);
   207 }
   197 		free(scheme->name);
   208 
   198 		free(scheme);
   209 void flib_scheme_release(flib_scheme *scheme) {
       
   210 	if(scheme && flib_release(&scheme->_referenceCount, "flib_scheme")) {
       
   211 		flib_scheme_destroy(scheme);
       
   212 	}
   199 	}
   213 }
   200 }
   214 
   201 
   215 bool flib_scheme_get_mod(flib_scheme *scheme, const char *name) {
   202 bool flib_scheme_get_mod(flib_scheme *scheme, const char *name) {
   216 	if(!log_badargs_if2(scheme==NULL, name==NULL)) {
   203 	if(!log_badargs_if2(scheme==NULL, name==NULL)) {