am 04fdd180: Merge "fix [2542425] memory leak during video recording" into froyo
Merge commit '04fdd180cc64f2724c8b8598f1b8495fb1fa1d93' into froyo-plus-aosp * commit '04fdd180cc64f2724c8b8598f1b8495fb1fa1d93': fix [2542425] memory leak during video recording
This commit is contained in:
@@ -173,9 +173,10 @@ status_t VectorImpl::sort(VectorImpl::compar_r_t cmp, void* state)
|
|||||||
if (!array) return NO_MEMORY;
|
if (!array) return NO_MEMORY;
|
||||||
temp = malloc(mItemSize);
|
temp = malloc(mItemSize);
|
||||||
if (!temp) return NO_MEMORY;
|
if (!temp) return NO_MEMORY;
|
||||||
_do_construct(temp, 1);
|
|
||||||
item = reinterpret_cast<char*>(array) + mItemSize*(i);
|
item = reinterpret_cast<char*>(array) + mItemSize*(i);
|
||||||
curr = reinterpret_cast<char*>(array) + mItemSize*(i-1);
|
curr = reinterpret_cast<char*>(array) + mItemSize*(i-1);
|
||||||
|
} else {
|
||||||
|
_do_destroy(temp, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
_do_copy(temp, item, 1);
|
_do_copy(temp, item, 1);
|
||||||
@@ -183,12 +184,14 @@ status_t VectorImpl::sort(VectorImpl::compar_r_t cmp, void* state)
|
|||||||
ssize_t j = i-1;
|
ssize_t j = i-1;
|
||||||
void* next = reinterpret_cast<char*>(array) + mItemSize*(i);
|
void* next = reinterpret_cast<char*>(array) + mItemSize*(i);
|
||||||
do {
|
do {
|
||||||
|
_do_destroy(next, 1);
|
||||||
_do_copy(next, curr, 1);
|
_do_copy(next, curr, 1);
|
||||||
next = curr;
|
next = curr;
|
||||||
--j;
|
--j;
|
||||||
curr = reinterpret_cast<char*>(array) + mItemSize*(j);
|
curr = reinterpret_cast<char*>(array) + mItemSize*(j);
|
||||||
} while (j>=0 && (cmp(curr, temp, state) > 0));
|
} while (j>=0 && (cmp(curr, temp, state) > 0));
|
||||||
|
|
||||||
|
_do_destroy(next, 1);
|
||||||
_do_copy(next, temp, 1);
|
_do_copy(next, temp, 1);
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
|
|||||||
Reference in New Issue
Block a user