Skip to content

Commit 57360f1

Browse files
committedJun 27, 2013
Merge branch 'google'
2 parents 7085cf7 + 4b68a74 commit 57360f1

File tree

1 file changed

+13
-25
lines changed

1 file changed

+13
-25
lines changed
 

‎jni/CursorWindow.cpp

+13-25
Original file line numberDiff line numberDiff line change
@@ -58,35 +58,23 @@ LOG_WINDOW("Created CursorWindow from existing IMemory: mFreeOffset = %d, numRow
5858

5959
bool CursorWindow::initBuffer(bool localOnly)
6060
{
61-
//TODO Use a non-memory dealer mmap region for localOnly
62-
63-
android::sp<android::MemoryHeapBase> heap;
64-
heap = new android::MemoryHeapBase(mMaxSize, 0, "CursorWindow");
65-
if (heap != NULL) {
66-
mMemory = new android::MemoryBase(heap, 0, mMaxSize);
67-
if (mMemory != NULL) {
68-
mData = (uint8_t *) mMemory->pointer();
69-
if (mData) {
70-
mHeader = (window_header_t *) mData;
71-
mSize = mMaxSize;
72-
73-
// Put the window into a clean state
74-
clear();
75-
LOG_WINDOW("Created CursorWindow with new MemoryDealer: mFreeOffset = %d, mSize = %d, mMaxSize = %d, mData = %p", mFreeOffset, mSize, mMaxSize, mData);
76-
return true;
77-
}
78-
}
79-
LOGE("CursorWindow heap allocation failed");
80-
return false;
81-
} else {
82-
LOGE("failed to create the CursorWindow heap");
83-
return false;
84-
}
61+
void* data = malloc(mMaxSize);
62+
if(data){
63+
mData = (uint8_t *) data;
64+
mHeader = (window_header_t *) mData;
65+
mSize = mMaxSize;
66+
clear();
67+
LOG_WINDOW("Created CursorWindow with new MemoryDealer: mFreeOffset = %d, mSize = %d, mMaxSize = %d, mData = %p", mFreeOffset, mSize, mMaxSize, mData);
68+
return true;
69+
}
70+
return false;
8571
}
8672

8773
CursorWindow::~CursorWindow()
8874
{
89-
// Everything that matters is a smart pointer
75+
if(mData){
76+
free(mData);
77+
}
9078
}
9179

9280
void CursorWindow::clear()

0 commit comments

Comments
 (0)