summaryrefslogtreecommitdiff
path: root/cesar
diff options
context:
space:
mode:
authorNélio Laranjeiro2011-02-02 17:33:38 +0100
committerNélio Laranjeiro2011-02-02 17:33:38 +0100
commit1e44da2511e5d5d8ea61e7d279138b566e54f373 (patch)
tree0ecc5940e05303a2f3600b4672e4ff62e31588dd /cesar
parent41983c772d41a2e73f058facf046f9bae4ac75ac (diff)
cesar/lib/blk: change blk_slack return, refs #2278
blk_slack return the number of block which can be allocated.
Diffstat (limited to 'cesar')
-rw-r--r--cesar/lib/blk.h4
-rw-r--r--cesar/lib/src/blk.c7
-rw-r--r--cesar/lib/test/blk/src/test_blk.c6
3 files changed, 10 insertions, 7 deletions
diff --git a/cesar/lib/blk.h b/cesar/lib/blk.h
index 3e207d7417..44277badca 100644
--- a/cesar/lib/blk.h
+++ b/cesar/lib/blk.h
@@ -220,7 +220,7 @@ blk_print_memory (void);
/**
* Querry blk when a huge number of blocks are needed.
- * \return true if possible, false otherwise.
+ * \return number of free blocks which could be allocated, 0 otherwise.
*
* Each time a numerous quantity of blocks are needed to handle a stuff, this
* function should be called. When the number of blocks reach a critical level
@@ -232,7 +232,7 @@ blk_print_memory (void);
* file. X is the minimum number of blocks under the one, the memory level
* is considered as critical.
*/
-bool
+uint
blk_slack (void);
END_DECLS
diff --git a/cesar/lib/src/blk.c b/cesar/lib/src/blk.c
index 520f4b6cd8..40b652ca51 100644
--- a/cesar/lib/src/blk.c
+++ b/cesar/lib/src/blk.c
@@ -399,8 +399,11 @@ blk_print_memory (void)
blk_global.total_nb, blk_global.free_nb);
}
-bool
+uint
blk_slack (void)
{
- return blk_global.free_nb > CONFIG_BLK_SLACK;
+ if (blk_global.free_nb > CONFIG_BLK_SLACK)
+ return blk_global.free_nb - CONFIG_BLK_SLACK;
+ else
+ return 0;
}
diff --git a/cesar/lib/test/blk/src/test_blk.c b/cesar/lib/test/blk/src/test_blk.c
index 8a5ce1d8bb..58ca0b6445 100644
--- a/cesar/lib/test/blk/src/test_blk.c
+++ b/cesar/lib/test/blk/src/test_blk.c
@@ -295,13 +295,13 @@ blk_slack_test_case (test_t t)
uint i;
for (i = 0; i < CONFIG_BLK_NB - CONFIG_BLK_SLACK; i++)
{
- test_fail_unless (blk_slack () == true);
+ test_fail_unless (blk_slack ());
b[i] = blk_alloc ();
}
- test_fail_unless (blk_slack () == false);
+ test_fail_unless (!blk_slack ());
blk_release (b[CONFIG_BLK_NB - CONFIG_BLK_SLACK - 1]);
- test_fail_unless (blk_slack () == true);
+ test_fail_unless (blk_slack ());
for (i = 0; i < CONFIG_BLK_NB - CONFIG_BLK_SLACK - 1; i++)
blk_release (b[i]);