summaryrefslogtreecommitdiff
path: root/support
diff options
context:
space:
mode:
authorYang Ni <yangni@google.com>2016-03-25 15:28:54 -0700
committerYang Ni <yangni@google.com>2016-03-25 16:08:05 -0700
commite5125574a68ee6283c300732a11662d8f9945624 (patch)
tree6e34e6cc604dab2a9af8851fabc4c318cdd87b96 /support
parentdeab7d352d917b042d827b2a589c53efe0d9d63e (diff)
downloadrs-e5125574a68ee6283c300732a11662d8f9945624.tar.gz
Removed unused variables
Bug: 27272549 Also avoided alloca(0) Change-Id: I64d0baf3ccd1da37851f337293d356973a12a9d7
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;
}