diff options
-rw-r--r-- | bindings/solv.i | 10 | ||||
-rw-r--r-- | ext/repo_content.c | 10 | ||||
-rw-r--r-- | ext/repo_deltainfoxml.c | 6 | ||||
-rw-r--r-- | ext/repo_helix.c | 2 | ||||
-rw-r--r-- | ext/repo_products.c | 6 | ||||
-rw-r--r-- | ext/repo_repomdxml.c | 2 | ||||
-rw-r--r-- | ext/repo_rpmdb.c | 4 | ||||
-rw-r--r-- | ext/repo_susetags.c | 6 | ||||
-rw-r--r-- | ext/repo_zyppdb.c | 2 | ||||
-rw-r--r-- | src/libsolv.ver | 3 | ||||
-rw-r--r-- | src/pool.c | 20 | ||||
-rw-r--r-- | src/pool.h | 7 | ||||
-rw-r--r-- | src/poolvendor.c | 2 | ||||
-rw-r--r-- | src/repo.c | 30 | ||||
-rw-r--r-- | src/repo.h | 2 | ||||
-rw-r--r-- | src/repodata.c | 2 | ||||
-rw-r--r-- | src/util.c | 12 | ||||
-rw-r--r-- | src/util.h | 1 |
18 files changed, 70 insertions, 57 deletions
diff --git a/bindings/solv.i b/bindings/solv.i index bf59ccb..a5b019a 100644 --- a/bindings/solv.i +++ b/bindings/solv.i @@ -1241,9 +1241,9 @@ typedef struct { const char *__str__() { char buf[20]; if ($self->name) - return strdup($self->name); + return solv_strdup($self->name); sprintf(buf, "Repo#%d", $self->repoid); - return strdup(buf); + return solv_strdup(buf); } %newobject __repr__; const char *__repr__() { @@ -1254,7 +1254,7 @@ typedef struct { return solv_dupjoin(buf, $self->name, ">"); } sprintf(buf, "<Repo #%d>", $self->repoid); - return strdup(buf); + return solv_strdup(buf); } } @@ -2141,7 +2141,7 @@ rb_eval_string( const char *__repr__() { char buf[20]; sprintf(buf, "<Rule #%d>", $self->id); - return strdup(buf); + return solv_strdup(buf); } } @@ -2248,7 +2248,7 @@ rb_eval_string( const char *__repr__() { char buf[20]; sprintf(buf, "<Repodata #%d>", $self->id); - return strdup(buf); + return solv_strdup(buf); } } diff --git a/ext/repo_content.c b/ext/repo_content.c index 53ed304..44acc4d 100644 --- a/ext/repo_content.c +++ b/ext/repo_content.c @@ -297,7 +297,7 @@ repo_add_content(Repo *repo, FILE *fp, int flags) repodata_set_str(data, SOLVID_META, SUSETAGS_DESCRDIR, value); if (s) repodata_set_str(data, s - pool->solvables, SUSETAGS_DESCRDIR, value); - descrdir = strdup(value); + descrdir = solv_strdup(value); continue; } if (istag ("DATADIR")) @@ -308,7 +308,7 @@ repo_add_content(Repo *repo, FILE *fp, int flags) repodata_set_str(data, SOLVID_META, SUSETAGS_DATADIR, value); if (s) repodata_set_str(data, s - pool->solvables, SUSETAGS_DATADIR, value); - datadir = strdup(value); + datadir = solv_strdup(value); continue; } if (istag ("VENDOR")) @@ -319,7 +319,7 @@ repo_add_content(Repo *repo, FILE *fp, int flags) repodata_set_poolstr(data, SOLVID_META, SUSETAGS_DEFAULTVENDOR, value); if (s) s->vendor = pool_str2id(pool, value, 1); - defvendor = strdup(value); + defvendor = solv_strdup(value); continue; } @@ -403,9 +403,9 @@ repo_add_content(Repo *repo, FILE *fp, int flags) } if (istag ("VERSION")) - pd.tmpvers = strdup(value); + pd.tmpvers = solv_strdup(value); else if (istag ("RELEASE")) - pd.tmprel = strdup(value); + pd.tmprel = solv_strdup(value); else if (code11 && istag ("DISTRIBUTION")) repodata_set_str(data, s - pool->solvables, SOLVABLE_DISTRIBUTION, value); else if (istag ("UPDATEURLS")) diff --git a/ext/repo_deltainfoxml.c b/ext/repo_deltainfoxml.c index 12efb3e..e810b60 100644 --- a/ext/repo_deltainfoxml.c +++ b/ext/repo_deltainfoxml.c @@ -226,7 +226,7 @@ static void parse_delta_location( struct parsedata *pd, name = alsa evr = 1.0.14-31_31.2 suffix = x86_64.delta.rpm. */ - char *real_str = strdup(str); + char *real_str = solv_strdup(str); char *s = real_str; char *s1, *s2; s1 = strrchr (s, '/'); @@ -481,7 +481,7 @@ endElement(void *userData, const char *name) parse_delta_location(pd, pd->content); break; case STATE_CHECKSUM: - pd->delta.filechecksum = strdup(pd->content); + pd->delta.filechecksum = solv_strdup(pd->content); break; case STATE_SIZE: pd->delta.downloadsize = atoi(pd->content); @@ -509,7 +509,7 @@ endElement(void *userData, const char *name) } } } - pd->delta.seqnum = strdup(str); + pd->delta.seqnum = solv_strdup(str); } default: break; diff --git a/ext/repo_helix.c b/ext/repo_helix.c index 17e718e..a75f693 100644 --- a/ext/repo_helix.c +++ b/ext/repo_helix.c @@ -629,7 +629,7 @@ endElement(void *userData, const char *name) const char *flavor = findKernelFlavor(pd, s); if (flavor) { - char *cflavor = strdup(flavor); /* make pointer safe */ + char *cflavor = solv_strdup(flavor); /* make pointer safe */ Id npr; Id pid; diff --git a/ext/repo_products.c b/ext/repo_products.c index 0f6048a..69edca3 100644 --- a/ext/repo_products.c +++ b/ext/repo_products.c @@ -145,7 +145,7 @@ find_attr(const char *txt, const char **atts, int dup) for (; *atts; atts += 2) { if (!strcmp(*atts, txt)) - return dup ? strdup(atts[1]) : atts[1]; + return dup ? solv_strdup(atts[1]) : atts[1]; } return 0; } @@ -308,10 +308,10 @@ endElement(void *userData, const char *name) s->name = pool_str2id(pd->pool, join2("product", ":", pd->content), 1); break; case STATE_VERSION: - pd->tmpvers = strdup(pd->content); + pd->tmpvers = solv_strdup(pd->content); break; case STATE_RELEASE: - pd->tmprel = strdup(pd->content); + pd->tmprel = solv_strdup(pd->content); break; case STATE_ARCH: s->arch = pool_str2id(pd->pool, pd->content, 1); diff --git a/ext/repo_repomdxml.c b/ext/repo_repomdxml.c index e856beb..87510dd 100644 --- a/ext/repo_repomdxml.c +++ b/ext/repo_repomdxml.c @@ -242,7 +242,7 @@ startElement(void *userData, const char *name, const char **atts) updstr = find_attr("updates", atts); if (updstr) { - char *value = strdup(updstr); + char *value = solv_strdup(updstr); char *fvalue = value; /* save the first */ while (value) { diff --git a/ext/repo_rpmdb.c b/ext/repo_rpmdb.c index 13b0b79..e6ca577 100644 --- a/ext/repo_rpmdb.c +++ b/ext/repo_rpmdb.c @@ -900,7 +900,7 @@ rpm2solv(Pool *pool, Repo *repo, Repodata *data, Solvable *s, RpmHead *rpmhead, { /* oh my, found SUSE special author section */ int l = aut - str; - str = strdup(str); + str = solv_strdup(str); aut = str + l; str[l] = 0; while (l > 0 && str[l - 1] == '\n') @@ -2167,7 +2167,7 @@ rpm_query(void *rpmhandle, Id what) break; case SOLVABLE_NAME: name = headstring(rpmhead, TAG_NAME); - r = strdup(name); + r = solv_strdup(name); break; case SOLVABLE_EVR: r = headtoevr(rpmhead); diff --git a/ext/repo_susetags.c b/ext/repo_susetags.c index 1b744a6..3f40be5 100644 --- a/ext/repo_susetags.c +++ b/ext/repo_susetags.c @@ -415,7 +415,7 @@ finish_solvable(struct parsedata *pd, Solvable *s, Id handle, Offset freshens) realloc the stringspace (and hence invalidate str). */ fname = sp + 1; if (strlen(fname) >= 128) - fname = strdup(fname); + fname = solv_strdup(fname); else { memcpy(fname_buf, fname, strlen(fname) + 1); @@ -423,7 +423,7 @@ finish_solvable(struct parsedata *pd, Solvable *s, Id handle, Offset freshens) } if (sp - str >= 128) { - char *sdup = strdup(str); + char *sdup = solv_strdup(str); sdup[sp - str] = 0; did = repodata_str2dir(pd->data, sdup, 1); free(sdup); @@ -1093,7 +1093,7 @@ repo_add_susetags(Repo *repo, FILE *fp, Id defvendor, const char *language, int set_checksum(&pd, data, handle, SOLVABLE_CHECKSUM, line + 6); break; case CTAG('=', 'L', 'a', 'n'): - language = strdup(line + 6); + language = solv_strdup(line + 6); break; case CTAG('=', 'F', 'l', 's'): diff --git a/ext/repo_zyppdb.c b/ext/repo_zyppdb.c index 84c2984..e31ecc7 100644 --- a/ext/repo_zyppdb.c +++ b/ext/repo_zyppdb.c @@ -105,7 +105,7 @@ find_attr(const char *txt, const char **atts, int dup) for (; *atts; atts += 2) { if (!strcmp(*atts, txt)) - return dup ? strdup(atts[1]) : atts[1]; + return dup ? solv_strdup(atts[1]) : atts[1]; } return 0; } diff --git a/src/libsolv.ver b/src/libsolv.ver index 5fa4af6..c6e399d 100644 --- a/src/libsolv.ver +++ b/src/libsolv.ver @@ -55,6 +55,7 @@ SOLV_1.0 { pool_evrcmp_str; pool_evrmatch; pool_free; + pool_freeallrepos; pool_freeidhashes; pool_freetmpspace; pool_freewhatprovides; @@ -119,7 +120,6 @@ SOLV_1.0 { repo_fix_conflicts; repo_fix_supplements; repo_free; - repo_freeallrepos; repo_free_solvable; repo_free_solvable_block; repo_internalize; @@ -214,6 +214,7 @@ SOLV_1.0 { solv_realloc; solv_realloc2; solv_sort; + solv_strdup; solv_timems; solv_vercmp; solv_version; @@ -86,7 +86,7 @@ pool_free(Pool *pool) pool_freewhatprovides(pool); pool_freeidhashes(pool); - repo_freeallrepos(pool, 1); + pool_freeallrepos(pool, 1); solv_free(pool->id2arch); solv_free(pool->solvables); stringpool_free(&pool->ss); @@ -102,6 +102,20 @@ pool_free(Pool *pool) solv_free(pool); } +void +pool_freeallrepos(Pool *pool, int reuseids) +{ + int i; + + pool_freewhatprovides(pool); + for (i = 0; i < pool->nrepos; i++) + repo_freedata(pool->repos[i]); + pool->repos = solv_free(pool->repos); + pool->nrepos = 0; + /* the first two solvables don't belong to a repo */ + pool_free_solvable_block(pool, 2, pool->nsolvables - 2, reuseids); +} + #ifdef MULTI_SEMANTICS void pool_setdisttype(Pool *pool, int disttype) @@ -883,7 +897,7 @@ pool_addfileprovides_dep(Pool *pool, Id *ida, struct searchfiles *sf, struct sea csf->names = solv_extend(csf->names, csf->nfiles, 1, sizeof(const char *), SEARCHFILES_BLOCK); csf->ids[csf->nfiles] = dep; sr = strrchr(s, '/'); - csf->names[csf->nfiles] = strdup(sr + 1); + csf->names[csf->nfiles] = solv_strdup(sr + 1); csf->dirs[csf->nfiles] = solv_malloc(sr - s + 1); if (sr != s) strncpy(csf->dirs[csf->nfiles], s, sr - s); @@ -1201,7 +1215,7 @@ pool_set_languages(Pool *pool, const char **languages, int nlanguages) return; pool->languages = solv_calloc(nlanguages, sizeof(const char **)); for (i = 0; i < pool->nlanguages; i++) - pool->languages[i] = strdup(languages[i]); + pool->languages[i] = solv_strdup(languages[i]); } Id @@ -181,14 +181,9 @@ struct _Pool { # define __attribute__(x) #endif -/** - * Creates a new pool - */ extern Pool *pool_create(void); -/** - * Delete a pool - */ extern void pool_free(Pool *pool); +extern void pool_freeallrepos(Pool *pool, int reuseids); extern void pool_setdebuglevel(Pool *pool, int level); #ifdef MULTI_SEMANTICS diff --git a/src/poolvendor.c b/src/poolvendor.c index f621f50..2bf00f8 100644 --- a/src/poolvendor.c +++ b/src/poolvendor.c @@ -97,7 +97,7 @@ pool_setvendorclasses(Pool *pool, const char **vendorclasses) ; pool->vendorclasses = solv_calloc(v - vendorclasses + 2, sizeof(const char *)); for (v = vendorclasses, i = 0; v[0] || v[1]; v++, i++) - pool->vendorclasses[i] = *v ? strdup(*v) : 0; + pool->vendorclasses[i] = *v ? solv_strdup(*v) : 0; pool->vendorclasses[i++] = 0; pool->vendorclasses[i] = 0; queue_empty(&pool->vendormap); @@ -45,7 +45,7 @@ repo_create(Pool *pool, const char *name) pool->repos = (Repo **)solv_realloc2(pool->repos, pool->nrepos + 1, sizeof(Repo *)); pool->repos[pool->nrepos++] = repo; repo->repoid = pool->nrepos; - repo->name = name ? strdup(name) : 0; + repo->name = name ? solv_strdup(name) : 0; repo->pool = pool; repo->start = pool->nsolvables; repo->end = pool->nsolvables; @@ -53,7 +53,7 @@ repo_create(Pool *pool, const char *name) return repo; } -static void +void repo_freedata(Repo *repo) { int i; @@ -134,21 +134,8 @@ repo_free(Repo *repo, int reuseids) repo_freedata(repo); } -void -repo_freeallrepos(Pool *pool, int reuseids) -{ - int i; - - pool_freewhatprovides(pool); - for (i = 0; i < pool->nrepos; i++) - repo_freedata(pool->repos[i]); - pool->repos = solv_free(pool->repos); - pool->nrepos = 0; - /* the first two solvables don't belong to a repo */ - pool_free_solvable_block(pool, 2, pool->nsolvables - 2, reuseids); -} - -Id repo_add_solvable(Repo *repo) +Id +repo_add_solvable(Repo *repo) { Id p = pool_add_solvable(repo->pool); if (!repo->start || repo->start == repo->end) @@ -165,7 +152,8 @@ Id repo_add_solvable(Repo *repo) return p; } -Id repo_add_solvable_block(Repo *repo, int count) +Id +repo_add_solvable_block(Repo *repo, int count) { Id p; Solvable *s; @@ -187,12 +175,14 @@ Id repo_add_solvable_block(Repo *repo, int count) return p; } -void repo_free_solvable(Repo *repo, Id p, int reuseids) +void +repo_free_solvable(Repo *repo, Id p, int reuseids) { repo_free_solvable_block(repo, p, 1, reuseids); } -void repo_free_solvable_block(Repo *repo, Id start, int count, int reuseids) +void +repo_free_solvable_block(Repo *repo, Id start, int count, int reuseids) { Solvable *s; Repodata *data; @@ -55,7 +55,7 @@ typedef struct _Repo { extern Repo *repo_create(Pool *pool, const char *name); extern void repo_free(Repo *repo, int reuseids); extern void repo_empty(Repo *repo, int reuseids); -extern void repo_freeallrepos(Pool *pool, int reuseids); +extern void repo_freedata(Repo *repo); extern Id repo_add_solvable(Repo *repo); extern Id repo_add_solvable_block(Repo *repo, int count); extern void repo_free_solvable(Repo *repo, Id p, int reuseids); diff --git a/src/repodata.c b/src/repodata.c index d3b00f6..802730d 100644 --- a/src/repodata.c +++ b/src/repodata.c @@ -2182,7 +2182,7 @@ repodata_set_location(Repodata *data, Id solvid, int medianr, const char *dir, c repodata_set_str(data, solvid, SOLVABLE_MEDIADIR, dir); else { - char *dir2 = strdup(dir); + char *dir2 = solv_strdup(dir); dir2[l] = 0; repodata_set_str(data, solvid, SOLVABLE_MEDIADIR, dir2); free(dir2); @@ -84,6 +84,18 @@ solv_free(void *mem) return 0; } +char * +solv_strdup(const char *s) +{ + char *r; + if (!s) + return 0; + r = strdup(s); + if (!r) + solv_oom(0, strlen(s)); + return r; +} + unsigned int solv_timems(unsigned int subtract) { @@ -26,6 +26,7 @@ extern void *solv_calloc(size_t, size_t); extern void *solv_realloc(void *, size_t); extern void *solv_realloc2(void *, size_t, size_t); extern void *solv_free(void *); +extern char *solv_strdup(const char *); extern void solv_oom(size_t, size_t); extern unsigned int solv_timems(unsigned int subtract); extern void solv_sort(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *, void *), void *compard); |