diff mbox series

[v2,11/18] storage: Use l_malloc

Message ID 20240202225405.993792-11-denkenz@gmail.com (mailing list archive)
State Accepted
Commit 4619f19d3ac79ecb10cc572b184bd849105274e6
Headers show
Series [v2,01/18] umlrunner: Also mount /var/lib as tmpfs | expand

Commit Message

Denis Kenzior Feb. 2, 2024, 10:53 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 eddb98c79598..47429c22d1bc 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;
 }