return "";
rd = GETRELDEP(pool, id);
if (ISRELDEP(rd->evr))
- return "REL";
+ return "(REL)";
return pool->ss.stringspace + pool->ss.strings[rd->evr];
}
-const char *
-dep2str(Pool *pool, Id id)
+static int
+dep2strlen(Pool *pool, Id id)
{
- Reldep *rd;
- const char *sr;
- char *s1, *s2;
- int n, l, ls1, ls2, lsr;
-
- if (!ISRELDEP(id))
- return pool->ss.stringspace + pool->ss.strings[id];
- rd = GETRELDEP(pool, id);
- n = pool->dep2strn;
+ int l = 0;
- sr = id2rel(pool, id);
- lsr = strlen(sr);
-
- s2 = (char *)dep2str(pool, rd->evr);
- pool->dep2strn = n;
- ls2 = strlen(s2);
-
- s1 = (char *)dep2str(pool, rd->name);
- pool->dep2strn = n;
- ls1 = strlen(s1);
-
- if (rd->flags == REL_NAMESPACE)
+ while (ISRELDEP(id))
{
- sr = "(";
- lsr = 1;
- ls2++;
+ Reldep *rd = GETRELDEP(pool, id);
+ l += dep2strlen(pool, rd->name) + strlen(id2rel(pool, id));
+ id = rd->evr;
}
+ return l + strlen(pool->ss.stringspace + pool->ss.strings[id]);
+}
- l = ls1 + ls2 + lsr;
- if (l + 1 > pool->dep2strlen[n])
+static void
+dep2strcpy(Pool *pool, char *p, Id id)
+{
+ while (ISRELDEP(id))
{
- if (s1 != pool->dep2strbuf[n])
- pool->dep2strbuf[n] = sat_realloc(pool->dep2strbuf[n], l + 32);
- else
+ Reldep *rd = GETRELDEP(pool, id);
+ dep2strcpy(pool, p, rd->name);
+ p += strlen(p);
+ if (rd->flags == REL_NAMESPACE)
{
- pool->dep2strbuf[n] = sat_realloc(pool->dep2strbuf[n], l + 32);
- s1 = pool->dep2strbuf[n];
+ *p++ = '(';
+ dep2strcpy(pool, p, rd->evr);
+ strcat(p, ")");
+ return;
}
- pool->dep2strlen[n] = l + 32;
- }
- if (s1 != pool->dep2strbuf[n])
- {
- strcpy(pool->dep2strbuf[n], s1);
- s1 = pool->dep2strbuf[n];
+ strcpy(p, id2rel(pool, id));
+ p += strlen(p);
+ id = rd->evr;
}
- strcpy(s1 + ls1, sr);
- pool->dep2strbuf[n] = s1 + ls1 + lsr;
- s2 = (char *)dep2str(pool, rd->evr);
- if (s2 != pool->dep2strbuf[n])
- strcpy(pool->dep2strbuf[n], s2);
- pool->dep2strbuf[n] = s1;
- if (rd->flags == REL_NAMESPACE)
- {
- s1[ls1 + ls2 + lsr - 1] = ')';
- s1[ls1 + ls2 + lsr] = 0;
- }
- pool->dep2strn = (n + 1) % DEP2STRBUF;
- return s1;
+ strcpy(p, pool->ss.stringspace + pool->ss.strings[id]);
}
-
+const char *
+dep2str(Pool *pool, Id id)
+{
+ char *p;
+ if (!ISRELDEP(id))
+ return pool->ss.stringspace + pool->ss.strings[id];
+ p = pool_alloctmpspace(pool, dep2strlen(pool, id));
+ dep2strcpy(pool, p, id);
+ return p;
+}
+
void
pool_shrink_strings(Pool *pool)
{