From 132529d5b43b3d12c78a07974929d0c3c4f2a6b8 Mon Sep 17 00:00:00 2001 From: Igor Gnatenko Date: Wed, 27 Jun 2018 18:27:07 +0200 Subject: [PATCH] add pool_solvable2id() Signed-off-by: Igor Gnatenko --- doc/gen/libsolv-pool.3 | 14 +++++++++++++- doc/libsolv-pool.txt | 4 ++++ src/pool.h | 4 ++++ 3 files changed, 21 insertions(+), 1 deletion(-) 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) -- 2.47.2