summaryrefslogtreecommitdiff
path: root/rsScriptC.cpp
diff options
context:
space:
mode:
authorShih-wei Liao <sliao@google.com>2010-07-20 16:43:25 -0700
committerShih-wei Liao <sliao@google.com>2010-07-20 16:43:25 -0700
commita226b166dde77ae4bf4202a60afd14339b040dd3 (patch)
treef3a311b14cd053b92c5fb180dc047396272c885d /rsScriptC.cpp
parent56dee03a405f8de7edeb585c74136cfaee4c0762 (diff)
downloadrs-a226b166dde77ae4bf4202a60afd14339b040dd3.tar.gz
Use bccGetExportVars to get mFieldCount, instead of hardwiring "100" in calloc.
Change-Id: I6023b93865f785779b966acf03bf120078ac3c74
Diffstat (limited to 'rsScriptC.cpp')
-rw-r--r--rsScriptC.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/rsScriptC.cpp b/rsScriptC.cpp
index 5261f57f..7c7b0373 100644
--- a/rsScriptC.cpp
+++ b/rsScriptC.cpp
@@ -390,9 +390,13 @@ void ScriptCState::runCompiler(Context *rsc, ScriptC *s)
bccGetExportFuncs(s->mBccScript, NULL, s->mEnviroment.mInvokeFunctionCount, (BCCvoid **) s->mEnviroment.mInvokeFunctions);
}
- s->mEnviroment.mFieldAddress = (void **)calloc(100, sizeof(void *));
- bccGetExportVars(s->mBccScript, (BCCsizei *)&s->mEnviroment.mFieldCount,
- 100, s->mEnviroment.mFieldAddress);
+ bccGetExportVars(s->mBccScript, (BCCsizei*) &s->mEnviroment.mFieldCount, 0, NULL);
+ if(s->mEnviroment.mFieldCount <= 0)
+ s->mEnviroment.mFieldAddress = NULL;
+ else {
+ s->mEnviroment.mFieldAddress = (void **) calloc(s->mEnviroment.mFieldCount, sizeof(void *));
+ bccGetExportVars(s->mBccScript, NULL, s->mEnviroment.mFieldCount, (BCCvoid **) s->mEnviroment.mFieldAddress);
+ }
//for (int ct2=0; ct2 < s->mEnviroment.mFieldCount; ct2++ ) {
//LOGE("Script field %i = %p", ct2, s->mEnviroment.mFieldAddress[ct2]);
//}