Tracked down issue with previous commit. For some reason, modifying the passed in parameter's value directly results in a segfault in registrar, and I cannot see why. Thoughts?
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25920 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -34,7 +34,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <syslog.h>
|
||||||
|
|
||||||
// helper function
|
// helper function
|
||||||
static inline
|
static inline
|
||||||
@@ -174,7 +174,7 @@ BList::RemoveItem(int32 index)
|
|||||||
if (index >= 0 && index < fItemCount) {
|
if (index >= 0 && index < fItemCount) {
|
||||||
item = fObjectList[index];
|
item = fObjectList[index];
|
||||||
move_items(fObjectList + index + 1, -1, fItemCount - index - 1);
|
move_items(fObjectList + index + 1, -1, fItemCount - index - 1);
|
||||||
Resize(fItemCount - 1);
|
Resize(fItemCount - 1);
|
||||||
}
|
}
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
@@ -434,10 +434,20 @@ BList::Resize(int32 count)
|
|||||||
{
|
{
|
||||||
bool result = true;
|
bool result = true;
|
||||||
// calculate the new physical size
|
// calculate the new physical size
|
||||||
int32 newSize = count;
|
// by doubling the existing size
|
||||||
if (newSize <= 0)
|
// until we can hold at least count items
|
||||||
newSize = 1;
|
int32 newSize = fBlockSize;
|
||||||
newSize = ((newSize - 1) / fBlockSize + 1) * fBlockSize;
|
// TODO: determine why modifying count directly via
|
||||||
|
// if (count <= 0) count = fBlockSize;
|
||||||
|
// results in this code segfaulting the registrar while using the local var 'c' does not.
|
||||||
|
int32 c = count;
|
||||||
|
if (c <= 0)
|
||||||
|
c = fBlockSize;
|
||||||
|
if ((size_t)c != fPhysicalSize) {
|
||||||
|
while (newSize < c)
|
||||||
|
newSize <<= 1;
|
||||||
|
}
|
||||||
|
|
||||||
// resize if necessary
|
// resize if necessary
|
||||||
if ((size_t)newSize != fPhysicalSize) {
|
if ((size_t)newSize != fPhysicalSize) {
|
||||||
void** newObjectList
|
void** newObjectList
|
||||||
|
|||||||
Reference in New Issue
Block a user