diff options
| author | David S. Miller <davem@davemloft.net> | 2010-09-09 02:49:04 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2010-09-09 02:49:04 -0400 |
| commit | e199e6136ce6b151e6638ae93dca60748424d900 (patch) | |
| tree | 0d66e0b5d227c36b005e4f5537f4bbcfc6ed4904 /lib/flex_array.c | |
| parent | 972c40b5bee429c84ba727f8ac0a08292bc5dc3d (diff) | |
| parent | d56557af19867edb8c0e96f8e26399698a08857f (diff) | |
Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/torvalds/linux-2.6
Diffstat (limited to 'lib/flex_array.c')
| -rw-r--r-- | lib/flex_array.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/lib/flex_array.c b/lib/flex_array.c index 41b1804fa728..77a6fea7481e 100644 --- a/lib/flex_array.c +++ b/lib/flex_array.c | |||
| @@ -171,6 +171,8 @@ __fa_get_part(struct flex_array *fa, int part_nr, gfp_t flags) | |||
| 171 | * Note that this *copies* the contents of @src into | 171 | * Note that this *copies* the contents of @src into |
| 172 | * the array. If you are trying to store an array of | 172 | * the array. If you are trying to store an array of |
| 173 | * pointers, make sure to pass in &ptr instead of ptr. | 173 | * pointers, make sure to pass in &ptr instead of ptr. |
| 174 | * You may instead wish to use the flex_array_put_ptr() | ||
| 175 | * helper function. | ||
| 174 | * | 176 | * |
| 175 | * Locking must be provided by the caller. | 177 | * Locking must be provided by the caller. |
| 176 | */ | 178 | */ |
| @@ -265,7 +267,8 @@ int flex_array_prealloc(struct flex_array *fa, unsigned int start, | |||
| 265 | * | 267 | * |
| 266 | * Returns a pointer to the data at index @element_nr. Note | 268 | * Returns a pointer to the data at index @element_nr. Note |
| 267 | * that this is a copy of the data that was passed in. If you | 269 | * that this is a copy of the data that was passed in. If you |
| 268 | * are using this to store pointers, you'll get back &ptr. | 270 | * are using this to store pointers, you'll get back &ptr. You |
| 271 | * may instead wish to use the flex_array_get_ptr helper. | ||
| 269 | * | 272 | * |
| 270 | * Locking must be provided by the caller. | 273 | * Locking must be provided by the caller. |
| 271 | */ | 274 | */ |
| @@ -286,6 +289,26 @@ void *flex_array_get(struct flex_array *fa, unsigned int element_nr) | |||
| 286 | return &part->elements[index_inside_part(fa, element_nr)]; | 289 | return &part->elements[index_inside_part(fa, element_nr)]; |
| 287 | } | 290 | } |
| 288 | 291 | ||
| 292 | /** | ||
| 293 | * flex_array_get_ptr - pull a ptr back out of the array | ||
| 294 | * @fa: the flex array from which to extract data | ||
| 295 | * @element_nr: index of the element to fetch from the array | ||
| 296 | * | ||
| 297 | * Returns the pointer placed in the flex array at element_nr using | ||
| 298 | * flex_array_put_ptr(). This function should not be called if the | ||
| 299 | * element in question was not set using the _put_ptr() helper. | ||
| 300 | */ | ||
| 301 | void *flex_array_get_ptr(struct flex_array *fa, unsigned int element_nr) | ||
| 302 | { | ||
| 303 | void **tmp; | ||
| 304 | |||
| 305 | tmp = flex_array_get(fa, element_nr); | ||
| 306 | if (!tmp) | ||
| 307 | return NULL; | ||
| 308 | |||
| 309 | return *tmp; | ||
| 310 | } | ||
| 311 | |||
| 289 | static int part_is_free(struct flex_array_part *part) | 312 | static int part_is_free(struct flex_array_part *part) |
| 290 | { | 313 | { |
| 291 | int i; | 314 | int i; |
