Fix rsg_generator.c to properly propagate NULL values.
This patch modifies rsg_generator.c to properly propagate NULL values in the
presence of inlined data pointers.
Change-Id: I5f91518807d4ab05148c9382e143581157409be6
diff --git a/driver/rsdAllocation.cpp b/driver/rsdAllocation.cpp
index 248e7b6..bbe0d7a 100644
--- a/driver/rsdAllocation.cpp
+++ b/driver/rsdAllocation.cpp
@@ -1213,5 +1213,3 @@
}
#endif
}
-
-
diff --git a/rsScript.cpp b/rsScript.cpp
index dd962d1..ea1b3ac 100644
--- a/rsScript.cpp
+++ b/rsScript.cpp
@@ -192,13 +192,6 @@
const void *params, size_t paramLen,
const RsScriptCall *sc, size_t scLen) {
Script *s = static_cast<Script *>(vs);
- // The rs.spec generated code does not handle the absence of an actual
- // input for sc. Instead, it retains an existing pointer value (the prior
- // field in the packed data object). This can cause confusion because
- // drivers might now inspect bogus sc data.
- if (scLen == 0) {
- sc = NULL;
- }
s->runForEach(rsc, slot,
static_cast<const Allocation *>(vain), static_cast<Allocation *>(vaout),
params, paramLen, sc);
@@ -211,14 +204,6 @@
size_t paramLen, const RsScriptCall *sc,
size_t scLen) {
Script *s = static_cast<Script *>(vs);
- // The rs.spec generated code does not handle the absence of an actual
- // input for sc. Instead, it retains an existing pointer value (the prior
- // field in the packed data object). This can cause confusion because
- // drivers might now inspect bogus sc data.
- if (scLen == 0) {
- sc = NULL;
- }
-
Allocation **ains = (Allocation**)(vains);
s->runForEach(rsc, slot,
diff --git a/rsg_generator.c b/rsg_generator.c
index be2dacc..75ea1a3 100644
--- a/rsg_generator.c
+++ b/rsg_generator.c
@@ -294,7 +294,9 @@
const VarType *vt = &api->params[ct2];
needFlush += vt->ptrLevel;
if (vt->ptrLevel && hasInlineDataPointers(api)) {
- fprintf(f, " if (dataSize < io->getMaxInlineSize()) {\n");
+ fprintf(f, " if (%s_length == 0) {\n", vt->name);
+ fprintf(f, " cmd->%s = NULL;\n", vt->name);
+ fprintf(f, " } else if (dataSize < io->getMaxInlineSize()) {\n");
fprintf(f, " memcpy(payload, %s, %s_length);\n", vt->name, vt->name);
fprintf(f, " cmd->%s = (", vt->name);
printVarType(f, vt);
@@ -489,7 +491,8 @@
needFlush += vt->ptrLevel;
if (hasInlineDataPointers(api) && vt->ptrLevel) {
- fprintf(f, ",\n (const %s *)&baseData[(intptr_t)cmd->%s]", vt->typeName, vt->name);
+ fprintf(f, ",\n cmd->%s_length == 0 ? NULL : (const %s *)&baseData[(intptr_t)cmd->%s]",
+ vt->name, vt->typeName, vt->name);
} else {
fprintf(f, ",\n cmd->%s", vt->name);
}