summaryrefslogtreecommitdiff
path: root/support
diff options
context:
space:
mode:
authorYang Ni <yangni@google.com>2016-04-01 16:26:36 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2016-04-01 16:26:36 +0000
commit17c0109763c504c15876b1e9096444c539326099 (patch)
tree4585a80e693c29c717f22c867c5a1774fe5e957c /support
parent2d69d1633da4f6e03801f8e7ca0414ac7dc7b746 (diff)
parente5125574a68ee6283c300732a11662d8f9945624 (diff)
downloadrs-17c0109763c504c15876b1e9096444c539326099.tar.gz
Merge "Removed unused variables"
Diffstat (limited to 'support')
-rw-r--r--support/jni/android_renderscript_RenderScript.cpp62
1 files changed, 37 insertions, 25 deletions
diff --git a/support/jni/android_renderscript_RenderScript.cpp b/support/jni/android_renderscript_RenderScript.cpp
index f8c178c3..fcb4289c 100644
--- a/support/jni/android_renderscript_RenderScript.cpp
+++ b/support/jni/android_renderscript_RenderScript.cpp
@@ -399,31 +399,44 @@ nClosureCreate(JNIEnv *_env, jobject _this, jlong con, jlong kernelID,
goto exit;
}
- fieldIDs = (RsScriptFieldID*)alloca(sizeof(RsScriptFieldID) * numValues);
- if (fieldIDs == nullptr) {
- goto exit;
+ if (numValues > 0) {
+ fieldIDs = (RsScriptFieldID*)alloca(sizeof(RsScriptFieldID) * numValues);
+ if (fieldIDs == nullptr) {
+ goto exit;
+ }
+ } else {
+ // numValues == 0
+ // alloca(0) implementation is platform dependent
+ fieldIDs = nullptr;
}
for (size_t i = 0; i < numValues; i++) {
fieldIDs[i] = (RsScriptFieldID)jFieldIDs[i];
}
- depClosures = (RsClosure*)alloca(sizeof(RsClosure) * numDependencies);
- if (depClosures == nullptr) {
- goto exit;
- }
-
- for (size_t i = 0; i < numDependencies; i++) {
- depClosures[i] = (RsClosure)jDepClosures[i];
- }
-
- depFieldIDs = (RsScriptFieldID*)alloca(sizeof(RsScriptFieldID) * numDependencies);
- if (depFieldIDs == nullptr) {
- goto exit;
- }
-
- for (size_t i = 0; i < numDependencies; i++) {
- depFieldIDs[i] = (RsClosure)jDepFieldIDs[i];
+ if (numDependencies > 0) {
+ depClosures = (RsClosure*)alloca(sizeof(RsClosure) * numDependencies);
+ if (depClosures == nullptr) {
+ goto exit;
+ }
+
+ for (size_t i = 0; i < numDependencies; i++) {
+ depClosures[i] = (RsClosure)jDepClosures[i];
+ }
+
+ depFieldIDs = (RsScriptFieldID*)alloca(sizeof(RsScriptFieldID) * numDependencies);
+ if (depFieldIDs == nullptr) {
+ goto exit;
+ }
+
+ for (size_t i = 0; i < numDependencies; i++) {
+ depFieldIDs[i] = (RsClosure)jDepFieldIDs[i];
+ }
+ } else {
+ // numDependencies == 0
+ // alloca(0) implementation is platform dependent
+ depClosures = nullptr;
+ depFieldIDs = nullptr;
}
ret = (jlong)(uintptr_t)dispatchTab.ClosureCreate(
@@ -1173,9 +1186,9 @@ static void
nAllocationElementData1D(JNIEnv *_env, jobject _this, jlong con, jlong alloc, jint xoff,
jint lod, jint compIdx, jbyteArray data, jint sizeBytes)
{
- jint len = _env->GetArrayLength(data);
LOG_API("nAllocationElementData1D, con(%p), alloc(%p), xoff(%i), comp(%i), len(%i), "
- "sizeBytes(%i)", (RsContext)con, (RsAllocation)alloc, xoff, compIdx, len,
+ "sizeBytes(%i)", (RsContext)con, (RsAllocation)alloc, xoff, compIdx,
+ _env->GetArrayLength(data),
sizeBytes);
jbyte *ptr = _env->GetByteArrayElements(data, nullptr);
dispatchTab.Allocation1DElementData((RsContext)con, (RsAllocation)alloc, xoff,
@@ -2298,11 +2311,10 @@ nAllocationGetStride(JNIEnv *_env, jobject _this, jlong con, jlong alloc)
{
LOG_API("nAllocationGetStride, con(%p), alloc(%p)", (RsContext)con, (RsAllocation)alloc);
size_t strideIn = 0;
- void* ptr = NULL;
if (alloc != 0 && dispatchTab.AllocationGetPointer != nullptr) {
- ptr = dispatchTab.AllocationGetPointer((RsContext)con, (RsAllocation)alloc, 0,
- RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_X, 0, 0,
- &strideIn, sizeof(size_t));
+ dispatchTab.AllocationGetPointer((RsContext)con, (RsAllocation)alloc, 0,
+ RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_X, 0, 0,
+ &strideIn, sizeof(size_t));
}
return (jlong)strideIn;
}