summaryrefslogtreecommitdiff
path: root/lib/header.c
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2011-11-30 09:37:49 +0200
committerPanu Matilainen <pmatilai@redhat.com>2011-11-30 11:03:17 +0200
commit359baa2831dd1850cba3a1cc8d31aebf883a5138 (patch)
treed3e854b5fb411d7c0d982c1194fb3a8549690c3d /lib/header.c
parente83aa4f63817620633f5079064283cc9c3320e3f (diff)
downloadlibrpm-tizen-359baa2831dd1850cba3a1cc8d31aebf883a5138.tar.gz
librpm-tizen-359baa2831dd1850cba3a1cc8d31aebf883a5138.tar.bz2
librpm-tizen-359baa2831dd1850cba3a1cc8d31aebf883a5138.zip
Add an enhanced interface for unloading, aka exporting, headers
- Most callers need the size of the blob as well, which the unloader internals know perfectly well but the interface doesn't support passing it. So callers were forced to make a second call to headerSizeof() to recalculate the size. Duh. - Rename and export doHeaderUnload() as headerExport(), update internal callers to use the new name. headerExport() is hopefully a bit more obvious as a name than headerUnload() which doesn't actually undo the effect of headerLoad() for that header, but merely exports the data by serializing into on-disk format. - Header size is not size_t really, its capped to fixed much lower size. Use unsigned int to better match reality.
Diffstat (limited to 'lib/header.c')
-rw-r--r--lib/header.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/lib/header.c b/lib/header.c
index 403084bad..a0b392ae6 100644
--- a/lib/header.c
+++ b/lib/header.c
@@ -461,13 +461,7 @@ static int regionSwab(indexEntry entry, int il, int dl,
return dl;
}
-/** \ingroup header
- * doHeaderUnload.
- * @param h header
- * @retval *lengthPtr no. bytes in unloaded header blob
- * @return unloaded header blob (NULL on error)
- */
-static void * doHeaderUnload(Header h, size_t * lengthPtr)
+void * headerExport(Header h, unsigned int *bsize)
{
int32_t * ei = NULL;
entryInfo pe;
@@ -677,8 +671,8 @@ static void * doHeaderUnload(Header h, size_t * lengthPtr)
if ((((char *)ei)+len) != te)
goto errxit;
- if (lengthPtr)
- *lengthPtr = len;
+ if (bsize)
+ *bsize = len;
headerSort(h);
@@ -691,7 +685,7 @@ errxit:
void * headerUnload(Header h)
{
- return doHeaderUnload(h, NULL);
+ return headerExport(h, NULL);
}
/**
@@ -908,8 +902,8 @@ errxit:
Header headerReload(Header h, rpmTagVal tag)
{
Header nh;
- size_t uc = 0;
- void * uh = doHeaderUnload(h, &uc);
+ unsigned int uc = 0;
+ void * uh = headerExport(h, &uc);
h = headerFree(h);
if (uh == NULL)
@@ -993,10 +987,10 @@ exit:
int headerWrite(FD_t fd, Header h, int magicp)
{
ssize_t nb;
- size_t length;
+ unsigned int length;
void * uh;
- uh = doHeaderUnload(h, &length);
+ uh = headerExport(h, &length);
if (uh == NULL)
return 1;
switch (magicp) {