diff mbox series

[10/17] storage: Use l_malloc

Message ID 20240130212137.814082-10-denkenz@gmail.com (mailing list archive)
State Superseded
Commit 4619f19d3ac79ecb10cc572b184bd849105274e6
Headers show
Series [01/17] umlrunner: Also mount /var/lib as tmpfs | expand

Commit Message

Denis Kenzior Jan. 30, 2024, 9:21 p.m. UTC
Instead of g_try_malloc
---
 src/storage.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/src/storage.c b/src/storage.c
index 89c11cac4452..1c873474a927 100644
--- a/src/storage.c
+++ b/src/storage.c
@@ -61,10 +61,7 @@  int create_dirs(const char *filename, const mode_t mode)
 	if (!err && S_ISREG(st.st_mode))
 		return 0;
 
-	dir = g_try_malloc(strlen(filename) + 1);
-	if (dir == NULL)
-		return -1;
-
+	dir = l_malloc(strlen(filename) + 1);
 	strcpy(dir, "/");
 
 	for (prev = filename; (next = strchr(prev + 1, '/')); prev = next) {
@@ -75,12 +72,12 @@  int create_dirs(const char *filename, const mode_t mode)
 		strncat(dir, prev + 1, next - prev);
 
 		if (mkdir(dir, mode) == -1 && errno != EEXIST) {
-			g_free(dir);
+			l_free(dir);
 			return -1;
 		}
 	}
 
-	g_free(dir);
+	l_free(dir);
 	return 0;
 }