From 4d9c0c39b033159f4bd6fe279dd38d4f4a67c904 Mon Sep 17 00:00:00 2001 From: Timo Teräs Date: Wed, 21 Jun 2017 16:07:58 +0300 Subject: 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. --- src/package.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) (limited to 'src/package.c') 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)) -- cgit v1.2.3-60-g2f50