From c3eda2864e62e883874247bf4a77fddd0d4dd39a Mon Sep 17 00:00:00 2001
From: obarun <eric@obarun.org>
Date: Sun, 24 Feb 2019 03:37:03 +1100
Subject: [PATCH] remove stralloc

---
 src/lib66/tree_copy.c | 39 ++++++++++++---------------------------
 1 file changed, 12 insertions(+), 27 deletions(-)

diff --git a/src/lib66/tree_copy.c b/src/lib66/tree_copy.c
index 037dc8c7..d14876f3 100644
--- a/src/lib66/tree_copy.c
+++ b/src/lib66/tree_copy.c
@@ -14,46 +14,31 @@
  
 #include <66/tree.h>
 
+#include <string.h>
+
 #include <oblibs/string.h>
 #include <oblibs/directory.h>
 #include <oblibs/error2.h>
 
-#include <string.h>
-
 #include <skalibs/stralloc.h>
 #include <skalibs/djbunix.h>
 
 #include <66/constants.h>
 #include <66/utils.h>
-
+#include <stdio.h>
 int tree_copy(stralloc *dir, char const *tree,char const *treename)
 {
-	char *fdir = NULL ;
-
-	
-	stralloc tmp = STRALLOC_ZERO ;
-	stralloc fdirtmp = STRALLOC_ZERO ;
-	
-	fdir = dir_create_tmp(&fdirtmp,"/tmp",treename) ;
-	if (!fdir)
-	{
-		VERBO3 strerr_warnwu1x("create tempory directory") ;
-		return 0 ;
-	}
-	if (!stralloc_cats(&tmp,tree)) retstralloc(0,"copy_tree") ;
-	if (!stralloc_cats(&tmp,SS_SVDIRS)) retstralloc(0,"copy_tree") ;
-	if (!stralloc_0(&tmp)) retstralloc(0,"copy_tree") ;
+	char *fdir = 0 ;
+	size_t treelen = strlen(tree) ;
+	char tmp[treelen + SS_SVDIRS_LEN + 1] ;
+	memcpy(tmp,tree,treelen) ;
+	memcpy(tmp + treelen,SS_SVDIRS,SS_SVDIRS_LEN) ;
+	tmp[treelen + SS_SVDIRS_LEN] = 0 ;
 	
-	if (!hiercopy(tmp.s, fdir))
-	{
-		VERBO3 strerr_warnwu2sys("to copy tree: ",tmp.s) ;
-		return 0 ;
-	}
-	if (!stralloc_cats(dir,fdir)) retstralloc(0,"copy_tree") ;
-	if (!stralloc_0(dir)) retstralloc(0,"copy_tree") ;
+	fdir = dir_create_tmp(dir,"/tmp",treename) ;
+	if (!fdir) return 0 ;
 
-	stralloc_free(&tmp) ;
-	stralloc_free(&fdirtmp) ;
+	if (!hiercopy(tmp,fdir)) return 0 ;
 	
 	return 1 ;
 }
-- 
GitLab