From: Igor Gnatenko Date: Wed, 27 Jun 2018 16:27:07 +0000 (+0200) Subject: add pool_solvable2id() X-Git-Tag: 0.6.35~42^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F274%2Fhead;p=thirdparty%2Flibsolv.git add pool_solvable2id() Signed-off-by: Igor Gnatenko --- diff --git a/doc/gen/libsolv-pool.3 b/doc/gen/libsolv-pool.3 index ffb8e56c..c0e14278 100644 --- a/doc/gen/libsolv-pool.3 +++ b/doc/gen/libsolv-pool.3 @@ -7,7 +7,7 @@ .\" Source: libsolv .\" Language: English .\" -.TH "LIBSOLV\-POOL" "3" "01/18/2018" "libsolv" "LIBSOLV" +.TH "LIBSOLV\-POOL" "3" "06/27/2018" "libsolv" "LIBSOLV" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -764,6 +764,18 @@ Convert a solvable Id into a pointer to the solvable data\&. Note that the point .RS 4 .\} .nf +\fBId pool_solvable2id(const Pool *\fR\fIpool\fR\fB, Solvable *\fR\fIs\fR\fB)\fR; +.fi +.if n \{\ +.RE +.\} +.sp +Convert a pointer to the solvable data into a solvable Id\&. +.sp +.if n \{\ +.RS 4 +.\} +.nf \fBconst char *pool_solvid2str(Pool *\fR\fIpool\fR\fB, Id\fR \fIp\fR\fB)\fR; .fi .if n \{\ diff --git a/doc/libsolv-pool.txt b/doc/libsolv-pool.txt index 60147207..0b9bc411 100644 --- a/doc/libsolv-pool.txt +++ b/doc/libsolv-pool.txt @@ -499,6 +499,10 @@ Convert a solvable Id into a pointer to the solvable data. Note that the pointer may become invalid if new solvables are created or old solvables deleted, because the array storing all solvables may get reallocated. + Id pool_solvable2id(const Pool *pool, Solvable *s); + +Convert a pointer to the solvable data into a solvable Id. + const char *pool_solvid2str(Pool *pool, Id p); Return a string representing the solvable with the Id _p_. The string will diff --git a/src/pool.h b/src/pool.h index f6573af3..378051b4 100644 --- a/src/pool.h +++ b/src/pool.h @@ -282,6 +282,10 @@ static inline Solvable *pool_id2solvable(const Pool *pool, Id p) { return pool->solvables + p; } +static inline Id pool_solvable2id(const Pool *pool, Solvable *s) +{ + return s - pool->solvables; +} extern const char *pool_solvable2str(Pool *pool, Solvable *s); static inline const char *pool_solvid2str(Pool *pool, Id p)