frontlib: Removed reference counting from schemelist
authorMedo <smaxein@googlemail.com>
Mon, 06 Aug 2012 22:31:02 +0200
changeset 7464 859ab6859854
parent 7461 38acbfdb484f
child 7467 a9ab8067a2d1
frontlib: Removed reference counting from schemelist
project_files/frontlib/model/schemelist.c
project_files/frontlib/model/schemelist.h
--- a/project_files/frontlib/model/schemelist.c	Thu Aug 02 16:36:11 2012 +0200
+++ b/project_files/frontlib/model/schemelist.c	Mon Aug 06 22:31:02 2012 +0200
@@ -30,16 +30,6 @@
 #include <limits.h>
 #include <string.h>
 
-static void flib_schemelist_destroy(flib_schemelist *list) {
-	if(list) {
-		for(int i=0; i<list->schemeCount; i++) {
-			flib_scheme_release(list->schemes[i]);
-		}
-		free(list->schemes);
-		free(list);
-	}
-}
-
 static char *makePrefixedName(int schemeIndex, const char *settingName) {
 	return flib_asprintf("%i\\%s", schemeIndex, settingName);
 }
@@ -183,19 +173,16 @@
 }
 
 flib_schemelist *flib_schemelist_create() {
-	return flib_schemelist_retain(flib_calloc(1, sizeof(flib_schemelist)));
+	return flib_calloc(1, sizeof(flib_schemelist));
 }
 
-flib_schemelist *flib_schemelist_retain(flib_schemelist *list) {
+void flib_schemelist_destroy(flib_schemelist *list) {
 	if(list) {
-		flib_retain(&list->_referenceCount, "flib_schemelist");
-	}
-	return list;
-}
-
-void flib_schemelist_release(flib_schemelist *list) {
-	if(list && flib_release(&list->_referenceCount, "flib_schemelist")) {
-		flib_schemelist_destroy(list);
+		for(int i=0; i<list->schemeCount; i++) {
+			flib_scheme_release(list->schemes[i]);
+		}
+		free(list->schemes);
+		free(list);
 	}
 }
 
--- a/project_files/frontlib/model/schemelist.h	Thu Aug 02 16:36:11 2012 +0200
+++ b/project_files/frontlib/model/schemelist.h	Mon Aug 06 22:31:02 2012 +0200
@@ -29,7 +29,6 @@
 #include "scheme.h"
 
 typedef struct {
-	int _referenceCount;
 	int schemeCount;
 	flib_scheme **schemes;
 } flib_schemelist;
@@ -60,7 +59,7 @@
 int flib_schemelist_insert(flib_schemelist *list, flib_scheme *cfg, int pos);
 
 /**
- * Delete a cfg from the list at position pos, moving down all higher schemes.
+ * Delete a scheme from the list at position pos, moving down all higher schemes.
  * The scheme is released automatically.
  * Returns 0 on success.
  */
@@ -72,15 +71,9 @@
 flib_scheme *flib_schemelist_find(flib_schemelist *list, const char *name);
 
 /**
- * Increase the reference count of the object. Call this if you store a pointer to it somewhere.
- * Returns the parameter.
+ * Free this schemelist.
  */
-flib_schemelist *flib_schemelist_retain(flib_schemelist *list);
-
-/**
- * Decrease the reference count of the object and free it if this was the last reference.
- */
-void flib_schemelist_release(flib_schemelist *list);
+void flib_schemelist_destroy(flib_schemelist *list);
 
 
 #endif /* SCHEMELIST_H_ */