-#if 0
-static void
+static inline void
write_str(FILE *fp, const char *str)
{
- if (fputs (str, fp) == EOF || putc (0, fp) == EOF)
+ if (fputs(str, fp) == EOF || putc(0, fp) == EOF)
{
- perror("write error");
+ perror("write error str");
exit(1);
}
}
-#endif
/*
* Array of Ids
}
static int
-cmp_ids (const void *pa, const void *pb, void *dp)
+cmp_ids(const void *pa, const void *pb, void *dp)
{
Id a = *(Id *)pa;
Id b = *(Id *)pb;
if (sids[i] == marker)
break;
if (i > 1)
- sat_sort(sids, i, sizeof (Id), cmp_ids, 0);
+ sat_sort(sids, i, sizeof(Id), cmp_ids, 0);
if ((len - i) > 2)
sat_sort(sids + i + 1, len - i - 1, sizeof(Id), cmp_ids, 0);
if (sids[i] == marker)
break;
if (i > 1)
- sat_sort(sids, i, sizeof (Id), cmp_ids, 0);
+ sat_sort(sids, i, sizeof(Id), cmp_ids, 0);
if ((len - i) > 2)
sat_sort(sids + i + 1, len - i - 1, sizeof(Id), cmp_ids, 0);
solv_flags |= SOLV_FLAG_PREFIX_POOL;
write_u32(fp, solv_flags);
+ /*
+ * calculate prefix encoding of the strings
+ */
+ unsigned char *prefixcomp = sat_malloc(nstrings);
+ unsigned int compsum = 0;
+ char *old_str = "";
+
+ prefixcomp[0] = 0;
+ for (i = 1; i < nstrings; i++)
+ {
+ char *str = spool->stringspace + spool->strings[needid[i].map];
+ int same;
+ for (same = 0; same < 255; same++)
+ if (!old_str[same] || old_str[same] != str[same])
+ break;
+ prefixcomp[i] = same;
+ compsum += same;
+ old_str = str;
+ }
+
+ /*
+ * write strings
+ */
+ write_u32(fp, sizeid);
+ /* we save compsum bytes but need 1 extra byte for every string */
+ write_u32(fp, sizeid + (nstrings ? nstrings - 1 : 0) - compsum);
+ if (sizeid + (nstrings ? nstrings - 1 : 0) != compsum)
+ {
+ for (i = 1; i < nstrings; i++)
+ {
+ char *str = spool->stringspace + spool->strings[needid[i].map];
+ write_u8(fp, prefixcomp[i]);
+ write_str(fp, str + prefixcomp[i]);
+ }
+ }
+ sat_free(prefixcomp);
+
+#if 0
/* Build the prefix-encoding of the string pool. We need to know
the size of that before writing it to the file, so we have to
build a separate buffer for that. As it's temporarily possible
break;
*pp++ = same;
len = strlen(str + same) + 1;
- memcpy (pp, str + same, len);
+ memcpy(pp, str + same, len);
pp += len;
old_str = str;
}
}
}
sat_free(prefix);
+#endif
/*
* write RelDeps
static int
keyfilter_language(Repo *repo, Repokey *key, void *kfdata)
{
+ Pool *pool = repo->pool;
const char *name, *p;
- char *lang = kfdata, *bname;
+ char *lang = kfdata;
int i;
- Id id;
name = id2str(repo->pool, key->name);
p = strrchr(name, ':');
if (!p || strcmp(p + 1, lang) != 0)
return KEY_STORAGE_DROPPED;
- /* find base name id */
- bname = strdup(name);
- bname[p - name] = 0;
- id = str2id(repo->pool, bname, 1);
for (i = 0; verticals[i]; i++)
- if (id == verticals[i])
- return KEY_STORAGE_VERTICAL_OFFSET;
+ {
+ const char *vname = id2str(pool, verticals[i]);
+ if (!strncmp(name, vname, p - name) && vname[p - name] == 0)
+ return KEY_STORAGE_VERTICAL_OFFSET;
+ }
return KEY_STORAGE_INCORE;
}
}
sat_free(addedfileprovides);
+ pool_freeidhashes(repo->pool); /* free some mem */
+
if (basename)
{
char fn[4096];
free(languages[i]);
sat_free(languages);
repodata_free(info);
- repo->nrepodata--;
return 0;
}
if (attrname)
repodata_internalize(info);
repo_write(repo, stdout, keyfilter_solv, &kd, 0);
repodata_free(info);
- repo->nrepodata--;
return 0;
}