diff options
author | Michael Schroeder <mls@suse.de> | 2008-01-09 11:55:50 +0000 |
---|---|---|
committer | Michael Schroeder <mls@suse.de> | 2008-01-09 11:55:50 +0000 |
commit | d9c1b4ab713720b5cd6d30716fed01c80f636b10 (patch) | |
tree | bb59b5e146f76445e20460cf69f07831c87ac100 | |
parent | 824a9d3ea9f94257a0bb7577f395691231d81a0e (diff) | |
download | libsolv-d9c1b4ab713720b5cd6d30716fed01c80f636b10.tar.gz libsolv-d9c1b4ab713720b5cd6d30716fed01c80f636b10.tar.bz2 libsolv-d9c1b4ab713720b5cd6d30716fed01c80f636b10.zip |
- rename xmalloc/... functions to sat_malloc, as we're a
library and mustn't conflict with other libraries
-rw-r--r-- | src/attr_store.c | 98 | ||||
-rw-r--r-- | src/bitmap.c | 6 | ||||
-rw-r--r-- | src/pool.c | 52 | ||||
-rw-r--r-- | src/poolarch.c | 6 | ||||
-rw-r--r-- | src/poolid.c | 20 | ||||
-rw-r--r-- | src/queue.c | 8 | ||||
-rw-r--r-- | src/repo.c | 34 | ||||
-rw-r--r-- | src/repo_solv.c | 72 | ||||
-rw-r--r-- | src/solver.c | 38 | ||||
-rw-r--r-- | src/strpool.c | 16 | ||||
-rw-r--r-- | src/util.c | 16 | ||||
-rw-r--r-- | src/util.h | 12 | ||||
-rw-r--r-- | tools/repo_content.c | 13 | ||||
-rw-r--r-- | tools/repo_rpmdb.c | 70 | ||||
-rw-r--r-- | tools/repo_rpmmd.c | 10 | ||||
-rw-r--r-- | tools/repo_write.c | 16 |
16 files changed, 242 insertions, 245 deletions
diff --git a/src/attr_store.c b/src/attr_store.c index 1ac16c0..a9fc2d6 100644 --- a/src/attr_store.c +++ b/src/attr_store.c @@ -49,7 +49,7 @@ new_store (Pool *pool) "", 0 }; - Attrstore *s = calloc (1, sizeof (Attrstore)); + Attrstore *s = sat_calloc (1, sizeof (Attrstore)); s->pool = pool; stringpool_init (&s->ss, predef_strings); add_key (s, 0, 0, 0); @@ -79,7 +79,7 @@ setup_dirs (Attrstore *s) 0 }; - s->dirtree.dirs = calloc (1024, sizeof (s->dirtree.dirs[0])); + s->dirtree.dirs = sat_calloc (1024, sizeof (s->dirtree.dirs[0])); s->dirtree.ndirs = 2; s->dirtree.dirs[0].child = 0; s->dirtree.dirs[0].sibling = 0; @@ -89,7 +89,7 @@ setup_dirs (Attrstore *s) s->dirtree.dirs[1].name = STRID_EMPTY; s->dirtree.dirstack_size = 16; - s->dirtree.dirstack = malloc (s->dirtree.dirstack_size * sizeof (s->dirtree.dirstack[0])); + s->dirtree.dirstack = sat_malloc (s->dirtree.dirstack_size * sizeof (s->dirtree.dirstack[0])); s->dirtree.ndirstack = 0; s->dirtree.dirstack[s->dirtree.ndirstack++] = 1; //dir-id of / @@ -104,7 +104,7 @@ dir_setup_flatsons (Dirtree *d) return; if (!d->nflatdirs) return; - d->flatsons = xcalloc (d->nflatdirs, sizeof (d->flatsons[0])); + d->flatsons = sat_calloc (d->nflatdirs, sizeof (d->flatsons[0])); unsigned firstson = -1; unsigned i; for (i = 0; i < d->nflatdirs; i++) @@ -148,7 +148,7 @@ dir_lookup_1 (Attrstore *s, unsigned dir, const char *name, unsigned insert) { c = s->dirtree.ndirs++; if (!(c & 1023)) - dirs = realloc (dirs, (c + 1024) * sizeof (dirs[0])); + dirs = sat_realloc (dirs, (c + 1024) * sizeof (dirs[0])); dirs[c].child = 0; dirs[c].sibling = dirs[dir].child; dirs[c].name = nameid; @@ -159,7 +159,7 @@ dir_lookup_1 (Attrstore *s, unsigned dir, const char *name, unsigned insert) if (!(s->dirtree.ndirstack & 15)) { s->dirtree.dirstack_size += 16; - s->dirtree.dirstack = realloc (s->dirtree.dirstack, s->dirtree.dirstack_size * sizeof (s->dirtree.dirstack[0])); + s->dirtree.dirstack = sat_realloc (s->dirtree.dirstack, s->dirtree.dirstack_size * sizeof (s->dirtree.dirstack[0])); } s->dirtree.dirstack[s->dirtree.ndirstack++] = c; if (!*end) @@ -250,7 +250,7 @@ dir2str (Attrstore *s, unsigned dir, char **str, unsigned *len) l++; if (l > *len) { - *str = malloc (l); + *str = sat_malloc (l); *len = l; } char *dest = *str; @@ -274,9 +274,9 @@ ensure_entry (Attrstore *s, unsigned int entry) if (((old_num + 127) & ~127) != ((s->entries + 127) & ~127)) { if (s->attrs) - s->attrs = realloc (s->attrs, (((s->entries+127) & ~127) * sizeof (s->attrs[0]))); + s->attrs = sat_realloc (s->attrs, (((s->entries+127) & ~127) * sizeof (s->attrs[0]))); else - s->attrs = malloc (((s->entries+127) & ~127) * sizeof (s->attrs[0])); + s->attrs = sat_malloc (((s->entries+127) & ~127) * sizeof (s->attrs[0])); } memset (s->attrs + old_num, 0, (s->entries - old_num) * sizeof (s->attrs[0])); } @@ -287,9 +287,9 @@ new_entry (Attrstore *s) if ((s->entries & 127) == 0) { if (s->attrs) - s->attrs = realloc (s->attrs, ((s->entries+128) * sizeof (s->attrs[0]))); + s->attrs = sat_realloc (s->attrs, ((s->entries+128) * sizeof (s->attrs[0]))); else - s->attrs = malloc ((s->entries+128) * sizeof (s->attrs[0])); + s->attrs = sat_malloc ((s->entries+128) * sizeof (s->attrs[0])); } s->attrs[s->entries++] = 0; return s->entries - 1; @@ -332,9 +332,9 @@ add_attr (Attrstore *s, unsigned int entry, LongNV attr) } len += 2; if (s->attrs[entry]) - s->attrs[entry] = realloc (s->attrs[entry], len * sizeof (LongNV)); + s->attrs[entry] = sat_realloc (s->attrs[entry], len * sizeof (LongNV)); else - s->attrs[entry] = malloc (len * sizeof (LongNV)); + s->attrs[entry] = sat_malloc (len * sizeof (LongNV)); nv = s->attrs[entry] + len - 2; *nv++ = attr; nv->key = 0; @@ -379,7 +379,7 @@ add_attr_blob (Attrstore *s, unsigned int entry, Id name, const void *ptr, unsig != ((s->blob_next_free + len + BLOB_BLOCK) & ~BLOB_BLOCK)) { unsigned int blobsz = (s->blob_next_free + len + BLOB_BLOCK) &~BLOB_BLOCK; - s->blob_store = xrealloc (s->blob_store, blobsz); + s->blob_store = sat_realloc (s->blob_store, blobsz); } memcpy (s->blob_store + s->blob_next_free, ptr, len); add_attr_chunk (s, entry, name, s->blob_next_free, len); @@ -389,7 +389,7 @@ add_attr_blob (Attrstore *s, unsigned int entry, Id name, const void *ptr, unsig if (npages != s->num_pages) { Attrblobpage *p; - s->pages = xrealloc (s->pages, npages * sizeof (s->pages[0])); + s->pages = sat_realloc (s->pages, npages * sizeof (s->pages[0])); for (p = s->pages + s->num_pages; s->num_pages < npages; p++, s->num_pages++) { @@ -416,14 +416,14 @@ add_attr_intlist_int (Attrstore *s, unsigned int entry, Id name, int val) if (nv) { unsigned len = nv->v.intlist[0]++; - nv->v.intlist = realloc (nv->v.intlist, (len + 2) * sizeof (nv->v.intlist[0])); + nv->v.intlist = sat_realloc (nv->v.intlist, (len + 2) * sizeof (nv->v.intlist[0])); nv->v.intlist[len+1] = val; } else { LongNV mynv; mynv.key = add_key (s, name, TYPE_ATTR_INTLIST, 0); - mynv.v.intlist = malloc (2 * sizeof (mynv.v.intlist[0])); + mynv.v.intlist = sat_malloc (2 * sizeof (mynv.v.intlist[0])); mynv.v.intlist[0] = 1; mynv.v.intlist[1] = val; add_attr (s, entry, mynv); @@ -439,7 +439,7 @@ add_attr_localids_id (Attrstore *s, unsigned int entry, Id name, LocalId id) unsigned len = 0; while (nv->v.localids[len]) len++; - nv->v.localids = realloc (nv->v.localids, (len + 2) * sizeof (nv->v.localids[0])); + nv->v.localids = sat_realloc (nv->v.localids, (len + 2) * sizeof (nv->v.localids[0])); nv->v.localids[len] = id; nv->v.localids[len+1] = 0; } @@ -447,7 +447,7 @@ add_attr_localids_id (Attrstore *s, unsigned int entry, Id name, LocalId id) { LongNV mynv; mynv.key = add_key (s, name, TYPE_ATTR_LOCALIDS, 0); - mynv.v.localids = malloc (2 * sizeof (mynv.v.localids[0])); + mynv.v.localids = sat_malloc (2 * sizeof (mynv.v.localids[0])); mynv.v.localids[0] = id; mynv.v.localids[1] = 0; add_attr (s, entry, mynv); @@ -547,18 +547,18 @@ add_attr_from_file (Attrstore *s, unsigned entry, Id name, int type, Id *idmap, len += 256; if (buf == localbuf) { - buf = xmalloc (len); + buf = sat_malloc (len); memcpy (buf, localbuf, len - 256); } else - buf = xrealloc (buf, len); + buf = sat_realloc (buf, len); } buf[ofs++] = c; } buf[ofs++] = 0; add_attr_string (s, entry, name, (char*) buf); if (buf != localbuf) - xfree (buf); + sat_free (buf); } break; case TYPE_ATTR_INTLIST: @@ -617,9 +617,9 @@ load_page_range (Attrstore *s, unsigned int pstart, unsigned int pend) s->ncanmap = pend - pstart + 1; if (s->ncanmap < 4) s->ncanmap = 4; - s->mapped = xrealloc (s->mapped, s->ncanmap * sizeof (s->mapped[0])); + s->mapped = sat_realloc (s->mapped, s->ncanmap * sizeof (s->mapped[0])); memset (s->mapped + oldcan, 0, (s->ncanmap - oldcan) * sizeof (s->mapped[0])); - s->blob_store = xrealloc (s->blob_store, s->ncanmap * BLOB_PAGESIZE); + s->blob_store = sat_realloc (s->blob_store, s->ncanmap * BLOB_PAGESIZE); #ifdef DEBUG_PAGING fprintf (stderr, "PAGE: can map %d pages\n", s->ncanmap); #endif @@ -780,7 +780,7 @@ attr_retrieve_blob (Attrstore *s, unsigned int ofs, unsigned int len) #define add_elem(buf,ofs,val,block) do { \ if (((ofs) & (block)) == 0) \ - buf = xrealloc (buf, ((ofs) + (block) + 1) * sizeof((buf)[0])); \ + buf = sat_realloc (buf, ((ofs) + (block) + 1) * sizeof((buf)[0])); \ (buf)[(ofs)++] = val; \ } while (0) #define add_u16(buf,ofs,val,block) do {\ @@ -824,7 +824,7 @@ add_key (Attrstore *s, Id name, unsigned type, unsigned size) return i; } if ((s->nkeys & KEY_BLOCK) == 0) - s->keys = xrealloc (s->keys, (s->nkeys + KEY_BLOCK + 1) * sizeof (s->keys[0])); + s->keys = sat_realloc (s->keys, (s->nkeys + KEY_BLOCK + 1) * sizeof (s->keys[0])); s->keys[i].name = name; s->keys[i].type = type; s->keys[i].size = size; @@ -862,13 +862,13 @@ finalize_dirtree (Dirtree *d) { if (d->nflatdirs || !d->ndirs) return; - d->dirmap = calloc (d->ndirs, sizeof (d->dirmap[0])); + d->dirmap = sat_calloc (d->ndirs, sizeof (d->dirmap[0])); d->nflatdirs = 0; d->flatdirs = 0; d->flatsons = 0; d->dirmap[1] = d->nflatdirs + 1; finalize_dirs_rec (d, 1); - xfree (d->dirs); + sat_free (d->dirs); d->dirs = 0; } @@ -881,7 +881,7 @@ attr_store_pack (Attrstore *s) return; finalize_dirtree (&s->dirtree); - s->ent2attr = xcalloc (s->entries, sizeof (s->ent2attr[0])); + s->ent2attr = sat_calloc (s->entries, sizeof (s->ent2attr[0])); s->flat_attrs = 0; s->attr_next_free = 0; s->nschemata = 0; @@ -960,7 +960,7 @@ attr_store_pack (Attrstore *s) add_elem (s->flat_attrs, s->attr_next_free, *str, FLAT_ATTR_BLOCK); add_elem (s->flat_attrs, s->attr_next_free, 0, FLAT_ATTR_BLOCK); old_mem += strlen ((const char*)nv[ofs].v.str) + 1; - xfree ((void*)nv[ofs].v.str); + sat_free ((void*)nv[ofs].v.str); break; } case TYPE_ATTR_INTLIST: @@ -985,7 +985,7 @@ attr_store_pack (Attrstore *s) i |= 64; add_num (s->flat_attrs, s->attr_next_free, i, FLAT_ATTR_BLOCK); } - xfree (nv[ofs].v.intlist); + sat_free (nv[ofs].v.intlist); break; } case TYPE_ATTR_LOCALIDS: @@ -996,18 +996,18 @@ attr_store_pack (Attrstore *s) add_num (s->flat_attrs, s->attr_next_free, i, FLAT_ATTR_BLOCK); add_num (s->flat_attrs, s->attr_next_free, 0, FLAT_ATTR_BLOCK); old_mem += 4; - xfree (nv[ofs].v.localids); + sat_free (nv[ofs].v.localids); break; } default: break; } - xfree (nv); + sat_free (nv); } old_mem += s->entries * sizeof (s->attrs[0]); free (s->attrs); s->attrs = 0; - xfree (s->dirtree.dirmap); + sat_free (s->dirtree.dirmap); s->dirtree.dirmap = 0; /* Remove the hashtable too, it will be build on demand in str2localid @@ -1048,7 +1048,7 @@ attr_store_unpack (Attrstore *s) /* Make the store writable right away, so we can use our adder functions. */ s->packed = 0; - s->attrs = xcalloc (s->entries, sizeof (s->attrs[0])); + s->attrs = sat_calloc (s->entries, sizeof (s->attrs[0])); for (i = 0; i < s->entries; i++) { @@ -1102,15 +1102,15 @@ attr_store_unpack (Attrstore *s) } } - xfree (s->ent2attr); + sat_free (s->ent2attr); s->ent2attr = 0; - xfree (s->flat_attrs); + sat_free (s->flat_attrs); s->flat_attrs = 0; s->attr_next_free = 0; - xfree (s->schemaofs); + sat_free (s->schemaofs); s->schemaofs = 0; s->nschemata = 0; - xfree (s->schemata); + sat_free (s->schemata); s->schemata = 0; s->szschemata = 0; /* XXX unpack the dirtree */ @@ -1516,13 +1516,13 @@ read_or_setup_pages (FILE *fp, Attrstore *s) npages = (blobsz + BLOB_PAGESIZE - 1) / BLOB_PAGESIZE; s->num_pages = npages; - s->pages = xmalloc (npages * sizeof (s->pages[0])); + s->pages = sat_malloc (npages * sizeof (s->pages[0])); /* If we can't seek on our input we have to slurp in everything. */ if (!can_seek) { s->blob_next_free = blobsz; - s->blob_store = xrealloc (s->blob_store, (s->blob_next_free + BLOB_BLOCK) &~BLOB_BLOCK); + s->blob_store = sat_realloc (s->blob_store, (s->blob_next_free + BLOB_BLOCK) &~BLOB_BLOCK); } for (i = 0; i < npages; i++) { @@ -1614,8 +1614,8 @@ read_stringpool (FILE *fp, Stringpool *ss, unsigned nstrings) out to be compatible with the SOLV file and to not have to introduce merging and mapping the string IDs. */ local_ssize = read_u32 (fp) - 1; - char *strsp = (char *)xrealloc(ss->stringspace, ss->sstrings + local_ssize + 1); - Offset *str = (Offset *)xrealloc(ss->strings, nstrings * sizeof(Offset)); + char *strsp = (char *)sat_realloc(ss->stringspace, ss->sstrings + local_ssize + 1); + Offset *str = (Offset *)sat_realloc(ss->strings, nstrings * sizeof(Offset)); ss->stringspace = strsp; ss->strings = str; @@ -1682,7 +1682,7 @@ attr_store_read (FILE *fp, Pool *pool) read_stringpool (fp, &s->ss, nstrings); - s->keys = xrealloc (s->keys, ((s->nkeys + KEY_BLOCK) & ~KEY_BLOCK) * sizeof (s->keys[0])); + s->keys = sat_realloc (s->keys, ((s->nkeys + KEY_BLOCK) & ~KEY_BLOCK) * sizeof (s->keys[0])); /* s->keys[0] is initialized in new_store. */ for (i = 1; i < s->nkeys; i++) { @@ -1696,7 +1696,7 @@ attr_store_read (FILE *fp, Pool *pool) s->szschemata = read_id (fp, 0); s->nschemata = 0; - s->schemata = xmalloc (((s->szschemata + SCHEMA_BLOCK) & ~SCHEMA_BLOCK) * sizeof (s->schemata[0])); + s->schemata = sat_malloc (((s->szschemata + SCHEMA_BLOCK) & ~SCHEMA_BLOCK) * sizeof (s->schemata[0])); s->schemaofs = 0; Id *ids = s->schemata; //add_elem (s->schemaofs, s->nschemata, 0, SCHEMA_BLOCK); @@ -1711,7 +1711,7 @@ attr_store_read (FILE *fp, Pool *pool) s->entries = nentries; - s->ent2attr = xmalloc (s->entries * sizeof (s->ent2attr[0])); + s->ent2attr = sat_malloc (s->entries * sizeof (s->ent2attr[0])); int start = 1; for (i = 0; i < s->entries; i++) { @@ -1723,7 +1723,7 @@ attr_store_read (FILE *fp, Pool *pool) } s->attr_next_free = start; - s->flat_attrs = xmalloc (((s->attr_next_free + FLAT_ATTR_BLOCK) & ~FLAT_ATTR_BLOCK) * sizeof (s->flat_attrs[0])); + s->flat_attrs = sat_malloc (((s->attr_next_free + FLAT_ATTR_BLOCK) & ~FLAT_ATTR_BLOCK) * sizeof (s->flat_attrs[0])); s->flat_attrs[0] = 0; if (s->entries && fread (s->flat_attrs + 1, s->attr_next_free - 1, 1, fp) != 1) { @@ -1736,14 +1736,14 @@ attr_store_read (FILE *fp, Pool *pool) { unsigned ndirs = s->dirtree.ndirs; setup_dirs (s); - xfree (s->dirtree.dirs); + sat_free (s->dirtree.dirs); s->dirtree.dirs = 0; s->dirtree.ndirs = ndirs; nstrings = read_u32 (fp); read_stringpool (fp, &s->dirtree.ss, nstrings); s->dirtree.nflatdirs = read_id (fp, 0); - s->dirtree.flatdirs = xmalloc (s->dirtree.nflatdirs * sizeof (s->dirtree.flatdirs[0])); + s->dirtree.flatdirs = sat_malloc (s->dirtree.nflatdirs * sizeof (s->dirtree.flatdirs[0])); for (i = 0; i < s->dirtree.nflatdirs; i++) s->dirtree.flatdirs[i] = read_id (fp, 0); } diff --git a/src/bitmap.c b/src/bitmap.c index 1f8a74d..f7ee3dd 100644 --- a/src/bitmap.c +++ b/src/bitmap.c @@ -20,14 +20,14 @@ void map_init(Map *m, int n) { m->size = (n + 7) >> 3; - m->map = xcalloc(m->size, 1); + m->map = sat_calloc(m->size, 1); } // free space allocated void map_free(Map *m) { - m->map = xfree(m->map); + m->map = sat_free(m->map); m->size = 0; } @@ -36,7 +36,7 @@ void map_clone(Map *t, Map *s) { t->size = s->size; - t->map = xmalloc(s->size); + t->map = sat_malloc(s->size); memcpy(t->map, s->map, t->size); } @@ -71,16 +71,16 @@ pool_create(void) Pool *pool; Solvable *s; - pool = (Pool *)xcalloc(1, sizeof(*pool)); + pool = (Pool *)sat_calloc(1, sizeof(*pool)); stringpool_init (&pool->ss, initpool_data); // pre-alloc space for a RelDep - pool->rels = (Reldep *)xcalloc(1 + REL_BLOCK, sizeof(Reldep)); + pool->rels = (Reldep *)sat_calloc(1 + REL_BLOCK, sizeof(Reldep)); pool->nrels = 1; // pre-alloc space for a Solvable - pool->solvables = (Solvable *)xcalloc(SOLVABLE_BLOCK + 1, sizeof(Solvable)); + pool->solvables = (Solvable *)sat_calloc(SOLVABLE_BLOCK + 1, sizeof(Solvable)); pool->nsolvables = 2; queue_init(&pool->vendormap); s = pool->solvables + SYSTEMSOLVABLE; @@ -102,22 +102,22 @@ pool_free(Pool *pool) pool_freewhatprovides(pool); pool_freeidhashes(pool); repo_freeallrepos(pool, 1); - xfree(pool->id2arch); - xfree(pool->solvables); - xfree(pool->ss.stringspace); - xfree(pool->ss.strings); - xfree(pool->rels); + sat_free(pool->id2arch); + sat_free(pool->solvables); + sat_free(pool->ss.stringspace); + sat_free(pool->ss.strings); + sat_free(pool->rels); queue_free(&pool->vendormap); for (i = 0; i < DEP2STRBUF; i++) - xfree(pool->dep2strbuf[i]); - xfree(pool); + sat_free(pool->dep2strbuf[i]); + sat_free(pool); } Id pool_add_solvable(Pool *pool) { if ((pool->nsolvables & SOLVABLE_BLOCK) == 0) - pool->solvables = xrealloc2(pool->solvables, pool->nsolvables + (SOLVABLE_BLOCK + 1), sizeof(Solvable)); + pool->solvables = sat_realloc2(pool->solvables, pool->nsolvables + (SOLVABLE_BLOCK + 1), sizeof(Solvable)); memset(pool->solvables + pool->nsolvables, 0, sizeof(Solvable)); return pool->nsolvables++; } @@ -129,7 +129,7 @@ pool_add_solvable_block(Pool *pool, int count) if (!count) return nsolvables; if (((nsolvables - 1) | SOLVABLE_BLOCK) != ((nsolvables + count - 1) | SOLVABLE_BLOCK)) - pool->solvables = xrealloc2(pool->solvables, (nsolvables + count + SOLVABLE_BLOCK) & ~SOLVABLE_BLOCK, sizeof(Solvable)); + pool->solvables = sat_realloc2(pool->solvables, (nsolvables + count + SOLVABLE_BLOCK) & ~SOLVABLE_BLOCK, sizeof(Solvable)); memset(pool->solvables + nsolvables, 0, sizeof(Solvable) * count); pool->nsolvables += count; return nsolvables; @@ -161,7 +161,7 @@ solvable2str(Pool *pool, Solvable *s) l = strlen(n) + strlen(e) + strlen(a) + 3; if (l > pool->dep2strlen[nn]) { - pool->dep2strbuf[nn] = xrealloc(pool->dep2strbuf[nn], l + 32); + pool->dep2strbuf[nn] = sat_realloc(pool->dep2strbuf[nn], l + 32); pool->dep2strlen[nn] = l + 32; } sprintf(pool->dep2strbuf[nn], "%s-%s.%s", n, e, a); @@ -212,7 +212,7 @@ pool_shrink_whatprovides(Pool *pool) if (pool->ss.nstrings < 3) return; - sorted = xmalloc2(pool->ss.nstrings, sizeof(Id)); + sorted = sat_malloc2(pool->ss.nstrings, sizeof(Id)); for (id = 0; id < pool->ss.nstrings; id++) sorted[id] = id; pool_shrink_whatprovides_sortcmp_data = pool; @@ -246,7 +246,7 @@ pool_shrink_whatprovides(Pool *pool) last = pool->whatprovidesdata + o; lastid = id; } - xfree(sorted); + sat_free(sorted); dp = pool->whatprovidesdata + 2; for (id = 1; id < pool->ss.nstrings; id++) { @@ -274,7 +274,7 @@ pool_shrink_whatprovides(Pool *pool) return; r = pool->whatprovidesdataoff - o; pool->whatprovidesdataoff = o; - pool->whatprovidesdata = xrealloc(pool->whatprovidesdata, (o + pool->whatprovidesdataleft) * sizeof(Id)); + pool->whatprovidesdata = sat_realloc(pool->whatprovidesdata, (o + pool->whatprovidesdataleft) * sizeof(Id)); if (r > pool->whatprovidesdataleft) r = pool->whatprovidesdataleft; memset(pool->whatprovidesdata + o, 0, r * sizeof(Id)); @@ -304,8 +304,8 @@ pool_createwhatprovides(Pool *pool) pool_freeidhashes(pool); /* XXX: should not be here! */ pool_freewhatprovides(pool); num = pool->ss.nstrings; - pool->whatprovides = whatprovides = (Offset *)xcalloc((num + WHATPROVIDES_BLOCK) & ~WHATPROVIDES_BLOCK, sizeof(Offset)); - pool->whatprovides_rel = (Offset *)xcalloc((pool->nrels + WHATPROVIDES_BLOCK) & ~WHATPROVIDES_BLOCK, sizeof(Offset)); + pool->whatprovides = whatprovides = sat_calloc((num + WHATPROVIDES_BLOCK) & ~WHATPROVIDES_BLOCK, sizeof(Offset)); + pool->whatprovides_rel = sat_calloc((pool->nrels + WHATPROVIDES_BLOCK) & ~WHATPROVIDES_BLOCK, sizeof(Offset)); /* count providers for each name */ for (i = 1; i < pool->nsolvables; i++) @@ -351,7 +351,7 @@ pool_createwhatprovides(Pool *pool) POOL_DEBUG(SAT_DEBUG_STATS, "provide space needed: %d + %d\n", off, extra); /* alloc space for all providers + extra */ - whatprovidesdata = (Id *)xcalloc(off + extra, sizeof(Id)); + whatprovidesdata = sat_calloc(off + extra, sizeof(Id)); /* now fill data for all provides */ for (i = 1; i < pool->nsolvables; i++) @@ -397,9 +397,9 @@ pool_createwhatprovides(Pool *pool) void pool_freewhatprovides(Pool *pool) { - pool->whatprovides = xfree(pool->whatprovides); - pool->whatprovides_rel = xfree(pool->whatprovides_rel); - pool->whatprovidesdata = xfree(pool->whatprovidesdata); + pool->whatprovides = sat_free(pool->whatprovides); + pool->whatprovides_rel = sat_free(pool->whatprovides_rel); + pool->whatprovidesdata = sat_free(pool->whatprovidesdata); pool->whatprovidesdataoff = 0; pool->whatprovidesdataleft = 0; } @@ -429,7 +429,7 @@ pool_queuetowhatprovides(Pool *pool, Queue *q) if (pool->whatprovidesdataleft < count + 1) { POOL_DEBUG(SAT_DEBUG_STATS, "growing provides hash data...\n"); - pool->whatprovidesdata = (Id *)xrealloc(pool->whatprovidesdata, (pool->whatprovidesdataoff + count + 4096) * sizeof(Id)); + pool->whatprovidesdata = sat_realloc(pool->whatprovidesdata, (pool->whatprovidesdataoff + count + 4096) * sizeof(Id)); pool->whatprovidesdataleft = count + 4096; } @@ -684,7 +684,7 @@ pool_addfileprovides_dep(Pool *pool, Id *ida, Map *seen, struct searchfiles *sf) if (*s != '/') continue; if ((sf->nfiles & SEARCHFILES_BLOCK) == 0) - sf->files = xrealloc2(sf->files, sf->nfiles + (SEARCHFILES_BLOCK + 1), sizeof(const char *)); + sf->files = sat_realloc2(sf->files, sf->nfiles + (SEARCHFILES_BLOCK + 1), sizeof(const char *)); sf->files[sf->nfiles++] = strdup(s); } } @@ -746,12 +746,12 @@ pool_addfileprovides(Pool *pool) POOL_DEBUG(SAT_DEBUG_STATS, "looking up %s in filelist\n", sf.files[i]); #endif if ((sf.nfiles & SEARCHFILES_BLOCK) == 0) - sf.files = xrealloc2(sf.files, sf.nfiles + (SEARCHFILES_BLOCK + 1), sizeof(const char *)); + sf.files = sat_realloc2(sf.files, sf.nfiles + (SEARCHFILES_BLOCK + 1), sizeof(const char *)); sf.files[sf.nfiles++] = 0; #if 0 pool_search(0, SOLVABLE_FILELIST, (const char *)sf.files, SEARCH_STRING|SEARCH_MULTIPLE, addfileprovides_cb, 0); #endif - xfree(sf.files); + sat_free(sf.files); pool_freewhatprovides(pool); /* as we have added provides */ } diff --git a/src/poolarch.c b/src/poolarch.c index 5755fda..7f4fa97 100644 --- a/src/poolarch.c +++ b/src/poolarch.c @@ -46,7 +46,7 @@ pool_setarch(Pool *pool, const char *arch) Id *id2arch; Id id, lastarch; - pool->id2arch = xfree(pool->id2arch); + pool->id2arch = sat_free(pool->id2arch); if (!arch) { pool->lastarch = 0; @@ -54,7 +54,7 @@ pool_setarch(Pool *pool, const char *arch) } id = ARCH_NOARCH; lastarch = id + 255; - id2arch = xcalloc(lastarch + 1, sizeof(Id)); + id2arch = sat_calloc(lastarch + 1, sizeof(Id)); id2arch[id] = 1; a = ""; @@ -74,7 +74,7 @@ pool_setarch(Pool *pool, const char *arch) id = str2id(pool, buf, 1); if (id > lastarch) { - id2arch = xrealloc(id2arch, (id + 255 + 1) * sizeof(Id)); + id2arch = sat_realloc(id2arch, (id + 255 + 1) * sizeof(Id)); memset(id2arch + lastarch + 1, 0, (id + 255 - lastarch) * sizeof(Id)); lastarch = id + 255; } diff --git a/src/poolid.c b/src/poolid.c index 57dd5c4..8a06437 100644 --- a/src/poolid.c +++ b/src/poolid.c @@ -31,7 +31,7 @@ str2id(Pool *pool, const char *str, int create) if (create && oldnstrings != pool->ss.nstrings && (id & WHATPROVIDES_BLOCK) == 0) { /* grow whatprovides array */ - pool->whatprovides = xrealloc(pool->whatprovides, (id + (WHATPROVIDES_BLOCK + 1)) * sizeof(Offset)); + pool->whatprovides = sat_realloc(pool->whatprovides, (id + (WHATPROVIDES_BLOCK + 1)) * sizeof(Offset)); memset(pool->whatprovides + id, 0, (WHATPROVIDES_BLOCK + 1) * sizeof(Offset)); } return id; @@ -55,9 +55,9 @@ rel2id(Pool *pool, Id name, Id evr, int flags, int create) /* extend hashtable if needed */ if (pool->nrels * 2 > hashmask) { - xfree(pool->relhashtbl); + sat_free(pool->relhashtbl); pool->relhashmask = hashmask = mkmask(pool->ss.nstrings + REL_BLOCK); - pool->relhashtbl = hashtbl = xcalloc(hashmask + 1, sizeof(Id)); + pool->relhashtbl = hashtbl = sat_calloc(hashmask + 1, sizeof(Id)); // rehash all rels into new hashtable for (i = 1; i < pool->nrels; i++) { @@ -87,7 +87,7 @@ rel2id(Pool *pool, Id name, Id evr, int flags, int create) id = pool->nrels++; /* extend rel space if needed */ if ((id & REL_BLOCK) == 0) - pool->rels = xrealloc(pool->rels, ((pool->nrels + REL_BLOCK) & ~REL_BLOCK) * sizeof(Reldep)); + pool->rels = sat_realloc(pool->rels, ((pool->nrels + REL_BLOCK) & ~REL_BLOCK) * sizeof(Reldep)); hashtbl[h] = id; ran = pool->rels + id; ran->name = name; @@ -97,7 +97,7 @@ rel2id(Pool *pool, Id name, Id evr, int flags, int create) /* extend whatprovides_rel if needed */ if (pool->whatprovides_rel && (id & WHATPROVIDES_BLOCK) == 0) { - pool->whatprovides_rel = xrealloc(pool->whatprovides_rel, (id + (WHATPROVIDES_BLOCK + 1)) * sizeof(Offset)); + pool->whatprovides_rel = sat_realloc(pool->whatprovides_rel, (id + (WHATPROVIDES_BLOCK + 1)) * sizeof(Offset)); memset(pool->whatprovides_rel + id, 0, (WHATPROVIDES_BLOCK + 1) * sizeof(Offset)); } return MAKERELDEP(id); @@ -209,10 +209,10 @@ dep2str(Pool *pool, Id id) if (l + 1 > pool->dep2strlen[n]) { if (s1 != pool->dep2strbuf[n]) - pool->dep2strbuf[n] = xrealloc(pool->dep2strbuf[n], l + 32); + pool->dep2strbuf[n] = sat_realloc(pool->dep2strbuf[n], l + 32); else { - pool->dep2strbuf[n] = xrealloc(pool->dep2strbuf[n], l + 32); + pool->dep2strbuf[n] = sat_realloc(pool->dep2strbuf[n], l + 32); s1 = pool->dep2strbuf[n]; } pool->dep2strlen[n] = l + 32; @@ -247,7 +247,7 @@ pool_shrink_strings(Pool *pool) void pool_shrink_rels(Pool *pool) { - pool->rels = (Reldep *)xrealloc(pool->rels, ((pool->nrels + REL_BLOCK) & ~REL_BLOCK) * sizeof(Reldep)); + pool->rels = (Reldep *)sat_realloc(pool->rels, ((pool->nrels + REL_BLOCK) & ~REL_BLOCK) * sizeof(Reldep)); } // reset all hash tables @@ -255,9 +255,9 @@ pool_shrink_rels(Pool *pool) void pool_freeidhashes(Pool *pool) { - pool->ss.stringhashtbl = xfree(pool->ss.stringhashtbl); + pool->ss.stringhashtbl = sat_free(pool->ss.stringhashtbl); pool->ss.stringhashmask = 0; - pool->relhashtbl = xfree(pool->relhashtbl); + pool->relhashtbl = sat_free(pool->relhashtbl); pool->relhashmask = 0; } diff --git a/src/queue.c b/src/queue.c index a585c1c..6740371 100644 --- a/src/queue.c +++ b/src/queue.c @@ -19,7 +19,7 @@ void queue_clone(Queue *t, Queue *s) { - t->alloc = t->elements = xmalloc((s->count + 8) * sizeof(Id)); + t->alloc = t->elements = sat_malloc2(s->count + 8, sizeof(Id)); if (s->count) memcpy(t->alloc, s->elements, s->count * sizeof(Id)); t->count = s->count; @@ -46,7 +46,7 @@ void queue_free(Queue *q) { if (q->alloc) - free(q->alloc); + sat_free(q->alloc); q->alloc = q->elements = 0; q->count = q->left = 0; } @@ -62,12 +62,12 @@ queue_alloc_one(Queue *q) } else if (q->alloc) { - q->elements = q->alloc = realloc(q->alloc, (q->count + 8) * sizeof(Id)); + q->elements = q->alloc = sat_realloc2(q->alloc, q->count + 8, sizeof(Id)); q->left += 8; } else { - q->alloc = xmalloc((q->count + 8) * sizeof(Id)); + q->alloc = sat_malloc2(q->count + 8, sizeof(Id)); if (q->count) memcpy(q->alloc, q->elements, q->count * sizeof(Id)); q->elements = q->alloc; @@ -36,8 +36,8 @@ repo_create(Pool *pool, const char *name) Repo *repo; pool_freewhatprovides(pool); - repo = (Repo *)xcalloc(1, sizeof(*repo)); - pool->repos = (Repo **)xrealloc(pool->repos, (pool->nrepos + 1) * sizeof(Repo *)); + repo = (Repo *)sat_calloc(1, sizeof(*repo)); + pool->repos = (Repo **)sat_realloc2(pool->repos, pool->nrepos + 1, sizeof(Repo *)); pool->repos[pool->nrepos++] = repo; repo->name = name ? strdup(name) : 0; repo->pool = pool; @@ -50,10 +50,10 @@ repo_create(Pool *pool, const char *name) static void repo_freedata(Repo *repo) { - xfree(repo->idarraydata); - xfree(repo->rpmdbid); - xfree((char *)repo->name); - xfree(repo); + sat_free(repo->idarraydata); + sat_free(repo->rpmdbid); + sat_free((char *)repo->name); + sat_free(repo); } /* @@ -74,7 +74,7 @@ repo_addid(Repo *repo, Offset olddeps, Id id) if (!idarray) /* alloc idarray if not done yet */ { - idarray = (Id *)xmalloc((1 + IDARRAY_BLOCK) * sizeof(Id)); + idarray = sat_malloc2(1 + IDARRAY_BLOCK, sizeof(Id)); idarray[0] = 0; idarraysize = 1; repo->lastoff = 0; @@ -84,7 +84,7 @@ repo_addid(Repo *repo, Offset olddeps, Id id) { olddeps = idarraysize; if ((idarraysize & IDARRAY_BLOCK) == 0) - idarray = (Id *)xrealloc(idarray, (idarraysize + 1 + IDARRAY_BLOCK) * sizeof(Id)); + idarray = sat_realloc2(idarray, idarraysize + 1 + IDARRAY_BLOCK, sizeof(Id)); } else if (olddeps == repo->lastoff) /* extend at end */ idarraysize--; @@ -95,17 +95,17 @@ repo_addid(Repo *repo, Offset olddeps, Id id) for (; idarray[i]; i++) { if ((idarraysize & IDARRAY_BLOCK) == 0) - idarray = (Id *)xrealloc(idarray, (idarraysize + 1 + IDARRAY_BLOCK) * sizeof(Id)); + idarray = sat_realloc2(idarray, idarraysize + 1 + IDARRAY_BLOCK, sizeof(Id)); idarray[idarraysize++] = idarray[i]; } if ((idarraysize & IDARRAY_BLOCK) == 0) - idarray = (Id *)xrealloc(idarray, (idarraysize + 1 + IDARRAY_BLOCK) * sizeof(Id)); + idarray = sat_realloc2(idarray, idarraysize + 1 + IDARRAY_BLOCK, sizeof(Id)); } idarray[idarraysize++] = id; /* insert Id into array */ if ((idarraysize & IDARRAY_BLOCK) == 0) /* realloc if at block boundary */ - idarray = (Id *)xrealloc(idarray, (idarraysize + 1 + IDARRAY_BLOCK) * sizeof(Id)); + idarray = sat_realloc2(idarray, idarraysize + 1 + IDARRAY_BLOCK, sizeof(Id)); idarray[idarraysize++] = 0; /* ensure NULL termination */ @@ -215,7 +215,7 @@ repo_reserve_ids(Repo *repo, Offset olddeps, int num) if (!repo->idarraysize) /* ensure buffer space */ { repo->idarraysize = 1; - repo->idarraydata = (Id *)xmalloc(((1 + num + IDARRAY_BLOCK) & ~IDARRAY_BLOCK) * sizeof(Id)); + repo->idarraydata = sat_malloc2((1 + num + IDARRAY_BLOCK) & ~IDARRAY_BLOCK, sizeof(Id)); repo->idarraydata[0] = 0; repo->lastoff = 1; return 1; @@ -237,7 +237,7 @@ repo_reserve_ids(Repo *repo, Offset olddeps, int num) /* realloc if crossing block boundary */ if (((repo->idarraysize - 1) | IDARRAY_BLOCK) != ((repo->idarraysize + count - 1) | IDARRAY_BLOCK)) - repo->idarraydata = (Id *)xrealloc(repo->idarraydata, ((repo->idarraysize + count + IDARRAY_BLOCK) & ~IDARRAY_BLOCK) * sizeof(Id)); + repo->idarraydata = sat_realloc2(repo->idarraydata, (repo->idarraysize + count + IDARRAY_BLOCK) & ~IDARRAY_BLOCK, sizeof(Id)); /* move old deps to end */ olddeps = repo->lastoff = repo->idarraysize; @@ -252,7 +252,7 @@ repo_reserve_ids(Repo *repo, Offset olddeps, int num) /* realloc if crossing block boundary */ if (((repo->idarraysize - 1) | IDARRAY_BLOCK) != ((repo->idarraysize + num - 1) | IDARRAY_BLOCK)) - repo->idarraydata = (Id *)xrealloc(repo->idarraydata, ((repo->idarraysize + num + IDARRAY_BLOCK) & ~IDARRAY_BLOCK) * sizeof(Id)); + repo->idarraydata = sat_realloc2(repo->idarraydata, (repo->idarraysize + num + IDARRAY_BLOCK) & ~IDARRAY_BLOCK, sizeof(Id)); /* appending or new */ repo->lastoff = olddeps ? olddeps : repo->idarraysize; @@ -308,7 +308,7 @@ repo_freeallrepos(Pool *pool, int reuseids) pool_freewhatprovides(pool); for (i = 0; i < pool->nrepos; i++) repo_freedata(pool->repos[i]); - pool->repos = xfree(pool->repos); + pool->repos = sat_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); @@ -906,14 +906,14 @@ repo_add_attrstore (Repo *repo, Attrstore *s, const char *location) } } repo->nrepodata++; - repo->repodata = xrealloc (repo->repodata, repo->nrepodata * sizeof (*data)); + repo->repodata = sat_realloc2(repo->repodata, repo->nrepodata, sizeof(*data)); data = repo->repodata + repo->nrepodata - 1; memset (data, 0, sizeof (*data)); data->s = s; data->nkeys = s->nkeys; if (data->nkeys) { - data->keys = xmalloc(data->nkeys * sizeof(data->keys[0])); + data->keys = sat_malloc2(data->nkeys, sizeof(data->keys[0])); for (i = 1; i < data->nkeys; i++) { data->keys[i].name = s->keys[i].name; diff --git a/src/repo_solv.c b/src/repo_solv.c index 0371320..4ccb8c8 100644 --- a/src/repo_solv.c +++ b/src/repo_solv.c @@ -215,7 +215,7 @@ read_str(Repodata *data, char **inbuf, unsigned *len) unsigned char *buf = (unsigned char*)*inbuf; if (!buf) { - buf = xmalloc (1024); + buf = sat_malloc(1024); *len = 1024; } int c; @@ -235,11 +235,11 @@ read_str(Repodata *data, char **inbuf, unsigned *len) /* Don't realloc on the inbuf, it might be on the stack. */ if (buf == (unsigned char*)*inbuf) { - buf = xmalloc(*len); + buf = sat_malloc(*len); memcpy(buf, *inbuf, *len - 256); } else - buf = xrealloc(buf, *len); + buf = sat_realloc(buf, *len); } buf[ofs++] = c; } @@ -325,7 +325,7 @@ parse_repodata(Repodata *maindata, Id *keyp, Repokey *keys, Id *idmap, unsigned Repodata *data; int i, n; - repo->repodata = xrealloc(repo->repodata, (repo->nrepodata + 1) * sizeof (*data)); + repo->repodata = sat_realloc2(repo->repodata, repo->nrepodata + 1, sizeof (*data)); data = repo->repodata + repo->nrepodata++; data->repo = repo; memset(data, 0, sizeof(*data)); @@ -341,7 +341,7 @@ parse_repodata(Repodata *maindata, Id *keyp, Repokey *keys, Id *idmap, unsigned skip_item(maindata, TYPE_IDVALUEARRAY, numid, numrel); break; } - ida = xcalloc(keys[key].size, sizeof(Id)); + ida = sat_calloc(keys[key].size, sizeof(Id)); ide = read_idarray(maindata, 0, 0, ida, ida + keys[key].size, 0); n = ide - ida - 1; if (n & 1) @@ -350,7 +350,7 @@ parse_repodata(Repodata *maindata, Id *keyp, Repokey *keys, Id *idmap, unsigned return; } data->nkeys = 1 + (n >> 1); - data->keys = xmalloc2(data->nkeys, sizeof(data->keys[0])); + data->keys = sat_malloc2(data->nkeys, sizeof(data->keys[0])); memset(data->keys, 0, sizeof(Repokey)); for (i = 1, ide = ida; i < data->nkeys; i++) { @@ -365,7 +365,7 @@ parse_repodata(Repodata *maindata, Id *keyp, Repokey *keys, Id *idmap, unsigned data->keys[i].size = 0; data->keys[i].storage = 0; } - xfree(ida); + sat_free(ida); if (data->nkeys > 2) qsort(data->keys + 1, data->nkeys - 1, sizeof(data->keys[0]), key_cmp); break; @@ -410,7 +410,7 @@ incore_add_id(Repodata *data, Id x) /* make sure we have at least 5 bytes free */ if (data->incoredatafree < 5) { - data->incoredata = xrealloc(data->incoredata, data->incoredatalen + 1024); + data->incoredata = sat_realloc(data->incoredata, data->incoredatalen + 1024); data->incoredatafree = 1024; } dp = data->incoredata + data->incoredatalen; @@ -438,7 +438,7 @@ incore_add_u32(Repodata *data, unsigned int x) /* make sure we have at least 4 bytes free */ if (data->incoredatafree < 4) { - data->incoredata = xrealloc(data->incoredata, data->incoredatalen + 1024); + data->incoredata = sat_realloc(data->incoredata, data->incoredatalen + 1024); data->incoredatafree = 1024; } dp = data->incoredata + data->incoredatalen; @@ -457,7 +457,7 @@ incore_add_u8(Repodata *data, unsigned int x) /* make sure we have at least 1 byte free */ if (data->incoredatafree < 1) { - data->incoredata = xrealloc(data->incoredata, data->incoredatalen + 1024); + data->incoredata = sat_realloc(data->incoredata, data->incoredatalen + 1024); data->incoredatafree = 1024; } dp = data->incoredata + data->incoredatalen; @@ -563,9 +563,9 @@ repo_add_solv(Repo *repo, FILE *fp) */ /* alloc string buffer */ - pool->ss.stringspace = xrealloc(pool->ss.stringspace, pool->ss.sstrings + sizeid + 1); + pool->ss.stringspace = sat_realloc(pool->ss.stringspace, pool->ss.sstrings + sizeid + 1); /* alloc string offsets (Id -> Offset into string space) */ - pool->ss.strings = xrealloc2(pool->ss.strings, pool->ss.nstrings + numid, sizeof(Offset)); + pool->ss.strings = sat_realloc2(pool->ss.strings, pool->ss.nstrings + numid, sizeof(Offset)); strsp = pool->ss.stringspace; str = pool->ss.strings; /* array of offsets into strsp, indexed by Id */ @@ -589,14 +589,14 @@ repo_add_solv(Repo *repo, FILE *fp) else { unsigned int pfsize = read_u32(&data); - char *prefix = xmalloc(pfsize); + char *prefix = sat_malloc(pfsize); char *pp = prefix; char *old_str = ""; char *dest = strsp; if (fread(prefix, pfsize, 1, fp) != 1) { pool_debug(pool, SAT_ERROR, "read error while reading strings\n"); - xfree(prefix); + sat_free(prefix); return SOLV_ERROR_EOF; } for (i = 1; i < numid; i++) @@ -610,7 +610,7 @@ repo_add_solv(Repo *repo, FILE *fp) old_str = dest; dest += same + len; } - xfree(prefix); + sat_free(prefix); } strsp[sizeid] = 0; /* make string space \0 terminated */ sp = strsp; @@ -618,7 +618,7 @@ repo_add_solv(Repo *repo, FILE *fp) /* alloc id map for name and rel Ids. this maps ids in the solv files * to the ids in our pool */ - idmap = (Id *)xcalloc(numid + numrel, sizeof(Id)); + idmap = sat_calloc(numid + numrel, sizeof(Id)); /* * build hashes for all read strings @@ -636,7 +636,7 @@ repo_add_solv(Repo *repo, FILE *fp) * create hashtable with strings already in pool */ - hashtbl = (Id *)xcalloc(hashmask + 1, sizeof(Id)); + hashtbl = sat_calloc(hashmask + 1, sizeof(Id)); for (i = 1; i < pool->ss.nstrings; i++) /* leave out our dummy zero id */ { h = strhash(pool->ss.stringspace + pool->ss.strings[i]) & hashmask; @@ -656,8 +656,8 @@ repo_add_solv(Repo *repo, FILE *fp) { if (sp >= strsp + sizeid) { - xfree(hashtbl); - xfree(idmap); + sat_free(hashtbl); + sat_free(idmap); pool_debug(pool, SAT_ERROR, "not enough strings\n"); return SOLV_ERROR_OVERFLOW; } @@ -695,7 +695,7 @@ repo_add_solv(Repo *repo, FILE *fp) idmap[i] = id; /* repo relative -> pool relative */ sp += l; /* next string */ } - xfree(hashtbl); + sat_free(hashtbl); pool_shrink_strings(pool); /* vacuum */ @@ -709,7 +709,7 @@ repo_add_solv(Repo *repo, FILE *fp) if (numrel) { /* extend rels */ - pool->rels = xrealloc2(pool->rels, pool->nrels + numrel, sizeof(Reldep)); + pool->rels = sat_realloc2(pool->rels, pool->nrels + numrel, sizeof(Reldep)); ran = pool->rels; hashmask = mkmask(pool->nrels + numrel); @@ -721,7 +721,7 @@ repo_add_solv(Repo *repo, FILE *fp) * prep hash table with already existing RelDeps */ - hashtbl = xcalloc(hashmask + 1, sizeof(Id)); + hashtbl = sat_calloc(hashmask + 1, sizeof(Id)); for (i = 1; i < pool->nrels; i++) { h = relhash(ran[i].name, ran[i].evr, ran[i].flags) & hashmask; @@ -763,14 +763,14 @@ repo_add_solv(Repo *repo, FILE *fp) } idmap[i + numid] = MAKERELDEP(id); /* fill Id map */ } - xfree(hashtbl); + sat_free(hashtbl); pool_shrink_rels(pool); /* vacuum */ } /******* Part 3: Keys ***********************************************/ - keys = xcalloc(numkeys, sizeof(*keys)); + keys = sat_calloc(numkeys, sizeof(*keys)); /* keys start at 1 */ for (i = 1; i < numkeys; i++) { @@ -824,10 +824,10 @@ repo_add_solv(Repo *repo, FILE *fp) /******* Part 4: Schemata ********************************************/ id = read_id(&data, 0); - schemadata = xcalloc(id, sizeof(Id)); + schemadata = sat_calloc(id, sizeof(Id)); schemadatap = schemadata; schemadataend = schemadata + id; - schemata = xcalloc(numschemata, sizeof(Id)); + schemata = sat_calloc(numschemata, sizeof(Id)); for (i = 0; i < numschemata; i++) { schemata[i] = schemadatap - schemadata; @@ -858,7 +858,7 @@ repo_add_solv(Repo *repo, FILE *fp) char *exists = 0; if ((solvflags & SOLV_FLAG_PACKEDSIZES) != 0) { - exists = xmalloc (numsolv); + exists = sat_malloc (numsolv); for (i = 0; i < numsolv; i++) exists[i] = read_id(&data, 0) != 0; } @@ -935,7 +935,7 @@ repo_add_solv(Repo *repo, FILE *fp) if (id == RPM_RPMDBID) { if (!repo->rpmdbid) - repo->rpmdbid = (Id *)xcalloc(numsolv, sizeof(Id)); + repo->rpmdbid = sat_calloc(numsolv, sizeof(Id)); repo->rpmdbid[i] = h; } else if (keys[key].storage == KEY_STORAGE_INCORE) @@ -1056,14 +1056,14 @@ repo_add_solv(Repo *repo, FILE *fp) /* free id array */ repo->idarraysize -= size_idarray; /* free incore data */ - data.incoredata = xfree(data.incoredata); + data.incoredata = sat_free(data.incoredata); data.incoredatalen = data.incoredatafree = 0; } if (data.incoredatafree) { /* shrink excess size */ - data.incoredata = xrealloc(data.incoredata, data.incoredatalen); + data.incoredata = sat_realloc(data.incoredata, data.incoredatalen); data.incoredatafree = 0; } @@ -1084,17 +1084,17 @@ repo_add_solv(Repo *repo, FILE *fp) if (data.incoredatalen || data.fp) { /* we got some data, make it available */ - repo->repodata = xrealloc(repo->repodata, (repo->nrepodata + 1) * sizeof(data)); + repo->repodata = sat_realloc2(repo->repodata, repo->nrepodata + 1, sizeof(data)); repo->repodata[repo->nrepodata++] = data; } else { - xfree(schemata); - xfree(schemadata); - xfree(keys); + sat_free(schemata); + sat_free(schemadata); + sat_free(keys); } - xfree(exists); + sat_free(exists); #if 0 if (embedded_store) { @@ -1105,7 +1105,7 @@ repo_add_solv(Repo *repo, FILE *fp) repo_add_attrstore (repo, embedded_store, NULL); } #endif - xfree(idmap); + sat_free(idmap); mypool = 0; return data.error; } diff --git a/src/solver.c b/src/solver.c index cda4388..71afad5 100644 --- a/src/solver.c +++ b/src/solver.c @@ -268,7 +268,7 @@ unifyrules(Solver *solv) /* adapt rule buffer */ solv->nrules = j; - solv->rules = (Rule *)xrealloc(solv->rules, ((solv->nrules + RULES_BLOCK) & ~RULES_BLOCK) * sizeof(Rule)); + solv->rules = (Rule *)sat_realloc(solv->rules, ((solv->nrules + RULES_BLOCK) & ~RULES_BLOCK) * sizeof(Rule)); IF_POOLDEBUG (SAT_DEBUG_STATS) { int binr = 0; @@ -438,7 +438,7 @@ addrule(Solver *solv, Id p, Id d) /* check and extend rule buffer */ if ((solv->nrules & RULES_BLOCK) == 0) { - solv->rules = (Rule *)xrealloc(solv->rules, (solv->nrules + (RULES_BLOCK + 1)) * sizeof(Rule)); + solv->rules = (Rule *)sat_realloc(solv->rules, (solv->nrules + (RULES_BLOCK + 1)) * sizeof(Rule)); } r = solv->rules + solv->nrules++; /* point to rule space */ @@ -1226,9 +1226,9 @@ makewatches(Solver *solv) int i; int nsolvables = solv->pool->nsolvables; - xfree(solv->watches); + sat_free(solv->watches); /* lower half for removals, upper half for installs */ - solv->watches = (Id *)xcalloc(2 * nsolvables, sizeof(Id)); + solv->watches = (Id *)sat_calloc(2 * nsolvables, sizeof(Id)); #if 1 /* do it reverse so rpm rules get triggered first */ for (i = 1, r = solv->rules + solv->nrules - 1; i < solv->nrules; i++, r--) @@ -1952,7 +1952,7 @@ Solver * solver_create(Pool *pool, Repo *installed) { Solver *solv; - solv = (Solver *)xcalloc(1, sizeof(Solver)); + solv = (Solver *)sat_calloc(1, sizeof(Solver)); solv->pool = pool; solv->installed = installed; @@ -1970,8 +1970,8 @@ solver_create(Pool *pool, Repo *installed) map_init(&solv->noupdate, installed ? installed->end - installed->start : 0); solv->recommends_index = 0; - solv->decisionmap = (Id *)xcalloc(pool->nsolvables, sizeof(Id)); - solv->rules = (Rule *)xmalloc((solv->nrules + (RULES_BLOCK + 1)) * sizeof(Rule)); + solv->decisionmap = (Id *)sat_calloc(pool->nsolvables, sizeof(Id)); + solv->rules = (Rule *)sat_malloc((solv->nrules + (RULES_BLOCK + 1)) * sizeof(Rule)); memset(solv->rules, 0, sizeof(Rule)); solv->nrules = 1; @@ -1998,13 +1998,13 @@ solver_free(Solver *solv) map_free(&solv->recommendsmap); map_free(&solv->suggestsmap); map_free(&solv->noupdate); - xfree(solv->decisionmap); - xfree(solv->rules); - xfree(solv->watches); - xfree(solv->weaksystemrules); - xfree(solv->obsoletes); - xfree(solv->obsoletes_data); - xfree(solv); + sat_free(solv->decisionmap); + sat_free(solv->rules); + sat_free(solv->watches); + sat_free(solv->weaksystemrules); + sat_free(solv->obsoletes); + sat_free(solv->obsoletes_data); + sat_free(solv); } @@ -2674,7 +2674,7 @@ create_obsoletesmap(Solver *solv) int i; Solvable *s; - obsoletesmap = (Id *)xcalloc(pool->nsolvables, sizeof(Id)); + obsoletesmap = (Id *)sat_calloc(pool->nsolvables, sizeof(Id)); if (installed) { for (i = 0; i < solv->decisionq.count; i++) @@ -2800,7 +2800,7 @@ printdecisions(Solver *solv) POOL_DEBUG(SAT_DEBUG_RESULT, "\n"); } - xfree(obsoletesmap); + sat_free(obsoletesmap); if (solv->suggestions.count) { @@ -3252,7 +3252,7 @@ create_obsolete_index(Solver *solv) if (!installed || !installed->nsolvables) return; /* create reverse obsoletes map for installed solvables */ - solv->obsoletes = obsoletes = xcalloc(installed->end - installed->start, sizeof(Id)); + solv->obsoletes = obsoletes = sat_calloc(installed->end - installed->start, sizeof(Id)); for (i = 1; i < pool->nsolvables; i++) { s = pool->solvables + i; @@ -3280,7 +3280,7 @@ create_obsolete_index(Solver *solv) n += obsoletes[i] + 1; obsoletes[i] = n; } - solv->obsoletes_data = obsoletes_data = xcalloc(n + 1, sizeof(Id)); + solv->obsoletes_data = obsoletes_data = sat_calloc(n + 1, sizeof(Id)); POOL_DEBUG(SAT_DEBUG_STATS, "obsoletes data: %d entries\n", n + 1); for (i = pool->nsolvables - 1; i > 0; i--) { @@ -3560,7 +3560,7 @@ solver_solve(Solver *solv, Queue *job) best effort mode */ if (installed && installed->nsolvables) { - solv->weaksystemrules = xcalloc(installed->end - installed->start, sizeof(Id)); + solv->weaksystemrules = sat_calloc(installed->end - installed->start, sizeof(Id)); FOR_REPO_SOLVABLES(installed, p, s) { policy_findupdatepackages(solv, s, &q, 1); diff --git a/src/strpool.c b/src/strpool.c index 7b0d765..8bf73e5 100644 --- a/src/strpool.c +++ b/src/strpool.c @@ -22,8 +22,8 @@ stringpool_init (Stringpool *ss, const char *strs[]) totalsize += strlen(strs[count]) + 1; // alloc appropriate space - ss->stringspace = (char *)xmalloc((totalsize + STRINGSPACE_BLOCK) & ~STRINGSPACE_BLOCK); - ss->strings = (Offset *)xmalloc(((count + STRING_BLOCK) & ~STRING_BLOCK) * sizeof(Offset)); + ss->stringspace = sat_malloc((totalsize + STRINGSPACE_BLOCK) & ~STRINGSPACE_BLOCK); + ss->strings = sat_malloc2((count + STRING_BLOCK) & ~STRING_BLOCK, sizeof(Offset)); // now copy predefined strings into allocated space ss->sstrings = 0; @@ -60,11 +60,11 @@ stringpool_strn2id (Stringpool *ss, const char *str, unsigned len, int create) // if (ss->nstrings * 2 > hashmask) { - xfree(hashtbl); + sat_free(hashtbl); // realloc hash table ss->stringhashmask = hashmask = mkmask(ss->nstrings + STRING_BLOCK); - ss->stringhashtbl = hashtbl = (Hashtable)xcalloc(hashmask + 1, sizeof(Id)); + ss->stringhashtbl = hashtbl = (Hashtable)sat_calloc(hashmask + 1, sizeof(Id)); // rehash all strings into new hashtable for (i = 1; i < ss->nstrings; i++) @@ -98,7 +98,7 @@ stringpool_strn2id (Stringpool *ss, const char *str, unsigned len, int create) // if ((id & STRING_BLOCK) == 0) - ss->strings = xrealloc(ss->strings, ((ss->nstrings + STRING_BLOCK) & ~STRING_BLOCK) * sizeof(Hashval)); + ss->strings = sat_realloc2(ss->strings, (ss->nstrings + STRING_BLOCK) & ~STRING_BLOCK, sizeof(Hashval)); // 'pointer' into stringspace is Offset of next free pos: sstrings ss->strings[id] = ss->sstrings; @@ -106,7 +106,7 @@ stringpool_strn2id (Stringpool *ss, const char *str, unsigned len, int create) // resize string buffer if needed if (((ss->sstrings + space_needed - 1) | STRINGSPACE_BLOCK) != ((ss->sstrings - 1) | STRINGSPACE_BLOCK)) - ss->stringspace = xrealloc(ss->stringspace, (ss->sstrings + space_needed + STRINGSPACE_BLOCK) & ~STRINGSPACE_BLOCK); + ss->stringspace = sat_realloc(ss->stringspace, (ss->sstrings + space_needed + STRINGSPACE_BLOCK) & ~STRINGSPACE_BLOCK); // copy new string into buffer memcpy(ss->stringspace + ss->sstrings, str, space_needed - 1); // add the sentinel, we can't rely on it being in the source string (in @@ -128,6 +128,6 @@ stringpool_str2id (Stringpool *ss, const char *str, int create) void stringpool_shrink (Stringpool *ss) { - ss->stringspace = (char *)xrealloc(ss->stringspace, (ss->sstrings + STRINGSPACE_BLOCK) & ~STRINGSPACE_BLOCK); - ss->strings = (Offset *)xrealloc(ss->strings, ((ss->nstrings + STRING_BLOCK) & ~STRING_BLOCK) * sizeof(Offset)); + ss->stringspace = (char *)sat_realloc(ss->stringspace, (ss->sstrings + STRINGSPACE_BLOCK) & ~STRINGSPACE_BLOCK); + ss->strings = (Offset *)sat_realloc2(ss->strings, (ss->nstrings + STRING_BLOCK) & ~STRING_BLOCK, sizeof(Offset)); } @@ -13,7 +13,7 @@ #include "util.h" void * -xmalloc(size_t len) +sat_malloc(size_t len) { void *r = malloc(len ? len : 1); if (r) @@ -23,18 +23,18 @@ xmalloc(size_t len) } void * -xmalloc2(size_t num, size_t len) +sat_malloc2(size_t num, size_t len) { if (len && (num * len) / len != num) { fprintf(stderr, "Out of memory allocating %zu*%zu bytes!\n", num, len); exit(1); } - return xmalloc(num * len); + return sat_malloc(num * len); } void * -xrealloc(void *old, size_t len) +sat_realloc(void *old, size_t len) { if (old == 0) old = malloc(len ? len : 1); @@ -47,18 +47,18 @@ xrealloc(void *old, size_t len) } void * -xrealloc2(void *old, size_t num, size_t len) +sat_realloc2(void *old, size_t num, size_t len) { if (len && (num * len) / len != num) { fprintf(stderr, "Out of memory allocating %zu*%zu bytes!\n", num, len); exit(1); } - return xrealloc(old, num * len); + return sat_realloc(old, num * len); } void * -xcalloc(size_t num, size_t len) +sat_calloc(size_t num, size_t len) { void *r; if (num == 0 || len == 0) @@ -72,7 +72,7 @@ xcalloc(size_t num, size_t len) } void * -xfree(void *mem) +sat_free(void *mem) { if (mem) free(mem); @@ -13,11 +13,11 @@ #ifndef SATSOLVER_UTIL_H #define SATSOLVER_UTIL_H -extern void *xmalloc(size_t); -extern void *xmalloc2(size_t, size_t); -extern void *xcalloc(size_t, size_t); -extern void *xrealloc(void *, size_t); -extern void *xrealloc2(void *, size_t, size_t); -extern void *xfree(void *); +extern void *sat_malloc(size_t); +extern void *sat_malloc2(size_t, size_t); +extern void *sat_calloc(size_t, size_t); +extern void *sat_realloc(void *, size_t); +extern void *sat_realloc2(void *, size_t, size_t); +extern void *sat_free(void *); #endif /* SATSOLVER_UTIL_H */ diff --git a/tools/repo_content.c b/tools/repo_content.c index 013e914..7706750 100644 --- a/tools/repo_content.c +++ b/tools/repo_content.c @@ -79,10 +79,7 @@ join(struct parsedata *pd, char *s1, char *s2, char *s3) if (l > pd->tmpl) { pd->tmpl = l + 256; - if (!pd->tmp) - pd->tmp = malloc(pd->tmpl); - else - pd->tmp = realloc(pd->tmp, pd->tmpl); + pd->tmp = sat_realloc(pd->tmp, pd->tmpl); } p = pd->tmp; if (s1) @@ -169,7 +166,7 @@ repo_add_content(Repo *repo, FILE *fp) struct parsedata pd; memset(&pd, 0, sizeof(pd)); - line = xmalloc(1024); + line = sat_malloc(1024); aline = 1024; pd.repo = repo; @@ -182,7 +179,7 @@ repo_add_content(Repo *repo, FILE *fp) if (linep - line + 16 > aline) { aline = linep - line; - line = realloc(line, aline + 512); + line = sat_realloc(line, aline + 512); linep = line + aline; aline += 512; } @@ -266,6 +263,6 @@ repo_add_content(Repo *repo, FILE *fp) s->supplements = repo_fix_legacy(repo, s->provides, s->supplements); if (pd.tmp) - free(pd.tmp); - free(line); + sat_free(pd.tmp); + sat_free(line); } diff --git a/tools/repo_rpmdb.c b/tools/repo_rpmdb.c index ab0edfb..b407528 100644 --- a/tools/repo_rpmdb.c +++ b/tools/repo_rpmdb.c @@ -103,7 +103,7 @@ headint32(RpmHead *h, int tag, int *cnt) if (o + 4 * i > h->dcnt) return 0; d = h->dp + o; - r = xcalloc(i ? i : 1, sizeof(unsigned int)); + r = sat_calloc(i ? i : 1, sizeof(unsigned int)); if (cnt) *cnt = i; for (o = 0; o < i; o++, d += 4) @@ -153,7 +153,7 @@ headstringarray(RpmHead *h, int tag, int *cnt) return 0; o = d[8] << 24 | d[9] << 16 | d[10] << 8 | d[11]; i = d[12] << 24 | d[13] << 16 | d[14] << 8 | d[15]; - r = xcalloc(i ? i : 1, sizeof(char *)); + r = sat_calloc(i ? i : 1, sizeof(char *)); if (cnt) *cnt = i; d = h->dp + o; @@ -164,7 +164,7 @@ headstringarray(RpmHead *h, int tag, int *cnt) d += strlen((char *)d) + 1; if (d >= h->dp + h->dcnt) { - free(r); + sat_free(r); return 0; } } @@ -194,16 +194,16 @@ static char *headtoevr(RpmHead *h) { char epochbuf[11]; /* 32bit decimal will fit in */ sprintf(epochbuf, "%u", epoch); - evr = xmalloc(strlen(epochbuf) + 1 + strlen(version) + 1 + strlen(release) + 1); + evr = sat_malloc(strlen(epochbuf) + 1 + strlen(version) + 1 + strlen(release) + 1); sprintf(evr, "%s:%s-%s", epochbuf, version, release); } else { - evr = xmalloc(strlen(version) + 1 + strlen(release) + 1); + evr = sat_malloc(strlen(version) + 1 + strlen(release) + 1); sprintf(evr, "%s-%s", version, release); } if (epochp) - free(epochp); + sat_free(epochp); return evr; } @@ -223,13 +223,13 @@ makedeps(Pool *pool, Repo *repo, RpmHead *rpmhead, int tagn, int tagv, int tagf, v = headstringarray(rpmhead, tagv, &vc); if (!v) { - free(n); + sat_free(n); return 0; } f = headint32(rpmhead, tagf, &fc); if (!f) { - free(n); + sat_free(n); free(v); return 0; } @@ -264,9 +264,9 @@ makedeps(Pool *pool, Repo *repo, RpmHead *rpmhead, int tagn, int tagv, int tagf, haspre = 0; if (cc == 0) { - free(n); - free(v); - free(f); + sat_free(n); + sat_free(v); + sat_free(f); return 0; } cc += haspre; @@ -310,9 +310,9 @@ makedeps(Pool *pool, Repo *repo, RpmHead *rpmhead, int tagn, int tagv, int tagf, } *ida++ = 0; repo->idarraysize += cc + 1; - free(n); - free(v); - free(f); + sat_free(n); + sat_free(v); + sat_free(f); return olddeps; } @@ -399,14 +399,14 @@ addfileprovides(Pool *pool, Repo *repo, RpmHead *rpmhead, unsigned int olddeps) dn = headstringarray(rpmhead, TAG_DIRNAMES, &dnc); if (!dn) { - free(bn); + sat_free(bn); return olddeps; } di = headint32(rpmhead, TAG_DIRINDEXES, &dic); if (!di) { - free(bn); - free(dn); + sat_free(bn); + sat_free(dn); return olddeps; } if (bnc != dic) @@ -451,17 +451,17 @@ addfileprovides(Pool *pool, Repo *repo, RpmHead *rpmhead, unsigned int olddeps) if (j > fna) { fna = j + 256; - fn = xrealloc(fn, fna); + fn = sat_realloc(fn, fna); } strcpy(fn, dn[di[i]]); strcat(fn, bn[i]); olddeps = repo_addid(repo, olddeps, str2id(pool, fn, 1)); } if (fn) - free(fn); - free(bn); - free(dn); - free(di); + sat_free(fn); + sat_free(bn); + sat_free(dn); + sat_free(di); return olddeps; } @@ -485,7 +485,7 @@ rpm2solv(Pool *pool, Repo *repo, Solvable *s, RpmHead *rpmhead) s->arch = ARCH_NOARCH; evr = headtoevr(rpmhead); s->evr = str2id(pool, evr, 1); - free(evr); + sat_free(evr); s->vendor = str2id(pool, headstring(rpmhead, TAG_VENDOR), 1); s->provides = makedeps(pool, repo, rpmhead, TAG_PROVIDENAME, TAG_PROVIDEVERSION, TAG_PROVIDEFLAGS, 0); @@ -560,7 +560,7 @@ repo_add_rpmdb(Repo *repo, Repo *ref, const char *rootdir) exit(1); } dbidp = (unsigned char *)&dbid; - repo->rpmdbid = xcalloc(256, sizeof(unsigned int)); + repo->rpmdbid = sat_calloc(256, sizeof(unsigned int)); asolv = 256; rpmheadsize = 0; rpmhead = 0; @@ -572,7 +572,7 @@ repo_add_rpmdb(Repo *repo, Repo *ref, const char *rootdir) s = pool_id2solvable(pool, repo_add_solvable(repo)); if (i >= asolv) { - repo->rpmdbid = xrealloc(repo->rpmdbid, (asolv + 256) * sizeof(unsigned int)); + repo->rpmdbid = sat_realloc(repo->rpmdbid, (asolv + 256) * sizeof(unsigned int)); memset(repo->rpmdbid + asolv, 0, 256 * sizeof(unsigned int)); asolv += 256; } @@ -599,7 +599,7 @@ repo_add_rpmdb(Repo *repo, Repo *ref, const char *rootdir) exit(1); } if (data.size > rpmheadsize) - rpmhead = xrealloc(rpmhead, sizeof(*rpmhead) + data.size); + rpmhead = sat_realloc(rpmhead, sizeof(*rpmhead) + data.size); memcpy(buf, data.data, 8); rpmhead->cnt = buf[0] << 24 | buf[1] << 16 | buf[2] << 8 | buf[3]; rpmhead->dcnt = buf[4] << 24 | buf[5] << 16 | buf[6] << 8 | buf[7]; @@ -672,9 +672,9 @@ repo_add_rpmdb(Repo *repo, Repo *ref, const char *rootdir) else memcpy(dbidp, dp, 4); if ((nrpmids & 255) == 0) - rpmids = xrealloc(rpmids, sizeof(*rpmids) * (nrpmids + 256)); + rpmids = sat_realloc(rpmids, sizeof(*rpmids) * (nrpmids + 256)); rpmids[nrpmids].dbid = dbid; - rpmids[nrpmids].name = malloc((int)key.size + 1); + rpmids[nrpmids].name = sat_malloc((int)key.size + 1); memcpy(rpmids[nrpmids].name, key.data, (int)key.size); rpmids[nrpmids].name[(int)key.size] = 0; nrpmids++; @@ -696,7 +696,7 @@ repo_add_rpmdb(Repo *repo, Repo *ref, const char *rootdir) if (ref) { refmask = mkmask(ref->nsolvables); - refhash = xcalloc(refmask + 1, sizeof(Id)); + refhash = sat_calloc(refmask + 1, sizeof(Id)); for (i = 0; i < ref->nsolvables; i++) { h = ref->rpmdbid[i] & refmask; @@ -706,7 +706,7 @@ repo_add_rpmdb(Repo *repo, Repo *ref, const char *rootdir) } } - repo->rpmdbid = xcalloc(nrpmids, sizeof(unsigned int)); + repo->rpmdbid = sat_calloc(nrpmids, sizeof(unsigned int)); s = pool_id2solvable(pool, repo_add_solvable_block(repo, nrpmids)); @@ -799,7 +799,7 @@ repo_add_rpmdb(Repo *repo, Repo *ref, const char *rootdir) exit(1); } if (data.size > rpmheadsize) - rpmhead = xrealloc(rpmhead, sizeof(*rpmhead) + data.size); + rpmhead = sat_realloc(rpmhead, sizeof(*rpmhead) + data.size); memcpy(buf, data.data, 8); rpmhead->cnt = buf[0] << 24 | buf[1] << 16 | buf[2] << 8 | buf[3]; rpmhead->dcnt = buf[4] << 24 | buf[5] << 16 | buf[6] << 8 | buf[7]; @@ -815,16 +815,16 @@ repo_add_rpmdb(Repo *repo, Repo *ref, const char *rootdir) } if (refhash) - free(refhash); + sat_free(refhash); if (rpmids) { for (i = 0; i < nrpmids; i++) - free(rpmids[i].name); - free(rpmids); + sat_free(rpmids[i].name); + sat_free(rpmids); } } if (rpmhead) - free(rpmhead); + sat_free(rpmhead); if (db) db->close(db, 0); } diff --git a/tools/repo_rpmmd.c b/tools/repo_rpmmd.c index fa42a77..45b1481 100644 --- a/tools/repo_rpmmd.c +++ b/tools/repo_rpmmd.c @@ -139,7 +139,7 @@ makeevr_atts(Pool *pool, struct parsedata *pd, const char **atts) l += strlen(r) + 1; if (l > pd->acontent) { - pd->content = xrealloc(pd->content, l + 256); + pd->content = sat_realloc(pd->content, l + 256); pd->acontent = l + 256; } c = pd->content; @@ -207,7 +207,7 @@ adddep(Pool *pool, struct parsedata *pd, unsigned int olddeps, const char **atts int l = strlen(k) + 1 + strlen(n) + 1; if (l > pd->acontent) { - pd->content = xrealloc(pd->content, l + 256); + pd->content = sat_realloc(pd->content, l + 256); pd->acontent = l + 256; } sprintf(pd->content, "%s:%s", k, n); @@ -412,7 +412,7 @@ characterData(void *userData, const XML_Char *s, int len) l = pd->lcontent + len + 1; if (l > pd->acontent) { - pd->content = xrealloc(pd->content, l + 256); + pd->content = sat_realloc(pd->content, l + 256); pd->acontent = l + 256; } c = pd->content + pd->lcontent; @@ -443,7 +443,7 @@ repo_add_rpmmd(Repo *repo, FILE *fp) } pd.pool = pool; pd.repo = repo; - pd.content = malloc(256); + pd.content = sat_malloc(256); pd.acontent = 256; pd.lcontent = 0; XML_Parser parser = XML_ParserCreate(NULL); @@ -464,5 +464,5 @@ repo_add_rpmmd(Repo *repo, FILE *fp) XML_ParserFree(parser); if (pd.numpacks) repo_free_solvable_block(repo, pd.solvable - pool->solvables, pd.numpacks, 1); - free(pd.content); + sat_free(pd.content); } diff --git a/tools/repo_write.c b/tools/repo_write.c index 6cae428..4895aa8 100644 --- a/tools/repo_write.c +++ b/tools/repo_write.c @@ -350,7 +350,7 @@ addschema(struct schemata *schemata, Id *schema) if (len > schemata->schemadatafree) { int l = schemata->schemadatap - schemata->schemadata; - schemata->schemadata = xrealloc(schemata->schemadata, (schemata->schemadatap - schemata->schemadata + len + 256) * sizeof(Id)); + schemata->schemadata = sat_realloc(schemata->schemadata, (schemata->schemadatap - schemata->schemadata + len + 256) * sizeof(Id)); schemata->schemadatafree = len + 256; schemata->schemadatap = schemata->schemadata + l; if (l == 0) @@ -401,7 +401,7 @@ repo_write(Repo *repo, FILE *fp) nsolvables = 0; idarraydata = repo->idarraydata; - needid = (NeedId *)xcalloc(pool->ss.nstrings + pool->nrels, sizeof(*needid)); + needid = sat_calloc(pool->ss.nstrings + pool->nrels, sizeof(*needid)); memset(idsizes, 0, sizeof(idsizes)); repodataschema = repodataschema_internal = 0; @@ -513,7 +513,7 @@ repo_write(Repo *repo, FILE *fp) /* find the schemata we need */ memset(&schemata, 0, sizeof(schemata)); - solvschema = xcalloc(repo->nsolvables, sizeof(Id)); + solvschema = sat_calloc(repo->nsolvables, sizeof(Id)); for (i = repo->start, s = pool->solvables + i, n = 0; i < repo->end; i++, s++) { @@ -597,7 +597,7 @@ repo_write(Repo *repo, FILE *fp) that this actually is an expansion we can't easily reuse the stringspace for this. The max expansion per string is 1 byte, so it will fit into sizeid+nstrings bytes. */ - char *prefix = xmalloc (sizeid + nstrings); + char *prefix = sat_malloc (sizeid + nstrings); char *pp = prefix; char *old_str = ""; for (i = 1; i < nstrings; i++) @@ -625,7 +625,7 @@ repo_write(Repo *repo, FILE *fp) perror("write error"); exit(1); } - xfree (prefix); + sat_free (prefix); /* * write RelDeps @@ -734,9 +734,9 @@ repo_write(Repo *repo, FILE *fp) write_u32(fp, repo->rpmdbid[i - repo->start]); } - xfree(needid); - xfree(solvschema); - xfree(schemata.schemadata); + sat_free(needid); + sat_free(solvschema); + sat_free(schemata.schemadata); } // EOF |