* Fix some coding style issues

* Stumbled upon a possible bug while trying to understand the reuse of large
  allocations. The "first" variable was always set to the current index at the
  end of the loop, even if it was already set. This should have caused that
  the success condition to never be reached.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23866 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Lotz
2008-02-04 21:53:57 +00:00
parent bd6a90a7e2
commit 9a2cc3ad3f
+6 -7
View File
@@ -469,25 +469,24 @@ memalign(size_t alignment, size_t size)
if (size < (heap_base_ptr - heap_base) / 10) { // but don't try too hard
int first = -1;
page = heap_alloc_table;
for (i = 0; i < (heap_base_ptr-heap_base)/B_PAGE_SIZE; i++) {
for (i = 0; i < (heap_base_ptr - heap_base) / B_PAGE_SIZE; i++) {
if (page[i].in_use) {
first = -1;
continue;
}
if (first > 0) {
if ((1 + i - first)*B_PAGE_SIZE > size)
if ((1 + i - first) * B_PAGE_SIZE > size)
break;
}
first = i;
} else
first = i;
}
if (first > -1)
address = (void *)(heap_base + first * B_PAGE_SIZE);
}
if (address == NULL)
address = raw_alloc(size, bin_index);
page = &heap_alloc_table[((unsigned int)address - heap_base) / B_PAGE_SIZE];
for (i = 0; i < (size+B_PAGE_SIZE-1)/B_PAGE_SIZE; i++) {
for (i = 0; i < (size + B_PAGE_SIZE - 1) / B_PAGE_SIZE; i++) {
page[i].in_use = 1;
page[i].cleaning = 0;
page[i].bin_index = bin_count;
@@ -640,7 +639,7 @@ free(void *address)
// free this allocation anymore... (tracking them would
// require some extra stuff)
for (i = 1; i <= (heap_base_ptr-heap_base)/B_PAGE_SIZE; i++) {
for (i = 1; i <= (heap_base_ptr - heap_base) / B_PAGE_SIZE; i++) {
if (!page[i].in_use)
break;
if (page[i].bin_index != bin_count)