Browse Source

fold uci_file_cleanup into uci_cleanup

Felix Fietkau 16 years ago
parent
commit
c57e7c3943
2 changed files with 21 additions and 21 deletions
  1. 0 20
      file.c
  2. 21 1
      libuci.c

+ 0 - 20
file.c

@@ -30,26 +30,6 @@
  */
 static void uci_file_cleanup(struct uci_context *ctx)
 {
-	struct uci_parse_context *pctx;
-
-	if (ctx->buf) {
-		free(ctx->buf);
-		ctx->buf = NULL;
-		ctx->bufsz = 0;
-	}
-
-	pctx = ctx->pctx;
-	if (!pctx)
-		return;
-
-	ctx->pctx = NULL;
-	if (pctx->package)
-		uci_free_package(&pctx->package);
-
-	if (pctx->buf)
-		free(pctx->buf);
-
-	free(pctx);
 }
 
 

+ 21 - 1
libuci.c

@@ -104,8 +104,28 @@ int uci_set_confdir(struct uci_context *ctx, const char *dir)
 
 int uci_cleanup(struct uci_context *ctx)
 {
+	struct uci_parse_context *pctx;
 	UCI_HANDLE_ERR(ctx);
-	uci_file_cleanup(ctx);
+
+	if (ctx->buf) {
+		free(ctx->buf);
+		ctx->buf = NULL;
+		ctx->bufsz = 0;
+	}
+
+	pctx = ctx->pctx;
+	if (!pctx)
+		goto done;
+
+	ctx->pctx = NULL;
+	if (pctx->package)
+		uci_free_package(&pctx->package);
+
+	if (pctx->buf)
+		free(pctx->buf);
+
+	free(pctx);
+done:
 	return 0;
 }