diff options
author | Christian Grothoff <christian@grothoff.org> | 2021-09-01 11:11:41 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2021-09-01 11:11:41 +0200 |
commit | bf2ce9853e640384106f4dd7c242ea1e5e440871 (patch) | |
tree | 51f5feae3e85ae11a89d77f32c499bba198b447e | |
parent | 896bb8f074d6b6e091ee79de93b8bec118caa3ca (diff) | |
download | exchange-bf2ce9853e640384106f4dd7c242ea1e5e440871.tar.gz exchange-bf2ce9853e640384106f4dd7c242ea1e5e440871.zip |
add long-time overdue convenience function
-rw-r--r-- | src/include/taler_amount_lib.h | 11 | ||||
-rw-r--r-- | src/util/amount.c | 12 |
2 files changed, 23 insertions, 0 deletions
diff --git a/src/include/taler_amount_lib.h b/src/include/taler_amount_lib.h index a1f6c7d35..c1f42e473 100644 --- a/src/include/taler_amount_lib.h +++ b/src/include/taler_amount_lib.h | |||
@@ -161,6 +161,17 @@ TALER_amount_set_zero (const char *cur, | |||
161 | 161 | ||
162 | 162 | ||
163 | /** | 163 | /** |
164 | * Test if the given @a amount is zero. | ||
165 | * | ||
166 | * @param amount amount to compare to zero | ||
167 | * @return true if the amount is zero, | ||
168 | * false if it is non-zero or invalid | ||
169 | */ | ||
170 | bool | ||
171 | TALER_amount_is_zero (const struct TALER_Amount *amount); | ||
172 | |||
173 | |||
174 | /** | ||
164 | * Test if the given amount is valid. | 175 | * Test if the given amount is valid. |
165 | * | 176 | * |
166 | * @param amount amount to check | 177 | * @param amount amount to check |
diff --git a/src/util/amount.c b/src/util/amount.c index 01f2a2313..ae9ae652e 100644 --- a/src/util/amount.c +++ b/src/util/amount.c | |||
@@ -241,6 +241,18 @@ TALER_amount_is_valid (const struct TALER_Amount *amount) | |||
241 | } | 241 | } |
242 | 242 | ||
243 | 243 | ||
244 | bool | ||
245 | TALER_amount_is_zero (const struct TALER_Amount *amount) | ||
246 | { | ||
247 | if (GNUNET_OK != | ||
248 | TALER_amount_is_valid (amount)) | ||
249 | return false; | ||
250 | return | ||
251 | (0 == amount->value) && | ||
252 | (0 == amount->fraction); | ||
253 | } | ||
254 | |||
255 | |||
244 | /** | 256 | /** |
245 | * Test if @a a is valid, NBO variant. | 257 | * Test if @a a is valid, NBO variant. |
246 | * | 258 | * |