summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Schroeder <mls@suse.de>2009-06-24 13:53:30 +0200
committerMichael Schroeder <mls@suse.de>2009-06-24 13:53:30 +0200
commita250cf21640477b117471a3a07d5e35c68abcdd5 (patch)
treec90f94f2d5dfd80ae0b7a3564ccb8ebdc5ce2f96
parenta5aa1fa0b50db91e45f544e09ebcc1acf1f63c38 (diff)
downloadlibsolv-a250cf21640477b117471a3a07d5e35c68abcdd5.tar.gz
libsolv-a250cf21640477b117471a3a07d5e35c68abcdd5.tar.bz2
libsolv-a250cf21640477b117471a3a07d5e35c68abcdd5.zip
- add pool_tmpjoin and sat_dupjoin helpers
-rw-r--r--src/pool.c29
-rw-r--r--src/pool.h1
-rw-r--r--src/util.c28
-rw-r--r--src/util.h1
4 files changed, 59 insertions, 0 deletions
diff --git a/src/pool.c b/src/pool.c
index ec87a4b..9155c2f 100644
--- a/src/pool.c
+++ b/src/pool.c
@@ -1173,6 +1173,35 @@ pool_alloctmpspace(Pool *pool, int len)
return pool->tmpspacebuf[n];
}
+char *
+pool_tmpjoin(Pool *pool, const char *str1, const char *str2, const char *str3)
+{
+ int l1, l2, l3;
+ char *s, *str;
+ l1 = str1 ? strlen(str1) : 0;
+ l2 = str2 ? strlen(str2) : 0;
+ l3 = str3 ? strlen(str3) : 0;
+ s = str = pool_alloctmpspace(pool, l1 + l2 + l3 + 1);
+ if (l1)
+ {
+ strcpy(s, str1);
+ s += l1;
+ }
+ if (l2)
+ {
+ strcpy(s, str2);
+ s += l2;
+ }
+ if (l3)
+ {
+ strcpy(s, str3);
+ s += l3;
+ }
+ *s = 0;
+ return str;
+}
+
+
/*******************************************************************/
struct mptree {
diff --git a/src/pool.h b/src/pool.h
index 47e12cc..3df007b 100644
--- a/src/pool.h
+++ b/src/pool.h
@@ -176,6 +176,7 @@ extern void pool_free(Pool *pool);
extern void pool_debug(Pool *pool, int type, const char *format, ...) __attribute__((format(printf, 3, 4)));
extern char *pool_alloctmpspace(Pool *pool, int len);
+extern char *pool_tmpjoin(Pool *pool, const char *str1, const char *str2, const char *str3);
extern void pool_set_installed(Pool *pool, struct _Repo *repo);
diff --git a/src/util.c b/src/util.c
index cde01f4..7dea6aa 100644
--- a/src/util.c
+++ b/src/util.c
@@ -108,3 +108,31 @@ sat_sort(void *base, size_t nmemb, size_t size, int (*compar)(const void *, cons
{
qsort_r(base, nmemb, size, compar, compard);
}
+
+char *
+sat_dupjoin(const char *str1, const char *str2, const char *str3)
+{
+ int l1, l2, l3;
+ char *s, *str;
+ l1 = str1 ? strlen(str1) : 0;
+ l2 = str2 ? strlen(str2) : 0;
+ l3 = str3 ? strlen(str3) : 0;
+ s = str = sat_malloc(l1 + l2 + l3 + 1);
+ if (l1)
+ {
+ strcpy(s, str1);
+ s += l1;
+ }
+ if (l2)
+ {
+ strcpy(s, str2);
+ s += l2;
+ }
+ if (l3)
+ {
+ strcpy(s, str3);
+ s += l3;
+ }
+ *s = 0;
+ return str;
+}
diff --git a/src/util.h b/src/util.h
index e578faf..6191d43 100644
--- a/src/util.h
+++ b/src/util.h
@@ -29,6 +29,7 @@ extern void *sat_free(void *);
extern void sat_oom(size_t, size_t);
extern unsigned int sat_timems(unsigned int subtract);
extern void sat_sort(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *, void *), void *compard);
+extern char *sat_dupjoin(const char *str1, const char *str2, const char *str3);
static inline void *sat_extend(void *buf, size_t len, size_t nmemb, size_t size, size_t block)
{