Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 250804
b: refs/heads/master
c: 150cdf6
h: refs/heads/master
v: v3
  • Loading branch information
Eric Paris committed Apr 28, 2011
1 parent 1ea9588 commit b905ccf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 5a3ea8782c63d3501cb764c176f153c0d9a400e1
refs/heads/master: 150cdf6ec0ede8d9f102f1817212447727dcf08c
11 changes: 10 additions & 1 deletion trunk/lib/flex_array.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,16 @@ int flex_array_prealloc(struct flex_array *fa, unsigned int start,
unsigned int end;
struct flex_array_part *part;

if (!start && !nr_elements)
return 0;
if (start >= fa->total_nr_elements)
return -ENOSPC;
if (!nr_elements)
return 0;

end = start + nr_elements - 1;

if (start >= fa->total_nr_elements || end >= fa->total_nr_elements)
if (end >= fa->total_nr_elements)
return -ENOSPC;
if (elements_fit_in_base(fa))
return 0;
Expand Down Expand Up @@ -346,6 +353,8 @@ int flex_array_shrink(struct flex_array *fa)
int part_nr;
int ret = 0;

if (!fa->total_nr_elements)
return 0;
if (elements_fit_in_base(fa))
return ret;
for (part_nr = 0; part_nr < FLEX_ARRAY_NR_BASE_PTRS; part_nr++) {
Expand Down

0 comments on commit b905ccf

Please sign in to comment.