Replace NULL macros with nullptr literals.
Change-Id: Id2311cda59dd42c74b3ed54d3ff6cfd509012738
diff --git a/lib/Renderscript/RSCompiler.cpp b/lib/Renderscript/RSCompiler.cpp
index 5547ad2..dc5ba6a 100644
--- a/lib/Renderscript/RSCompiler.cpp
+++ b/lib/Renderscript/RSCompiler.cpp
@@ -46,7 +46,7 @@
// Special RS functions should always be global symbols.
const char **special_functions = RSExecutable::SpecialFunctionNames;
- while (*special_functions != NULL) {
+ while (*special_functions != nullptr) {
export_symbols.push_back(*special_functions);
special_functions++;
}
diff --git a/lib/Renderscript/RSCompilerDriver.cpp b/lib/Renderscript/RSCompilerDriver.cpp
index 4d90470..9ae2e03 100644
--- a/lib/Renderscript/RSCompilerDriver.cpp
+++ b/lib/Renderscript/RSCompilerDriver.cpp
@@ -58,8 +58,8 @@
}
RSCompilerDriver::RSCompilerDriver(bool pUseCompilerRT) :
- mConfig(NULL), mCompiler(), mDebugContext(false),
- mLinkRuntimeCallback(NULL), mEnableGlobalMerge(true) {
+ mConfig(nullptr), mCompiler(), mDebugContext(false),
+ mLinkRuntimeCallback(nullptr), mEnableGlobalMerge(true) {
init::Initialize();
}
@@ -72,15 +72,15 @@
const char* expectedCompileCommandLine,
SymbolResolverProxy& pResolver) {
// android::StopWatch load_time("bcc: RSCompilerDriver::loadScript time");
- if ((pCacheDir == NULL) || (pResName == NULL)) {
+ if ((pCacheDir == nullptr) || (pResName == nullptr)) {
ALOGE("Missing pCacheDir and/or pResName");
- return NULL;
+ return nullptr;
}
- if ((pBitcode == NULL) || (pBitcodeSize <= 0)) {
+ if ((pBitcode == nullptr) || (pBitcodeSize <= 0)) {
ALOGE("No bitcode supplied! (bitcode: %p, size of bitcode: %zu)",
pBitcode, pBitcodeSize);
- return NULL;
+ return nullptr;
}
// {pCacheDir}/{pResName}.o
@@ -96,7 +96,7 @@
if (read_output_mutex.hasError() || !read_output_mutex.lock()) {
ALOGE("Unable to acquire the read lock for %s! (%s)", output_path.c_str(),
read_output_mutex.getErrorMessage().c_str());
- return NULL;
+ return nullptr;
}
//===--------------------------------------------------------------------===//
@@ -104,11 +104,11 @@
//===--------------------------------------------------------------------===//
InputFile *object_file = new (std::nothrow) InputFile(output_path.c_str());
- if ((object_file == NULL) || object_file->hasError()) {
+ if ((object_file == nullptr) || object_file->hasError()) {
// ALOGE("Unable to open the %s for read! (%s)", output_path.c_str(),
// object_file->getErrorMessage().c_str());
delete object_file;
- return NULL;
+ return nullptr;
}
//===--------------------------------------------------------------------===//
@@ -121,7 +121,7 @@
output_path.c_str(), info_path.c_str(),
object_file->getErrorMessage().c_str());
delete object_file;
- return NULL;
+ return nullptr;
}
//===---------------------------------------------------------------------===//
@@ -133,9 +133,9 @@
// Release the lock on object_file.
object_file->unlock();
- if (info == NULL) {
+ if (info == nullptr) {
delete object_file;
- return NULL;
+ return nullptr;
}
//===---------------------------------------------------------------------===//
@@ -155,17 +155,17 @@
expectedBuildFingerprint.c_str())) {
delete object_file;
delete info;
- return NULL;
+ return nullptr;
}
//===--------------------------------------------------------------------===//
// Create the RSExecutable.
//===--------------------------------------------------------------------===//
RSExecutable *executable = RSExecutable::Create(*info, *object_file, pResolver);
- if (executable == NULL) {
+ if (executable == nullptr) {
delete object_file;
delete info;
- return NULL;
+ return nullptr;
}
return executable;
@@ -185,7 +185,7 @@
EnableGlobalMerge = mEnableGlobalMerge;
#endif
- if (mConfig != NULL) {
+ if (mConfig != nullptr) {
// Renderscript bitcode may have their optimization flag configuration
// different than the previous run of RS compilation.
if (mConfig->getOptimizationLevel() != script_opt_level) {
@@ -195,7 +195,7 @@
} else {
// Haven't run the compiler ever.
mConfig = new (std::nothrow) CompilerConfig(DEFAULT_TARGET_TRIPLE_STRING);
- if (mConfig == NULL) {
+ if (mConfig == nullptr) {
// Return false since mConfig remains NULL and out-of-memory.
return false;
}
@@ -204,7 +204,7 @@
}
#if defined(PROVIDE_ARM_CODEGEN)
- assert((pScript.getInfo() != NULL) && "NULL RS info!");
+ assert((pScript.getInfo() != nullptr) && "NULL RS info!");
bool script_full_prec = (pScript.getInfo()->getFloatPrecisionRequirement() ==
RSInfo::FP_Full);
if (mConfig->getFullPrecision() != script_full_prec) {
@@ -223,7 +223,7 @@
const char* compileCommandLineToEmbed,
bool saveInfoFile, bool pDumpIR) {
// android::StopWatch compile_time("bcc: RSCompilerDriver::compileScript time");
- RSInfo *info = NULL;
+ RSInfo *info = nullptr;
//===--------------------------------------------------------------------===//
// Extract RS-specific information from source bitcode.
@@ -232,7 +232,7 @@
// compiler therefore it should be extracted before compilation.
info = RSInfo::ExtractFromSource(pScript.getSource(), pSourceHash, compileCommandLineToEmbed,
getBuildFingerPrint().c_str());
- if (info == NULL) {
+ if (info == nullptr) {
return Compiler::kErrInvalidSource;
}
@@ -280,7 +280,7 @@
// Setup the config to the compiler.
bool compiler_need_reconfigure = setupConfig(pScript);
- if (mConfig == NULL) {
+ if (mConfig == nullptr) {
ALOGE("Failed to setup config for RS compiler to compile %s!",
pOutputPath);
return Compiler::kErrInvalidSource;
@@ -295,8 +295,8 @@
}
}
- OutputFile *ir_file = NULL;
- llvm::raw_fd_ostream *IRStream = NULL;
+ OutputFile *ir_file = nullptr;
+ llvm::raw_fd_ostream *IRStream = nullptr;
if (pDumpIR) {
std::string path(pOutputPath);
path.append(".ll");
@@ -360,14 +360,14 @@
//===--------------------------------------------------------------------===//
// Check parameters.
//===--------------------------------------------------------------------===//
- if ((pCacheDir == NULL) || (pResName == NULL)) {
+ if ((pCacheDir == nullptr) || (pResName == nullptr)) {
ALOGE("Invalid parameter passed to RSCompilerDriver::build()! (cache dir: "
"%s, resource name: %s)", ((pCacheDir) ? pCacheDir : "(null)"),
((pResName) ? pResName : "(null)"));
return false;
}
- if ((pBitcode == NULL) || (pBitcodeSize <= 0)) {
+ if ((pBitcode == nullptr) || (pBitcodeSize <= 0)) {
ALOGE("No bitcode supplied! (bitcode: %p, size of bitcode: %u)",
pBitcode, static_cast<unsigned>(pBitcodeSize));
return false;
@@ -392,7 +392,7 @@
//===--------------------------------------------------------------------===//
Source *source = Source::CreateFromBuffer(pContext, pResName,
pBitcode, pBitcodeSize);
- if (source == NULL) {
+ if (source == nullptr) {
return false;
}
@@ -432,7 +432,7 @@
RSInfo* info = RSInfo::ExtractFromSource(pScript.getSource(), bitcode_sha1,
compileCommandLineToEmbed, buildFingerprintToEmbed);
- if (info == NULL) {
+ if (info == nullptr) {
return false;
}
pScript.setInfo(info);
diff --git a/lib/Renderscript/RSEmbedInfo.cpp b/lib/Renderscript/RSEmbedInfo.cpp
index b19519f..06fe547 100644
--- a/lib/Renderscript/RSEmbedInfo.cpp
+++ b/lib/Renderscript/RSEmbedInfo.cpp
@@ -54,7 +54,7 @@
public:
RSEmbedInfoPass()
: ModulePass(ID),
- M(NULL) {
+ M(nullptr) {
}
static std::string getRSInfoString(const llvm::Module *module) {
diff --git a/lib/Renderscript/RSExecutable.cpp b/lib/Renderscript/RSExecutable.cpp
index 06f9b5f..f0b95ae 100644
--- a/lib/Renderscript/RSExecutable.cpp
+++ b/lib/Renderscript/RSExecutable.cpp
@@ -32,7 +32,7 @@
"init", // Initialization routine called implicitly on startup.
".rs.dtor", // Static global destructor for a script instance.
".rs.info", // Variable containing string of RS metadata info.
- NULL // Must be NULL-terminated.
+ nullptr // Must be nullptr-terminated.
};
RSExecutable *RSExecutable::Create(RSInfo &pInfo,
@@ -43,18 +43,18 @@
ObjectLoader *loader = ObjectLoader::Load(pObjFile,
pResolver,
pInfo.hasDebugInformation());
- if (loader == NULL) {
- return NULL;
+ if (loader == nullptr) {
+ return nullptr;
}
// Now, all things required to build a RSExecutable object are ready.
RSExecutable *result = new (std::nothrow) RSExecutable(pInfo,
pObjFile,
*loader);
- if (result == NULL) {
+ if (result == nullptr) {
ALOGE("Out of memory when create object to hold RS result file for %s!",
pObjFile.getName().c_str());
- return NULL;
+ return nullptr;
}
unsigned idx;
@@ -68,7 +68,7 @@
var_iter++, idx++) {
const char *name = *var_iter;
void *addr = result->getSymbolAddress(name);
- if (addr == NULL) {
+ if (addr == nullptr) {
//ALOGW("RS export var at entry #%u named %s cannot be found in the result "
//"object!", idx, name);
}
@@ -170,7 +170,7 @@
void *func = mLoader->getSymbolAddress(func_name);
size_t func_size = mLoader->getSymbolSize(func_name);
- if (func == NULL) {
+ if (func == nullptr) {
continue;
}
DisassembleResult result =
diff --git a/lib/Renderscript/RSForEachExpand.cpp b/lib/Renderscript/RSForEachExpand.cpp
index 8185256..ec3d330 100644
--- a/lib/Renderscript/RSForEachExpand.cpp
+++ b/lib/Renderscript/RSForEachExpand.cpp
@@ -103,7 +103,7 @@
// We only handle the case for legacy root() functions here, so this is
// hard-coded to look at only the first such function.
llvm::MDNode *SigNode = ExportForEachMetadata->getOperand(0);
- if (SigNode != NULL && SigNode->getNumOperands() == 1) {
+ if (SigNode != nullptr && SigNode->getNumOperands() == 1) {
llvm::Value *SigVal = SigNode->getOperand(0);
if (SigVal->getValueID() == llvm::Value::MDStringVal) {
llvm::StringRef SigString =
@@ -307,7 +307,7 @@
public:
RSForEachExpandPass(bool pEnableStepOpt)
- : ModulePass(ID), Module(NULL), Context(NULL),
+ : ModulePass(ID), Module(nullptr), Context(nullptr),
mEnableStepOpt(pEnableStepOpt) {
}
@@ -348,8 +348,8 @@
llvm::Value *Arg_x2 = &*(ExpandedFunctionArgIter++);
llvm::Value *Arg_outstep = &*(ExpandedFunctionArgIter);
- llvm::Value *InStep = NULL;
- llvm::Value *OutStep = NULL;
+ llvm::Value *InStep = nullptr;
+ llvm::Value *OutStep = nullptr;
// Construct the actual function body.
llvm::IRBuilder<> Builder(ExpandedFunction->getEntryBlock().begin());
@@ -358,8 +358,8 @@
// Note that we load any loop-invariant arguments before entering the Loop.
llvm::Function::arg_iterator FunctionArgIter = Function->arg_begin();
- llvm::Type *InTy = NULL;
- llvm::Value *InBasePtr = NULL;
+ llvm::Type *InTy = nullptr;
+ llvm::Value *InBasePtr = nullptr;
if (bcinfo::MetadataExtractor::hasForEachSignatureIn(Signature)) {
llvm::Value *InsMember = Builder.CreateStructGEP(Arg_p,
PARAM_FIELD_INS);
@@ -385,8 +385,8 @@
InBasePtr = Builder.CreateLoad(InputAddr, "input_base");
}
- llvm::Type *OutTy = NULL;
- llvm::Value *OutBasePtr = NULL;
+ llvm::Type *OutTy = nullptr;
+ llvm::Value *OutBasePtr = nullptr;
if (bcinfo::MetadataExtractor::hasForEachSignatureOut(Signature)) {
OutTy = (FunctionArgIter++)->getType();
OutStep = getStepValue(&DL, OutTy, Arg_outstep);
@@ -395,7 +395,7 @@
Builder.CreateStructGEP(Arg_p, PARAM_FIELD_OUT));
}
- llvm::Value *UsrData = NULL;
+ llvm::Value *UsrData = nullptr;
if (bcinfo::MetadataExtractor::hasForEachSignatureUsrData(Signature)) {
llvm::Type *UsrDataTy = (FunctionArgIter++)->getType();
UsrData = Builder.CreatePointerCast(Builder.CreateLoad(
@@ -407,7 +407,7 @@
FunctionArgIter++;
}
- llvm::Value *Y = NULL;
+ llvm::Value *Y = nullptr;
if (bcinfo::MetadataExtractor::hasForEachSignatureY(Signature)) {
Y = Builder.CreateLoad(
Builder.CreateStructGEP(Arg_p, PARAM_FIELD_Y), "Y");
@@ -423,8 +423,8 @@
// Populate the actual call to kernel().
llvm::SmallVector<llvm::Value*, 8> RootArgs;
- llvm::Value *InPtr = NULL;
- llvm::Value *OutPtr = NULL;
+ llvm::Value *InPtr = nullptr;
+ llvm::Value *OutPtr = nullptr;
// Calculate the current input and output pointers
//
@@ -524,7 +524,7 @@
*/
size_t NumInputs = Function->arg_size();
- llvm::Value *Y = NULL;
+ llvm::Value *Y = nullptr;
if (bcinfo::MetadataExtractor::hasForEachSignatureY(Signature)) {
Y = Builder.CreateLoad(
Builder.CreateStructGEP(Arg_p, PARAM_FIELD_Y), "Y");
@@ -543,9 +543,9 @@
llvm::Function::arg_iterator ArgIter = Function->arg_begin();
// Check the return type
- llvm::Type *OutTy = NULL;
- llvm::Value *OutStep = NULL;
- llvm::LoadInst *OutBasePtr = NULL;
+ llvm::Type *OutTy = nullptr;
+ llvm::Value *OutStep = nullptr;
+ llvm::LoadInst *OutBasePtr = nullptr;
bool PassOutByPointer = false;
@@ -651,7 +651,7 @@
// Output
- llvm::Value *OutPtr = NULL;
+ llvm::Value *OutPtr = nullptr;
if (OutBasePtr) {
llvm::Value *OutOffset = Builder.CreateSub(IV, Arg_x1);
diff --git a/lib/Renderscript/RSInfo.cpp b/lib/Renderscript/RSInfo.cpp
index bfc26d1..bd25327 100644
--- a/lib/Renderscript/RSInfo.cpp
+++ b/lib/Renderscript/RSInfo.cpp
@@ -88,7 +88,7 @@
return true;
}
-RSInfo::RSInfo(size_t pStringPoolSize) : mStringPool(NULL) {
+RSInfo::RSInfo(size_t pStringPoolSize) : mStringPool(nullptr) {
::memset(&mHeader, 0, sizeof(mHeader));
::memcpy(mHeader.magic, RSINFO_MAGIC, sizeof(mHeader.magic));
@@ -105,15 +105,15 @@
if (pStringPoolSize > 0) {
mHeader.strPoolSize = pStringPoolSize;
mStringPool = new (std::nothrow) char [ mHeader.strPoolSize ];
- if (mStringPool == NULL) {
+ if (mStringPool == nullptr) {
ALOGE("Out of memory when allocate memory for string pool in RSInfo "
"constructor (size: %u)!", mHeader.strPoolSize);
}
::memset(mStringPool, 0, mHeader.strPoolSize);
}
- mSourceHash = NULL;
- mCompileCommandLine = NULL;
- mBuildFingerprint = NULL;
+ mSourceHash = nullptr;
+ mCompileCommandLine = nullptr;
+ mBuildFingerprint = nullptr;
}
RSInfo::~RSInfo() {
@@ -153,14 +153,16 @@
ALOGV("\tHeader size: %u", mHeader.headerSize);
ALOGV("\tString pool size: %u", mHeader.strPoolSize);
- if (mSourceHash == NULL) {
+ if (mSourceHash == nullptr) {
ALOGV("Source hash: NULL!");
} else {
ALOGV("Source hash: %s", stringFromSourceHash(mSourceHash).c_str());
}
- ALOGV("Compile Command Line: ", mCompileCommandLine ? mCompileCommandLine : "(NULL)");
- ALOGV("mBuildFingerprint: ", mBuildFingerprint ? mBuildFingerprint : "(NULL)");
+ ALOGV("Compile Command Line: ", mCompileCommandLine ? mCompileCommandLine :
+ "(NULL)");
+ ALOGV("mBuildFingerprint: ", mBuildFingerprint ? mBuildFingerprint :
+ "(NULL)");
#define DUMP_LIST_HEADER(_name, _header) do { \
ALOGV(_name ":"); \
@@ -213,7 +215,7 @@
if (pStrIdx >= mHeader.strPoolSize) {
ALOGE("String index #%u is out of range in string pool (size: %u)!",
pStrIdx, mHeader.strPoolSize);
- return NULL;
+ return nullptr;
}
return &mStringPool[ pStrIdx ];
}
diff --git a/lib/Renderscript/RSInfoExtractor.cpp b/lib/Renderscript/RSInfoExtractor.cpp
index d302cdf..bafce38 100644
--- a/lib/Renderscript/RSInfoExtractor.cpp
+++ b/lib/Renderscript/RSInfoExtractor.cpp
@@ -54,7 +54,7 @@
const llvm::StringRef object_slot_metadata_name("#rs_object_slots");
inline llvm::StringRef getStringFromOperand(const llvm::Value *pString) {
- if ((pString != NULL) && (pString->getValueID() == llvm::Value::MDStringVal)) {
+ if ((pString != nullptr) && (pString->getValueID() == llvm::Value::MDStringVal)) {
return static_cast<const llvm::MDString *>(pString)->getString();
}
return llvm::StringRef();
@@ -62,14 +62,14 @@
template<size_t NumOperands>
inline size_t getMetadataStringLength(const llvm::NamedMDNode *pMetadata) {
- if (pMetadata == NULL) {
+ if (pMetadata == nullptr) {
return 0;
}
size_t string_size = 0;
for (unsigned i = 0, e = pMetadata->getNumOperands(); i < e; i++) {
llvm::MDNode *node = pMetadata->getOperand(i);
- if ((node != NULL) && (node->getNumOperands() >= NumOperands)) {
+ if ((node != nullptr) && (node->getNumOperands() >= NumOperands)) {
// Compiler try its best to unroll this loop since NumOperands is a
// template parameter (therefore the number of iteration can be determined
// at compile-time and it's usually small.)
@@ -131,13 +131,13 @@
size_t string_pool_size = 1;
off_t cur_string_pool_offset = 0;
- RSInfo *result = NULL;
+ RSInfo *result = nullptr;
// Handle legacy case for pre-ICS bitcode that doesn't contain a metadata
// section for ForEach. We generate a full signature for a "root" function.
- if ((export_foreach_name == NULL) || (export_foreach_signature == NULL)) {
- export_foreach_name = NULL;
- export_foreach_signature = NULL;
+ if ((export_foreach_name == nullptr) || (export_foreach_signature == nullptr)) {
+ export_foreach_name = nullptr;
+ export_foreach_signature = nullptr;
string_pool_size += 5; // insert "root\0" for #rs_export_foreach_name
}
@@ -153,13 +153,13 @@
// Allocate result object
result = new (std::nothrow) RSInfo(string_pool_size);
- if (result == NULL) {
+ if (result == nullptr) {
ALOGE("Out of memory when create RSInfo object for %s!", module_name);
goto bail;
}
// Check string pool.
- if (result->mStringPool == NULL) {
+ if (result->mStringPool == nullptr) {
ALOGE("Out of memory when allocate string pool in RSInfo object for %s!",
module_name);
goto bail;
@@ -171,13 +171,13 @@
// Populate all the strings and data.
#define FOR_EACH_NODE_IN(_metadata, _node) \
for (unsigned i = 0, e = (_metadata)->getNumOperands(); i != e; i++) \
- if (((_node) = (_metadata)->getOperand(i)) != NULL)
+ if (((_node) = (_metadata)->getOperand(i)) != nullptr)
//===--------------------------------------------------------------------===//
// #pragma
//===--------------------------------------------------------------------===//
// Pragma is actually a key-value pair. The value can be an empty string while
// the key cannot.
- if (pragma != NULL) {
+ if (pragma != nullptr) {
llvm::MDNode *node;
FOR_EACH_NODE_IN(pragma, node) {
llvm::StringRef key = getStringFromOperand(node->getOperand(0));
@@ -191,12 +191,12 @@
writeString(val, result->mStringPool, &cur_string_pool_offset)));
} // key.empty()
} // FOR_EACH_NODE_IN
- } // pragma != NULL
+ } // pragma != nullptr
//===--------------------------------------------------------------------===//
// #rs_export_var
//===--------------------------------------------------------------------===//
- if (export_var != NULL) {
+ if (export_var != nullptr) {
llvm::MDNode *node;
FOR_EACH_NODE_IN(export_var, node) {
llvm::StringRef name = getStringFromOperand(node->getOperand(0));
@@ -213,7 +213,7 @@
//===--------------------------------------------------------------------===//
// #rs_export_func
//===--------------------------------------------------------------------===//
- if (export_func != NULL) {
+ if (export_func != nullptr) {
llvm::MDNode *node;
FOR_EACH_NODE_IN(export_func, node) {
llvm::StringRef name = getStringFromOperand(node->getOperand(0));
@@ -245,7 +245,7 @@
// for-eachable. In this case, #rs_export_foreach (the function name) and
// #rs_export_foreach metadata (the signature) is one-to-one mapping among
// their entries.
- if ((export_foreach_name != NULL) && (export_foreach_signature != NULL)) {
+ if ((export_foreach_name != nullptr) && (export_foreach_signature != nullptr)) {
unsigned num_foreach_function;
// Should be one-to-one mapping.
@@ -264,15 +264,15 @@
llvm::MDNode *signature_node = export_foreach_signature->getOperand(i);
llvm::StringRef name, signature_string;
- if (name_node != NULL) {
+ if (name_node != nullptr) {
name = getStringFromOperand(name_node->getOperand(0));
}
- if (signature_node != NULL) {
+ if (signature_node != nullptr) {
signature_string = getStringFromOperand(signature_node->getOperand(0));
}
if (!name.empty() && !signature_string.empty()) {
- // Both name_node and signature_node are not NULL nodes.
+ // Both name_node and signature_node are not nullptr nodes.
uint32_t signature;
if (signature_string.getAsInteger(10, signature)) {
ALOGE("Non-integer signature value '%s' for function %s found in %s!",
@@ -287,7 +287,7 @@
// if both of them are empty.
if (name.empty() && signature_string.empty()) {
ALOGW("Entries #%u at #rs_export_foreach_name and #rs_export_foreach"
- " are both NULL in %s! (skip)", i, module_name);
+ " are both nullptr in %s! (skip)", i, module_name);
continue;
} else {
ALOGE("Entries #%u at %s is NULL in %s! (skip)", i,
@@ -309,7 +309,7 @@
//===--------------------------------------------------------------------===//
// #rs_object_slots
//===--------------------------------------------------------------------===//
- if (object_slots != NULL) {
+ if (object_slots != nullptr) {
llvm::MDNode *node;
for (unsigned int i = 0; i <= export_var->getNumOperands(); i++) {
result->mObjectSlots.push_back(0);
@@ -360,7 +360,7 @@
// The root context of the debug information in the bitcode is put under
// the metadata named "llvm.dbg.cu".
result->mHeader.hasDebugInformation =
- static_cast<uint8_t>(module.getNamedMetadata("llvm.dbg.cu") != NULL);
+ static_cast<uint8_t>(module.getNamedMetadata("llvm.dbg.cu") != nullptr);
assert((cur_string_pool_offset == string_pool_size) &&
"Unexpected string pool size!");
@@ -369,5 +369,5 @@
bail:
delete result;
- return NULL;
+ return nullptr;
}
diff --git a/lib/Renderscript/RSInfoReader.cpp b/lib/Renderscript/RSInfoReader.cpp
index 00b0a3c..d997aac 100644
--- a/lib/Renderscript/RSInfoReader.cpp
+++ b/lib/Renderscript/RSInfoReader.cpp
@@ -46,12 +46,12 @@
const char *key = pInfo.getStringFromPool(pItem.key);
const char *value =pInfo.getStringFromPool(pItem.value);
- if (key == NULL) {
+ if (key == nullptr) {
ALOGE("Invalid string index %d for key in RS pragma list.", pItem.key);
return false;
}
- if (value == NULL) {
+ if (value == nullptr) {
ALOGE("Invalid string index %d for value in RS pragma list.", pItem.value);
return false;
}
@@ -80,7 +80,7 @@
{
const char *name = pInfo.getStringFromPool(pItem.name);
- if (name == NULL) {
+ if (name == nullptr) {
ALOGE("Invalid string index %d for name in RS export vars.", pItem.name);
return false;
}
@@ -98,7 +98,7 @@
{
const char *name = pInfo.getStringFromPool(pItem.name);
- if (name == NULL) {
+ if (name == nullptr) {
ALOGE("Invalid string index %d for name in RS export funcs.", pItem.name);
return false;
}
@@ -116,7 +116,7 @@
{
const char *name = pInfo.getStringFromPool(pItem.name);
- if (name == NULL) {
+ if (name == nullptr) {
ALOGE("Invalid string index %d for name in RS export foreachs.", pItem.name);
return false;
}
@@ -147,8 +147,8 @@
} // end anonymous namespace
RSInfo *RSInfo::ReadFromFile(InputFile &pInput) {
- android::FileMap *map = NULL;
- RSInfo *result = NULL;
+ android::FileMap *map = nullptr;
+ RSInfo *result = nullptr;
const uint8_t *data;
const rsinfo::Header *header;
size_t filesize;
@@ -171,7 +171,7 @@
// Create memory map for the file.
map = pInput.createMap(/* pOffset */cur_input_offset,
/* pLength */filesize - cur_input_offset);
- if (map == NULL) {
+ if (map == nullptr) {
ALOGE("Failed to map RS info file %s to the memory! (%s)",
input_filename, pInput.getErrorMessage().c_str());
goto bail;
@@ -226,7 +226,7 @@
// File seems ok, create result RSInfo object.
result = new (std::nothrow) RSInfo(header->strPoolSize);
- if (result == NULL) {
+ if (result == nullptr) {
ALOGE("Out of memory when create RSInfo object for %s!", input_filename);
goto bail;
}
@@ -240,7 +240,7 @@
if (header->strPoolSize > 0) {
// Copy the string pool. The string pool is immediately after the header at
// the offset header->headerSize.
- if (result->mStringPool == NULL) {
+ if (result->mStringPool == nullptr) {
ALOGE("Out of memory when allocate string pool for RS info file %s!",
input_filename);
goto bail;
@@ -252,19 +252,19 @@
// Populate all the data to the result object.
result->mSourceHash =
reinterpret_cast<const uint8_t*>(result->getStringFromPool(header->sourceSha1Idx));
- if (result->mSourceHash == NULL) {
+ if (result->mSourceHash == nullptr) {
ALOGE("Invalid string index %d for SHA-1 checksum of source.", header->sourceSha1Idx);
goto bail;
}
result->mCompileCommandLine = result->getStringFromPool(header->compileCommandLineIdx);
- if (result->mCompileCommandLine == NULL) {
+ if (result->mCompileCommandLine == nullptr) {
ALOGE("Invalid string index %d for compile command line.", header->compileCommandLineIdx);
goto bail;
}
result->mBuildFingerprint = result->getStringFromPool(header->buildFingerprintIdx);
- if (result->mBuildFingerprint == NULL) {
+ if (result->mBuildFingerprint == nullptr) {
ALOGE("Invalid string index %d for build fingerprint.", header->buildFingerprintIdx);
goto bail;
}
@@ -300,11 +300,11 @@
return result;
bail:
- if (map != NULL) {
+ if (map != nullptr) {
map->release();
}
delete result;
- return NULL;
+ return nullptr;
} // RSInfo::ReadFromFile
diff --git a/lib/Renderscript/RSScript.cpp b/lib/Renderscript/RSScript.cpp
index 884de22..2dadc66 100644
--- a/lib/Renderscript/RSScript.cpp
+++ b/lib/Renderscript/RSScript.cpp
@@ -24,18 +24,18 @@
using namespace bcc;
bool RSScript::LinkRuntime(RSScript &pScript, const char *core_lib) {
- bccAssert(core_lib != NULL);
+ bccAssert(core_lib != nullptr);
// Using the same context with the source in pScript.
BCCContext &context = pScript.getSource().getContext();
Source *libclcore_source = Source::CreateFromFile(context, core_lib);
- if (libclcore_source == NULL) {
+ if (libclcore_source == nullptr) {
ALOGE("Failed to load Renderscript library '%s' to link!", core_lib);
return false;
}
- if (NULL != pScript.mLinkRuntimeCallback) {
+ if (pScript.mLinkRuntimeCallback != nullptr) {
pScript.mLinkRuntimeCallback(&pScript,
&pScript.getSource().getModule(), &libclcore_source->getModule());
}
@@ -51,12 +51,12 @@
}
RSScript::RSScript(Source &pSource)
- : Script(pSource), mInfo(NULL), mCompilerVersion(0),
- mOptimizationLevel(kOptLvl3), mLinkRuntimeCallback(NULL),
+ : Script(pSource), mInfo(nullptr), mCompilerVersion(0),
+ mOptimizationLevel(kOptLvl3), mLinkRuntimeCallback(nullptr),
mEmbedInfo(false) { }
bool RSScript::doReset() {
- mInfo = NULL;
+ mInfo = nullptr;
mCompilerVersion = 0;
mOptimizationLevel = kOptLvl3;
return true;