summaryrefslogtreecommitdiff
path: root/src/package.c
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2017-06-21 16:07:58 +0300
committerTimo Teräs <timo.teras@iki.fi>2017-06-23 10:07:44 +0300
commit4d9c0c39b033159f4bd6fe279dd38d4f4a67c904 (patch)
treeb316100ea8a03be653c8cb0c729577c24ebcae14 /src/package.c
parentca9d476ba39d75b9a197f9ae30e5efe2ebafaf3c (diff)
downloadapk-tools-4d9c0c39b033159f4bd6fe279dd38d4f4a67c904.tar.gz
apk-tools-4d9c0c39b033159f4bd6fe279dd38d4f4a67c904.tar.bz2
apk-tools-4d9c0c39b033159f4bd6fe279dd38d4f4a67c904.tar.xz
apk-tools-4d9c0c39b033159f4bd6fe279dd38d4f4a67c904.zip
io: make io vtables const struct, and add accessors for them
This reduces function pointers in heap, and unifies how the io functions are called.
Diffstat (limited to 'src/package.c')
-rw-r--r--src/package.c23
1 files changed, 8 insertions, 15 deletions
diff --git a/src/package.c b/src/package.c
index 0bb3747..4582b10 100644
--- a/src/package.c
+++ b/src/package.c
@@ -434,7 +434,7 @@ int apk_deps_write(struct apk_database *db, struct apk_dependency_array *deps, s
blob = apk_blob_pushed(APK_BLOB_BUF(tmp), blob);
if (APK_BLOB_IS_NULL(blob) ||
- os->write(os, blob.ptr, blob.len) != blob.len)
+ apk_ostream_write(os, blob.ptr, blob.len) != blob.len)
return -1;
n += blob.len;
@@ -930,7 +930,7 @@ int apk_pkg_read(struct apk_database *db, const char *file,
tar = apk_bstream_gunzip_mpart(bs, apk_sign_ctx_mpart_cb, sctx);
r = apk_tar_parse(tar, read_info_entry, &ctx, FALSE, &db->id_cache);
- tar->close(tar);
+ apk_istream_close(tar);
if (r < 0 && r != -ECANCELED)
goto err;
if (ctx.pkg->name == NULL || ctx.pkg->uninstallable) {
@@ -979,7 +979,7 @@ int apk_ipkg_add_script(struct apk_installed_package *ipkg,
return -1;
ptr = malloc(size);
- r = is->read(is, ptr, size);
+ r = apk_istream_read(is, ptr, size);
if (r < 0) {
free(ptr);
return r;
@@ -1073,17 +1073,10 @@ static int write_depends(struct apk_ostream *os, const char *field,
{
int r;
- if (deps->num == 0)
- return 0;
-
- if (os->write(os, field, 2) != 2)
- return -1;
- r = apk_deps_write(NULL, deps, os, APK_BLOB_PTR_LEN(" ", 1));
- if (r < 0)
- return r;
- if (os->write(os, "\n", 1) != 1)
- return -1;
-
+ if (deps->num == 0) return 0;
+ if (apk_ostream_write(os, field, 2) != 2) return -1;
+ if ((r = apk_deps_write(NULL, deps, os, APK_BLOB_PTR_LEN(" ", 1))) < 0) return r;
+ if (apk_ostream_write(os, "\n", 1) != 1) return -1;
return 0;
}
@@ -1138,7 +1131,7 @@ int apk_pkg_write_index_entry(struct apk_package *info,
}
bbuf = apk_blob_pushed(APK_BLOB_BUF(buf), bbuf);
- if (os->write(os, bbuf.ptr, bbuf.len) != bbuf.len ||
+ if (apk_ostream_write(os, bbuf.ptr, bbuf.len) != bbuf.len ||
write_depends(os, "D:", info->depends) ||
write_depends(os, "p:", info->provides) ||
write_depends(os, "i:", info->install_if))