projects
/
ccan
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(from parent 1:
bd294f1
)
alloc: fix bug in tiny allocator
author
Rusty Russell
<rusty@rustcorp.com.au>
Thu, 15 Jul 2010 08:40:47 +0000
(18:10 +0930)
committer
Rusty Russell
<rusty@rustcorp.com.au>
Thu, 15 Jul 2010 08:40:47 +0000
(18:10 +0930)
We can have a 0 byte in the *middle* of an encoding.
ccan/alloc/tiny.c
patch
|
blob
|
history
diff --git
a/ccan/alloc/tiny.c
b/ccan/alloc/tiny.c
index b965eb471b329f9ff4108513f0cf10a6796c8928..feffa618e0cf629d9edc1822ed89d70ba8dde290 100755
(executable)
--- a/
ccan/alloc/tiny.c
+++ b/
ccan/alloc/tiny.c
@@
-152,13
+152,13
@@
static bool long_enough(unsigned long offset, unsigned long len,
static unsigned long find_free_end(unsigned char *arr, unsigned long arrsize)
{
-
unsigned long end
;
+
long i
;
- for (
end = 0; end < arrsize; end++
) {
- if (
!arr[end
])
-
break
;
+ for (
i = arrsize-1; i >= 0; i--
) {
+ if (
arr[i
])
+
return i + 1
;
}
- return
end
;
+ return
0
;
}
void *tiny_alloc_get(void *pool, unsigned long poolsize,