From a65ad4efc1102449a087b464d3b8d4670a614b99 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Tue, 14 Aug 2007 10:14:35 -0400 Subject: package.h: implement origin_data union in pmpkg_t struct We were using a void *data element in pmpkg_t before, which is unsafe by its nature of being untyped. Reimplement data as origin_data being a union that can hold either a path to a package file or a pointer to a cache database, and make the other necesary updates in the code to reflect this. See package.h for details. Signed-off-by: Dan McGee --- lib/libalpm/package.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'lib/libalpm/package.h') diff --git a/lib/libalpm/package.h b/lib/libalpm/package.h index 41ab5f0d..1d3daafa 100644 --- a/lib/libalpm/package.h +++ b/lib/libalpm/package.h @@ -78,15 +78,14 @@ struct __pmpkg_t { alpm_list_t *provides; /* internal */ pmpkgfrom_t origin; - void *data; - /* TODO replace 'data' with this: + /* Replaced 'void *data' with this union as follows: origin == PKG_FROM_CACHE, use pkg->origin_data.db - origin == PKG_FROM_FILE, use pkg->origin_data.fd + origin == PKG_FROM_FILE, use pkg->origin_data.file + */ union { - int fd; pmdb_t *db; + char *file; } origin_data; - */ pmdbinfrq_t infolevel; }; -- cgit v1.2.3-54-g00ecf