aboutsummaryrefslogtreecommitdiffstats
path: root/src/url.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/url.c
parentca9d476ba39d75b9a197f9ae30e5efe2ebafaf3c (diff)
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/url.c')
-rw-r--r--src/url.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/url.c b/src/url.c
index 711755a..4d7c7e6 100644
--- a/src/url.c
+++ b/src/url.c
@@ -102,6 +102,12 @@ static void fetch_close(void *stream)
free(fis);
}
+static const struct apk_istream_ops fetch_istream_ops = {
+ .get_meta = fetch_get_meta,
+ .read = fetch_read,
+ .close = fetch_close,
+};
+
static struct apk_istream *apk_istream_fetch(const char *url, time_t since)
{
struct apk_fetch_istream *fis;
@@ -121,9 +127,7 @@ static struct apk_istream *apk_istream_fetch(const char *url, time_t since)
}
*fis = (struct apk_fetch_istream) {
- .is.get_meta = fetch_get_meta,
- .is.read = fetch_read,
- .is.close = fetch_close,
+ .is.ops = &fetch_istream_ops,
.fetchIO = io,
.urlstat = fis->urlstat,
};