Replace NULL macros with nullptr literals.
Change-Id: I918c40879aa547438f77e7d1a95fa2aa33bec398
diff --git a/cpu_ref/linkloader/android/librsloader.cpp b/cpu_ref/linkloader/android/librsloader.cpp
index 7fbaa7c..fa74a7d 100644
--- a/cpu_ref/linkloader/android/librsloader.cpp
+++ b/cpu_ref/linkloader/android/librsloader.cpp
@@ -53,12 +53,12 @@
void *find_symbol_context) {
RSExecRef object = rsloaderLoadExecutable(buf, buf_size);
if (!object) {
- return NULL;
+ return nullptr;
}
if (!rsloaderRelocateExecutable(object, find_symbol, find_symbol_context)) {
rsloaderDisposeExec(object);
- return NULL;
+ return nullptr;
}
return object;
@@ -75,7 +75,7 @@
#endif
if (!object) {
ALOGE("Unable to load the ELF object.");
- return NULL;
+ return nullptr;
}
return wrap(object.release());
@@ -156,7 +156,7 @@
#endif
if (!symtab) {
- return NULL;
+ return nullptr;
}
#if defined(__LP64__) || defined(__x86_64__)
@@ -167,7 +167,7 @@
if (!symbol) {
ALOGV("Symbol not found: %s\n", name);
- return NULL;
+ return nullptr;
}
int machine = object->getHeader()->getMachine();
diff --git a/cpu_ref/linkloader/include/ELFHeader.h b/cpu_ref/linkloader/include/ELFHeader.h
index e6c66f6..e6535f0 100644
--- a/cpu_ref/linkloader/include/ELFHeader.h
+++ b/cpu_ref/linkloader/include/ELFHeader.h
@@ -149,19 +149,19 @@
static ELFHeader *read(Archiver &AR) {
if (!AR) {
// Archiver is in bad state before calling read function.
- // Return NULL and do nothing.
- return 0;
+ // Return nullptr and do nothing.
+ return nullptr;
}
std::unique_ptr<ELFHeader> header(new ELFHeader());
if (!header->serialize(AR)) {
- // Unable to read the structure. Return NULL.
- return 0;
+ // Unable to read the structure. Return nullptr.
+ return nullptr;
}
if (!header->isValid()) {
- // Header read from archiver is not valid. Return NULL.
- return 0;
+ // Header read from archiver is not valid. Return nullptr.
+ return nullptr;
}
return header.release();
diff --git a/cpu_ref/linkloader/include/ELFObject.h b/cpu_ref/linkloader/include/ELFObject.h
index 86ac6bf..0910067 100644
--- a/cpu_ref/linkloader/include/ELFObject.h
+++ b/cpu_ref/linkloader/include/ELFObject.h
@@ -54,7 +54,7 @@
}
private:
- ELFObject() : SHNCommonDataPtr(NULL), missingSymbols(false) { }
+ ELFObject() : SHNCommonDataPtr(nullptr), missingSymbols(false) { }
public:
template <typename Archiver>
@@ -92,7 +92,7 @@
// Ensure the free size is sufficient
if (SHNCommonDataFreeSize < size) {
- return NULL;
+ return nullptr;
}
// Allcoate
diff --git a/cpu_ref/linkloader/include/ELFSectionBits.h b/cpu_ref/linkloader/include/ELFSectionBits.h
index b6e4590..33b4259 100644
--- a/cpu_ref/linkloader/include/ELFSectionBits.h
+++ b/cpu_ref/linkloader/include/ELFSectionBits.h
@@ -28,7 +28,7 @@
MemChunk chunk;
protected:
- ELFSectionBits() : sh(NULL) { }
+ ELFSectionBits() : sh(nullptr) { }
public:
virtual void print() const;
diff --git a/cpu_ref/linkloader/include/ELFSectionProgBits.h b/cpu_ref/linkloader/include/ELFSectionProgBits.h
index a642b16..9c1d428 100644
--- a/cpu_ref/linkloader/include/ELFSectionProgBits.h
+++ b/cpu_ref/linkloader/include/ELFSectionProgBits.h
@@ -64,7 +64,7 @@
break;
default:
- stubs = NULL;
+ stubs = nullptr;
}
}
diff --git a/cpu_ref/linkloader/lib/MemChunk.cpp b/cpu_ref/linkloader/lib/MemChunk.cpp
index 5d6c102..8a9b548 100644
--- a/cpu_ref/linkloader/lib/MemChunk.cpp
+++ b/cpu_ref/linkloader/lib/MemChunk.cpp
@@ -41,10 +41,10 @@
static uintptr_t StartAddr = 0x7e000000UL;
#endif
-AllocFunc MemChunk::VendorAlloc = NULL;
-FreeFunc MemChunk::VendorFree = NULL;
+AllocFunc MemChunk::VendorAlloc = nullptr;
+FreeFunc MemChunk::VendorFree = nullptr;
-MemChunk::MemChunk() : buf(NULL), buf_size(0), bVendorBuf(true) {
+MemChunk::MemChunk() : buf(nullptr), buf_size(0), bVendorBuf(true) {
}
MemChunk::~MemChunk() {
diff --git a/cpu_ref/linkloader/lib/StubLayout.cpp b/cpu_ref/linkloader/lib/StubLayout.cpp
index dd4b139..1ff9e16 100644
--- a/cpu_ref/linkloader/lib/StubLayout.cpp
+++ b/cpu_ref/linkloader/lib/StubLayout.cpp
@@ -23,7 +23,7 @@
#include <stdint.h>
#include <stdlib.h>
-StubLayout::StubLayout() : table(NULL), count(0) {
+StubLayout::StubLayout() : table(nullptr), count(0) {
}
void StubLayout::initStubTable(unsigned char *table_, size_t count_) {
@@ -42,7 +42,7 @@
// We have to create a new stub
if (count == 0) {
// No free stub slot is available
- return NULL;
+ return nullptr;
}
// Initialize the stub
diff --git a/cpu_ref/linkloader/main.cpp b/cpu_ref/linkloader/main.cpp
index 072595f..011e1d7 100644
--- a/cpu_ref/linkloader/main.cpp
+++ b/cpu_ref/linkloader/main.cpp
@@ -54,7 +54,7 @@
// Open the file
int fd = -1;
- unsigned char const *image = NULL;
+ unsigned char const *image = nullptr;
size_t image_size = 0;
if (!open_mmap_file(filename, fd, image, image_size)) {
@@ -135,7 +135,7 @@
}
assert(0 && "Can't find symbol.");
- return 0;
+ return nullptr;
}
template <unsigned Bitwidth, typename Archiver>
diff --git a/cpu_ref/linkloader/utils/serialize.h b/cpu_ref/linkloader/utils/serialize.h
index 3d15158..49ba400 100644
--- a/cpu_ref/linkloader/utils/serialize.h
+++ b/cpu_ref/linkloader/utils/serialize.h
@@ -66,21 +66,21 @@
bool good;
public:
- ArchiveReader(unsigned char const *buf = NULL, size_t size = 0)
+ ArchiveReader(unsigned char const *buf = nullptr, size_t size = 0)
: buf_begin(buf), buf_end(buf + size),
- cursor(buf), cursor_base(NULL), good(buf != NULL) {
+ cursor(buf), cursor_base(nullptr), good(buf != nullptr) {
}
void prologue(size_t size) {
- rsl_assert(cursor_base == NULL);
+ rsl_assert(cursor_base == nullptr);
cursor_base = cursor;
}
void epilogue(size_t size) {
- rsl_assert(cursor_base != NULL);
+ rsl_assert(cursor_base != nullptr);
rsl_assert(cursor_base + size >= cursor);
cursor = cursor_base + size;
- cursor_base = NULL;
+ cursor_base = nullptr;
}
void seek(off_t off, bool from_begin = false) {
diff --git a/cpu_ref/rsCpuCore.cpp b/cpu_ref/rsCpuCore.cpp
index ee4d1e6..f40f411 100644
--- a/cpu_ref/rsCpuCore.cpp
+++ b/cpu_ref/rsCpuCore.cpp
@@ -72,11 +72,11 @@
RsdCpuReferenceImpl *cpu = new RsdCpuReferenceImpl(rsc);
if (!cpu) {
- return NULL;
+ return nullptr;
}
if (!cpu->init(version_major, version_minor, lfn, slfn)) {
delete cpu;
- return NULL;
+ return nullptr;
}
#ifndef RS_COMPATIBILITY_LIB
@@ -116,9 +116,9 @@
memset(&mTlsStruct, 0, sizeof(mTlsStruct));
mExit = false;
#ifndef RS_COMPATIBILITY_LIB
- mLinkRuntimeCallback = NULL;
- mSelectRTCallback = NULL;
- mSetupCompilerCallback = NULL;
+ mLinkRuntimeCallback = nullptr;
+ mSelectRTCallback = nullptr;
+ mSetupCompilerCallback = nullptr;
#endif
}
@@ -160,7 +160,7 @@
}
//ALOGV("RS helperThread exited %p idx=%i", dc, idx);
- return NULL;
+ return nullptr;
}
void RsdCpuReferenceImpl::launchThreads(WorkerCallback_t cbk, void *data) {
@@ -246,7 +246,7 @@
lockMutex();
if (!gThreadTLSKeyCount) {
- int status = pthread_key_create(&gThreadTLSKey, NULL);
+ int status = pthread_key_create(&gThreadTLSKey, nullptr);
if (status) {
ALOGE("Failed to init thread tls key.");
unlockMutex();
@@ -257,7 +257,7 @@
unlockMutex();
mTlsStruct.mContext = mRSC;
- mTlsStruct.mScript = NULL;
+ mTlsStruct.mScript = nullptr;
int status = pthread_setspecific(gThreadTLSKey, &mTlsStruct);
if (status) {
ALOGE("pthread_setspecific %i", status);
@@ -282,7 +282,7 @@
mWorkers.mThreadId = (pthread_t *) calloc(mWorkers.mCount, sizeof(pthread_t));
mWorkers.mNativeThreadId = (pid_t *) calloc(mWorkers.mCount, sizeof(pid_t));
mWorkers.mLaunchSignals = new Signal[mWorkers.mCount];
- mWorkers.mLaunchCallback = NULL;
+ mWorkers.mLaunchCallback = nullptr;
mWorkers.mCompleteSignal.init();
@@ -322,8 +322,8 @@
RsdCpuReferenceImpl::~RsdCpuReferenceImpl() {
mExit = true;
- mWorkers.mLaunchData = NULL;
- mWorkers.mLaunchCallback = NULL;
+ mWorkers.mLaunchData = nullptr;
+ mWorkers.mLaunchCallback = nullptr;
mWorkers.mRunningCount = mWorkers.mCount;
__sync_synchronize();
for (uint32_t ct = 0; ct < mWorkers.mCount; ct++) {
@@ -569,7 +569,7 @@
if (sc) {
tls->mScript = sc->getScript();
} else {
- tls->mScript = NULL;
+ tls->mScript = nullptr;
}
return old;
}
@@ -591,7 +591,7 @@
#endif
)) {
delete i;
- return NULL;
+ return nullptr;
}
return i;
}
@@ -622,7 +622,7 @@
RsdCpuReference::CpuScript * RsdCpuReferenceImpl::createIntrinsic(const Script *s,
RsScriptIntrinsicID iid, Element *e) {
- RsdCpuScriptImpl *i = NULL;
+ RsdCpuScriptImpl *i = nullptr;
switch (iid) {
case RS_SCRIPT_INTRINSIC_ID_3DLUT:
i = rsdIntrinsic_3DLUT(this, s, e);
@@ -671,7 +671,7 @@
CpuScriptGroupImpl *sgi = new CpuScriptGroupImpl(this, sg);
if (!sgi->init()) {
delete sgi;
- return NULL;
+ return nullptr;
}
return sgi;
}
diff --git a/cpu_ref/rsCpuCore.h b/cpu_ref/rsCpuCore.h
index 2fea3fc..bfd5e51 100644
--- a/cpu_ref/rsCpuCore.h
+++ b/cpu_ref/rsCpuCore.h
@@ -65,11 +65,11 @@
~RsExpandKernelDriverInfo() {
if (heapAllocatedArrays) {
- if (inPtrs != NULL) {
+ if (inPtrs != nullptr) {
delete[] inPtrs;
}
- if (inStrides != NULL) {
+ if (inStrides != nullptr) {
delete[] inStrides;
}
}
diff --git a/cpu_ref/rsCpuIntrinsicBlur.cpp b/cpu_ref/rsCpuIntrinsicBlur.cpp
index 7f888e9..3214d42 100644
--- a/cpu_ref/rsCpuIntrinsicBlur.cpp
+++ b/cpu_ref/rsCpuIntrinsicBlur.cpp
@@ -414,7 +414,7 @@
const Script *s, const Element *e)
: RsdCpuScriptIntrinsic(ctx, s, e, RS_SCRIPT_INTRINSIC_ID_BLUR) {
- mRootPtr = NULL;
+ mRootPtr = nullptr;
if (e->getType() == RS_TYPE_UNSIGNED_8) {
switch (e->getVectorSize()) {
case 1:
diff --git a/cpu_ref/rsCpuIntrinsicColorMatrix.cpp b/cpu_ref/rsCpuIntrinsicColorMatrix.cpp
index f072e52..af75701 100644
--- a/cpu_ref/rsCpuIntrinsicColorMatrix.cpp
+++ b/cpu_ref/rsCpuIntrinsicColorMatrix.cpp
@@ -464,7 +464,7 @@
void * selectKernel(Key_t key)
{
- void * kernel = NULL;
+ void * kernel = nullptr;
// inType, outType float if nonzero
if (!(key.u.inType || key.u.outType)) {
@@ -491,7 +491,7 @@
}
uint8_t *buf = mBuf;
- uint8_t *buf2 = NULL;
+ uint8_t *buf2 = nullptr;
int ops[5][4]; // 0=unused, 1 = set, 2 = accumulate, 3 = final
int opInit[4] = {0, 0, 0, 0};
@@ -901,7 +901,7 @@
if(x2 > x1) {
int32_t len = x2 - x1;
if (gArchUseSIMD) {
- if((cp->mOptKernel != NULL) && (len >= 4)) {
+ if((cp->mOptKernel != nullptr) && (len >= 4)) {
// The optimized kernel processes 4 pixels at once
// and requires a minimum of 1 chunk of 4
cp->mOptKernel(out, in, cp->ip, len >> 2);
@@ -963,17 +963,17 @@
Key_t key = computeKey(ein, eout);
#if defined(ARCH_X86_HAVE_SSSE3)
- if ((mOptKernel == NULL) || (mLastKey.key != key.key)) {
+ if ((mOptKernel == nullptr) || (mLastKey.key != key.key)) {
// FIXME: Disable mOptKernel to pass RS color matrix CTS cases
// mOptKernel = (void (*)(void *, const void *, const short *, uint32_t)) selectKernel(key);
mLastKey = key;
}
#else //if !defined(ARCH_X86_HAVE_SSSE3)
- if ((mOptKernel == NULL) || (mLastKey.key != key.key)) {
+ if ((mOptKernel == nullptr) || (mLastKey.key != key.key)) {
if (mBuf) munmap(mBuf, mBufSize);
- mBuf = NULL;
- mOptKernel = NULL;
+ mBuf = nullptr;
+ mOptKernel = nullptr;
if (build(key)) {
mOptKernel = (void (*)(void *, const void *, const short *, uint32_t)) mBuf;
}
@@ -1008,9 +1008,9 @@
: RsdCpuScriptIntrinsic(ctx, s, e, RS_SCRIPT_INTRINSIC_ID_COLOR_MATRIX) {
mLastKey.key = 0;
- mBuf = NULL;
+ mBuf = nullptr;
mBufSize = 0;
- mOptKernel = NULL;
+ mOptKernel = nullptr;
const static float defaultMatrix[] = {
1.f, 0.f, 0.f, 0.f,
0.f, 1.f, 0.f, 0.f,
@@ -1024,8 +1024,8 @@
RsdCpuScriptIntrinsicColorMatrix::~RsdCpuScriptIntrinsicColorMatrix() {
if (mBuf) munmap(mBuf, mBufSize);
- mBuf = NULL;
- mOptKernel = NULL;
+ mBuf = nullptr;
+ mOptKernel = nullptr;
}
void RsdCpuScriptIntrinsicColorMatrix::populateScript(Script *s) {
diff --git a/cpu_ref/rsCpuIntrinsicHistogram.cpp b/cpu_ref/rsCpuIntrinsicHistogram.cpp
index d3dce6d..4779187 100644
--- a/cpu_ref/rsCpuIntrinsicHistogram.cpp
+++ b/cpu_ref/rsCpuIntrinsicHistogram.cpp
@@ -299,7 +299,7 @@
const Script *s, const Element *e)
: RsdCpuScriptIntrinsic(ctx, s, e, RS_SCRIPT_INTRINSIC_ID_HISTOGRAM) {
- mRootPtr = NULL;
+ mRootPtr = nullptr;
mSums = new int[256 * 4 * mCtx->getThreadCount()];
mDot[0] = 0.299f;
mDot[1] = 0.587f;
diff --git a/cpu_ref/rsCpuIntrinsicLoopFilter.cpp b/cpu_ref/rsCpuIntrinsicLoopFilter.cpp
index 05ccfd6..d6fb6c1 100644
--- a/cpu_ref/rsCpuIntrinsicLoopFilter.cpp
+++ b/cpu_ref/rsCpuIntrinsicLoopFilter.cpp
@@ -248,7 +248,7 @@
pthread_cond_signal(&mPrch.start_cond[i]);
}
for (i = 0; i < mWorkerCount; ++i) {
- pthread_join(mPrch.tid[i], NULL);
+ pthread_join(mPrch.tid[i], nullptr);
}
free(mPrch.tid);
}
@@ -1127,7 +1127,7 @@
pthread_cond_wait(¶m->start_cond[wid], ¶m->mutex[wid]);
pthread_mutex_unlock(¶m->mutex[wid]);
- if (android_atomic_release_load(¶m->quit)) return NULL;
+ if (android_atomic_release_load(¶m->quit)) return nullptr;
buf_start[0] = param->buffer_alloc + buf_info->y_offset;
buf_start[1] = param->buffer_alloc + buf_info->u_offset;
@@ -1196,7 +1196,7 @@
pthread_mutex_unlock(param->hmutex);
}
- return NULL;
+ return nullptr;
}
RsdCpuScriptIntrinsicLoopFilter::RsdCpuScriptIntrinsicLoopFilter(
@@ -1221,14 +1221,14 @@
mPrch.finish = (pthread_cond_t *) (mPrch.hmutex + 1);
int i = 0;
int rv = 0;
- pthread_mutex_init(mPrch.hmutex, NULL);
- pthread_cond_init(mPrch.finish, NULL);
+ pthread_mutex_init(mPrch.hmutex, nullptr);
+ pthread_cond_init(mPrch.finish, nullptr);
for (i = 0; i < mWorkerCount; ++i) {
- pthread_mutex_init(&mPrch.mutex[i], NULL);
- pthread_cond_init(&mPrch.start_cond[i], NULL);
+ pthread_mutex_init(&mPrch.mutex[i], nullptr);
+ pthread_cond_init(&mPrch.start_cond[i], nullptr);
}
for (i = 0; i < mWorkerCount; ++i) {
- rv = pthread_create(&mPrch.tid[i], NULL, &vp9_loop_filter_rows_work_proc, &mPrch);
+ rv = pthread_create(&mPrch.tid[i], nullptr, &vp9_loop_filter_rows_work_proc, &mPrch);
rsAssert(rv == 0);
}
}
diff --git a/cpu_ref/rsCpuIntrinsicYuvToRGB.cpp b/cpu_ref/rsCpuIntrinsicYuvToRGB.cpp
index 390ca3c..497e19c 100644
--- a/cpu_ref/rsCpuIntrinsicYuvToRGB.cpp
+++ b/cpu_ref/rsCpuIntrinsicYuvToRGB.cpp
@@ -110,7 +110,7 @@
return;
}
const uchar *pinY = (const uchar *)cp->alloc->mHal.drvState.lod[0].mallocPtr;
- if (pinY == NULL) {
+ if (pinY == nullptr) {
ALOGE("YuvToRGB executed without data, skipping");
return;
}
@@ -143,7 +143,7 @@
//ALOGE("dimX, %d, dimY, %d", cp->alloc->mHal.drvState.lod[0].dimX, cp->alloc->mHal.drvState.lod[0].dimY);
//ALOGE("p->dimX, %d, p->dimY, %d", p->dimX, p->dimY);
- if (pinU == NULL) {
+ if (pinU == nullptr) {
// Legacy yuv support didn't fill in uv
v = ((uint8_t *)cp->alloc->mHal.drvState.lod[0].mallocPtr) +
(strideY * p->dimY) +
diff --git a/cpu_ref/rsCpuRuntimeMath.cpp b/cpu_ref/rsCpuRuntimeMath.cpp
index db8cee9..5e66bbd 100644
--- a/cpu_ref/rsCpuRuntimeMath.cpp
+++ b/cpu_ref/rsCpuRuntimeMath.cpp
@@ -312,7 +312,7 @@
{ "_Z6rsRandff", (void *)&SC_randf2, true },
{ "_Z6rsFracf", (void *)&SC_frac, true },
- { NULL, NULL, false }
+ { nullptr, nullptr, false }
};
const RsdCpuReference::CpuSymbol * RsdCpuScriptImpl::lookupSymbolMath(const char *sym) {
@@ -324,6 +324,6 @@
}
syms++;
}
- return NULL;
+ return nullptr;
}
diff --git a/cpu_ref/rsCpuRuntimeStubs.cpp b/cpu_ref/rsCpuRuntimeStubs.cpp
index 6210f33..6dc3688 100644
--- a/cpu_ref/rsCpuRuntimeStubs.cpp
+++ b/cpu_ref/rsCpuRuntimeStubs.cpp
@@ -301,14 +301,14 @@
{ "_Z7rsDebugPKcPKDv4_y", (void *)&SC_debugUL4, true },
{ "_Z7rsDebugPKcPKv", (void *)&SC_debugP, true },
- { NULL, NULL, false }
+ { nullptr, nullptr, false }
};
void * RsdCpuScriptImpl::lookupRuntimeStub(void* pContext, char const* name) {
RsdCpuScriptImpl *s = (RsdCpuScriptImpl *)pContext;
const RsdCpuReference::CpuSymbol *syms = gSyms;
- const RsdCpuReference::CpuSymbol *sym = NULL;
+ const RsdCpuReference::CpuSymbol *sym = nullptr;
sym = s->mCtx->symLookup(name);
if (!sym) {
@@ -328,7 +328,7 @@
return sym->fnPtr;
}
ALOGE("ScriptC sym lookup failed for %s", name);
- return NULL;
+ return nullptr;
}
diff --git a/cpu_ref/rsCpuScript.cpp b/cpu_ref/rsCpuScript.cpp
index e0b4004..a89e38d 100644
--- a/cpu_ref/rsCpuScript.cpp
+++ b/cpu_ref/rsCpuScript.cpp
@@ -92,11 +92,11 @@
// independent).
static std::set<std::string> LoadedLibraries;
- void *loaded = NULL;
+ void *loaded = nullptr;
// Skip everything if we don't even have the original library available.
if (access(origName, F_OK) != 0) {
- return NULL;
+ return nullptr;
}
// Common path is that we have not loaded this Script/library before.
@@ -113,7 +113,7 @@
if (!ensureCacheDirExists(newName.c_str())) {
ALOGE("Could not verify or create cache dir: %s", cacheDir);
- return NULL;
+ return nullptr;
}
// Construct an appropriately randomized filename for the symlink.
@@ -126,7 +126,7 @@
int r = symlink(origName, newName.c_str());
if (r != 0) {
ALOGE("Could not create symlink %s -> %s", newName.c_str(), origName);
- return NULL;
+ return nullptr;
}
loaded = dlopen(newName.c_str(), RTLD_NOW | RTLD_LOCAL);
r = unlink(newName.c_str());
@@ -146,7 +146,7 @@
// This is required behavior to implement script instancing for the support
// library, since shared objects are loaded and de-duped by name only.
static void *loadSharedLibrary(const char *cacheDir, const char *resName) {
- void *loaded = NULL;
+ void *loaded = nullptr;
//arc4random_stir();
#ifndef RS_SERVER
std::string scriptSOName(cacheDir);
@@ -167,7 +167,7 @@
// location for shared libraries first.
loaded = loadSOHelper(scriptSOName.c_str(), cacheDir, resName);
- if (loaded == NULL) {
+ if (loaded == nullptr) {
ALOGE("Unable to open shared library (%s): %s",
scriptSOName.c_str(), dlerror());
@@ -181,7 +181,7 @@
scriptSONameSystem.append(".so");
loaded = loadSOHelper(scriptSONameSystem.c_str(), cacheDir,
resName);
- if (loaded == NULL) {
+ if (loaded == nullptr) {
ALOGE("Unable to open system shared library (%s): %s",
scriptSONameSystem.c_str(), dlerror());
}
@@ -245,7 +245,7 @@
}
args->push_back(bcFileName.c_str());
- args->push_back(NULL);
+ args->push_back(nullptr);
}
static bool compileBitcode(const std::string &bcFileName,
@@ -318,10 +318,10 @@
#define OBJECT_SLOT_STR "objectSlotCount: "
// Copy up to a newline or size chars from str -> s, updating str
-// Returns s when successful and NULL when '\0' is finally reached.
+// Returns s when successful and nullptr when '\0' is finally reached.
static char* strgets(char *s, int size, const char **ppstr) {
if (!ppstr || !*ppstr || **ppstr == '\0' || size < 1) {
- return NULL;
+ return nullptr;
}
int i;
@@ -348,27 +348,27 @@
mScript = s;
#ifdef RS_COMPATIBILITY_LIB
- mScriptSO = NULL;
- mInvokeFunctions = NULL;
- mForEachFunctions = NULL;
- mFieldAddress = NULL;
- mFieldIsObject = NULL;
- mForEachSignatures = NULL;
+ mScriptSO = nullptr;
+ mInvokeFunctions = nullptr;
+ mForEachFunctions = nullptr;
+ mFieldAddress = nullptr;
+ mFieldIsObject = nullptr;
+ mForEachSignatures = nullptr;
#else
- mCompilerContext = NULL;
- mCompilerDriver = NULL;
- mExecutable = NULL;
+ mCompilerContext = nullptr;
+ mCompilerDriver = nullptr;
+ mExecutable = nullptr;
#endif
- mRoot = NULL;
- mRootExpand = NULL;
- mInit = NULL;
- mFreeChildren = NULL;
+ mRoot = nullptr;
+ mRootExpand = nullptr;
+ mInit = nullptr;
+ mFreeChildren = nullptr;
- mBoundAllocs = NULL;
- mIntrinsicData = NULL;
+ mBoundAllocs = nullptr;
+ mIntrinsicData = nullptr;
mIsThreadable = true;
}
@@ -383,19 +383,19 @@
#ifndef RS_COMPATIBILITY_LIB
bool useRSDebugContext = false;
- mCompilerContext = NULL;
- mCompilerDriver = NULL;
- mExecutable = NULL;
+ mCompilerContext = nullptr;
+ mCompilerDriver = nullptr;
+ mExecutable = nullptr;
mCompilerContext = new bcc::BCCContext();
- if (mCompilerContext == NULL) {
+ if (mCompilerContext == nullptr) {
ALOGE("bcc: FAILS to create compiler context (out of memory)");
mCtx->unlockMutex();
return false;
}
mCompilerDriver = new bcc::RSCompilerDriver();
- if (mCompilerDriver == NULL) {
+ if (mCompilerDriver == nullptr) {
ALOGE("bcc: FAILS to create compiler driver (out of memory)");
mCtx->unlockMutex();
return false;
@@ -410,7 +410,7 @@
// Run any compiler setup functions we have been provided with.
RSSetupCompilerCallback setupCompilerCallback =
mCtx->getSetupCompilerCallback();
- if (setupCompilerCallback != NULL) {
+ if (setupCompilerCallback != nullptr) {
setupCompilerCallback(mCompilerDriver);
}
@@ -436,7 +436,7 @@
std::vector<const char*> compileArguments;
setCompileArguments(&compileArguments, bcFileName, cacheDir, resName, core_lib,
useRSDebugContext, bccPluginName);
- // The last argument of compileArguments ia a NULL, so remove 1 from the size.
+ // The last argument of compileArguments ia a nullptr, so remove 1 from the size.
std::string compileCommandLine =
bcc::getCommandLine(compileArguments.size() - 1, compileArguments.data());
@@ -449,7 +449,7 @@
// If we can't, it's either not there or out of date. We compile the bit code and try loading
// again.
- if (mExecutable == NULL) {
+ if (mExecutable == nullptr) {
if (!compileBitcode(bcFileName, (const char*)bitcode, bitcodeSize, compileArguments.data(),
compileCommandLine)) {
ALOGE("bcc: FAILS to compile '%s'", resName);
@@ -459,7 +459,7 @@
mExecutable = bcc::RSCompilerDriver::loadScript(cacheDir, resName, (const char*)bitcode,
bitcodeSize, compileCommandLine.c_str(),
mResolver);
- if (mExecutable == NULL) {
+ if (mExecutable == nullptr) {
ALOGE("bcc: FAILS to load freshly compiled executable for '%s'", resName);
mCtx->unlockMutex();
return false;
@@ -519,7 +519,7 @@
}
size_t varCount = 0;
- if (strgets(line, MAXLINE, &rsInfo) == NULL) {
+ if (strgets(line, MAXLINE, &rsInfo) == nullptr) {
goto error;
}
if (sscanf(line, EXPORT_VAR_STR "%zu", &varCount) != 1) {
@@ -533,16 +533,16 @@
// Start by creating/zeroing this member, since we don't want to
// accidentally clean up invalid pointers later (if we error out).
mFieldIsObject = new bool[varCount];
- if (mFieldIsObject == NULL) {
+ if (mFieldIsObject == nullptr) {
goto error;
}
memset(mFieldIsObject, 0, varCount * sizeof(*mFieldIsObject));
mFieldAddress = new void*[varCount];
- if (mFieldAddress == NULL) {
+ if (mFieldAddress == nullptr) {
goto error;
}
for (size_t i = 0; i < varCount; ++i) {
- if (strgets(line, MAXLINE, &rsInfo) == NULL) {
+ if (strgets(line, MAXLINE, &rsInfo) == nullptr) {
goto error;
}
char *c = strrchr(line, '\n');
@@ -550,7 +550,7 @@
*c = '\0';
}
mFieldAddress[i] = dlsym(mScriptSO, line);
- if (mFieldAddress[i] == NULL) {
+ if (mFieldAddress[i] == nullptr) {
ALOGE("Failed to find variable address for %s: %s",
line, dlerror());
// Not a critical error if we don't find a global variable.
@@ -563,7 +563,7 @@
}
size_t funcCount = 0;
- if (strgets(line, MAXLINE, &rsInfo) == NULL) {
+ if (strgets(line, MAXLINE, &rsInfo) == nullptr) {
goto error;
}
if (sscanf(line, EXPORT_FUNC_STR "%zu", &funcCount) != 1) {
@@ -576,11 +576,11 @@
if (funcCount > 0) {
mInvokeFunctions = new InvokeFunc_t[funcCount];
- if (mInvokeFunctions == NULL) {
+ if (mInvokeFunctions == nullptr) {
goto error;
}
for (size_t i = 0; i < funcCount; ++i) {
- if (strgets(line, MAXLINE, &rsInfo) == NULL) {
+ if (strgets(line, MAXLINE, &rsInfo) == nullptr) {
goto error;
}
char *c = strrchr(line, '\n');
@@ -589,7 +589,7 @@
}
mInvokeFunctions[i] = (InvokeFunc_t) dlsym(mScriptSO, line);
- if (mInvokeFunctions[i] == NULL) {
+ if (mInvokeFunctions[i] == nullptr) {
ALOGE("Failed to get function address for %s(): %s",
line, dlerror());
goto error;
@@ -601,7 +601,7 @@
}
size_t forEachCount = 0;
- if (strgets(line, MAXLINE, &rsInfo) == NULL) {
+ if (strgets(line, MAXLINE, &rsInfo) == nullptr) {
goto error;
}
if (sscanf(line, EXPORT_FOREACH_STR "%zu", &forEachCount) != 1) {
@@ -612,18 +612,18 @@
if (forEachCount > 0) {
mForEachSignatures = new uint32_t[forEachCount];
- if (mForEachSignatures == NULL) {
+ if (mForEachSignatures == nullptr) {
goto error;
}
mForEachFunctions = new ForEachFunc_t[forEachCount];
- if (mForEachFunctions == NULL) {
+ if (mForEachFunctions == nullptr) {
goto error;
}
for (size_t i = 0; i < forEachCount; ++i) {
unsigned int tmpSig = 0;
char tmpName[MAXLINE];
- if (strgets(line, MAXLINE, &rsInfo) == NULL) {
+ if (strgets(line, MAXLINE, &rsInfo) == nullptr) {
goto error;
}
if (sscanf(line, "%u - %" MAKE_STR(MAXLINE) "s",
@@ -637,7 +637,7 @@
mForEachSignatures[i] = tmpSig;
mForEachFunctions[i] =
(ForEachFunc_t) dlsym(mScriptSO, tmpName);
- if (i != 0 && mForEachFunctions[i] == NULL) {
+ if (i != 0 && mForEachFunctions[i] == nullptr) {
// Ignore missing root.expand functions.
// root() is always specified at location 0.
ALOGE("Failed to find forEach function address for %s: %s",
@@ -651,7 +651,7 @@
}
size_t objectSlotCount = 0;
- if (strgets(line, MAXLINE, &rsInfo) == NULL) {
+ if (strgets(line, MAXLINE, &rsInfo) == nullptr) {
goto error;
}
if (sscanf(line, OBJECT_SLOT_STR "%zu", &objectSlotCount) != 1) {
@@ -663,7 +663,7 @@
rsAssert(varCount > 0);
for (size_t i = 0; i < objectSlotCount; ++i) {
uint32_t varNum = 0;
- if (strgets(line, MAXLINE, &rsInfo) == NULL) {
+ if (strgets(line, MAXLINE, &rsInfo) == nullptr) {
goto error;
}
if (sscanf(line, "%u", &varNum) != 1) {
@@ -728,7 +728,7 @@
// If a callback has been registered to specify a library, use that.
RSSelectRTCallback selectRTCallback = mCtx->getSelectRTCallback();
- if (selectRTCallback != NULL) {
+ if (selectRTCallback != nullptr) {
return selectRTCallback((const char*)bitcode, bitcodeSize);
}
@@ -804,14 +804,18 @@
const Allocation* ain = ains[index];
// possible for this to occur if IO_OUTPUT/IO_INPUT with no bound surface
- if (ain != NULL && (const uint8_t *)ain->mHal.drvState.lod[0].mallocPtr == NULL) {
+ if (ain != nullptr &&
+ (const uint8_t *)ain->mHal.drvState.lod[0].mallocPtr == nullptr) {
+
mCtx->getContext()->setError(RS_ERROR_BAD_SCRIPT,
"rsForEach called with null in allocations");
return;
}
}
- if (aout && (const uint8_t *)aout->mHal.drvState.lod[0].mallocPtr == NULL) {
+ if (aout &&
+ (const uint8_t *)aout->mHal.drvState.lod[0].mallocPtr == nullptr) {
+
mCtx->getContext()->setError(RS_ERROR_BAD_SCRIPT,
"rsForEach called with null out allocations");
return;
@@ -834,7 +838,7 @@
}
}
- } else if (aout != NULL) {
+ } else if (aout != nullptr) {
const Type *outType = aout->getType();
mtls->fep.dimX = outType->getDimX();
@@ -847,7 +851,7 @@
return;
}
- if (inLen > 0 && aout != NULL) {
+ if (inLen > 0 && aout != nullptr) {
if (!ains[0]->hasSameDims(aout)) {
mCtx->getContext()->setError(RS_ERROR_BAD_SCRIPT,
"Failed to launch kernel; dimensions of input and output allocations do not match.");
@@ -904,8 +908,8 @@
mtls->mSliceSize = 1;
mtls->mSliceNum = 0;
- mtls->fep.inPtrs = NULL;
- mtls->fep.inStrides = NULL;
+ mtls->fep.inPtrs = nullptr;
+ mtls->fep.inStrides = nullptr;
mtls->isThreadable = mIsThreadable;
if (inLen > 0) {
@@ -935,10 +939,10 @@
}
}
- mtls->fep.outPtr = NULL;
+ mtls->fep.outPtr = nullptr;
mtls->fep.outStride.eStride = 0;
mtls->fep.outStride.yStride = 0;
- if (aout != NULL) {
+ if (aout != nullptr) {
mtls->fep.outPtr = (uint8_t *)aout->mHal.drvState.lod[0].mallocPtr;
mtls->fep.outStride.eStride = aout->getType()->getElementSizeBytes();
@@ -972,11 +976,11 @@
rsAssert(slot < mExecutable->getExportForeachFuncAddrs().size());
mtls->kernel = reinterpret_cast<ForEachFunc_t>(
mExecutable->getExportForeachFuncAddrs()[slot]);
- rsAssert(mtls->kernel != NULL);
+ rsAssert(mtls->kernel != nullptr);
mtls->sig = mExecutable->getInfo().getExportForeachFuncs()[slot].second;
#else
mtls->kernel = reinterpret_cast<ForEachFunc_t>(mForEachFunctions[slot]);
- rsAssert(mtls->kernel != NULL);
+ rsAssert(mtls->kernel != nullptr);
mtls->sig = mForEachSignatures[slot];
#endif
}
@@ -1112,7 +1116,7 @@
return;
}
- void *ptr = NULL;
+ void *ptr = nullptr;
mBoundAllocs[slot] = data;
if(data) {
ptr = data->mHal.drvState.lod[0].mallocPtr;
@@ -1155,12 +1159,12 @@
while ((var_addr_iter != var_addr_end) &&
(is_object_iter != is_object_end)) {
- // The field address can be NULL if the script-side has optimized
+ // The field address can be nullptr if the script-side has optimized
// the corresponding global variable away.
rs_object_base *obj_addr =
reinterpret_cast<rs_object_base *>(*var_addr_iter);
if (*is_object_iter) {
- if (*var_addr_iter != NULL && mCtx->getContext() != NULL) {
+ if (*var_addr_iter != nullptr && mCtx->getContext() != nullptr) {
rsrClearObject(mCtx->getContext(), obj_addr);
}
}
@@ -1189,7 +1193,7 @@
if (mFieldIsObject) {
for (size_t i = 0; i < mExportedVariableCount; ++i) {
if (mFieldIsObject[i]) {
- if (mFieldAddress[i] != NULL) {
+ if (mFieldAddress[i] != nullptr) {
rs_object_base *obj_addr =
reinterpret_cast<rs_object_base *>(mFieldAddress[i]);
rsrClearObject(mCtx->getContext(), obj_addr);
@@ -1212,7 +1216,7 @@
Allocation * RsdCpuScriptImpl::getAllocationForPointer(const void *ptr) const {
if (!ptr) {
- return NULL;
+ return nullptr;
}
for (uint32_t ct=0; ct < mScript->mHal.info.exportedVariableCount; ct++) {
@@ -1223,7 +1227,7 @@
}
}
ALOGE("rsGetAllocation, failed to find %p", ptr);
- return NULL;
+ return nullptr;
}
void RsdCpuScriptImpl::preLaunch(uint32_t slot, const Allocation ** ains,
diff --git a/cpu_ref/rsCpuScript.h b/cpu_ref/rsCpuScript.h
index c5fc183..78111ea 100644
--- a/cpu_ref/rsCpuScript.h
+++ b/cpu_ref/rsCpuScript.h
@@ -59,7 +59,7 @@
bool init(char const *resName, char const *cacheDir,
uint8_t const *bitcode, size_t bitcodeSize, uint32_t flags,
- char const *bccPluginName = NULL);
+ char const *bccPluginName = nullptr);
virtual void populateScript(Script *);
virtual void invokeFunction(uint32_t slot, const void *params, size_t paramLength);
diff --git a/cpu_ref/rsCpuScriptGroup.cpp b/cpu_ref/rsCpuScriptGroup.cpp
index 1d26f59..751bafb 100644
--- a/cpu_ref/rsCpuScriptGroup.cpp
+++ b/cpu_ref/rsCpuScriptGroup.cpp
@@ -87,7 +87,7 @@
}
} else {
- localIns[0] = NULL;
+ localIns[0] = nullptr;
localStride[0] = 0;
}
@@ -109,7 +109,7 @@
sl->outs[ct]->mHal.drvState.lod[0].stride * kparams->lid;
}
} else {
- mkparams->out = NULL;
+ mkparams->out = nullptr;
ostep = 0;
}
@@ -153,8 +153,8 @@
for (size_t ct2=0; ct2 < n->mKernels.size(); ct2++) {
const ScriptKernelID *k = n->mKernels[ct2];
- Allocation *ain = NULL;
- Allocation *aout = NULL;
+ Allocation *ain = nullptr;
+ Allocation *aout = nullptr;
bool inExt = false;
bool outExt = false;
@@ -164,7 +164,7 @@
break;
}
}
- if (ain == NULL) {
+ if (ain == nullptr) {
for (size_t ct3=0; ct3 < mSG->mInputs.size(); ct3++) {
if (mSG->mInputs[ct3]->mKernel == k) {
ain = mSG->mInputs[ct3]->mAlloc.get();
@@ -177,13 +177,13 @@
for (size_t ct3=0; ct3 < n->mOutputs.size(); ct3++) {
if (n->mOutputs[ct3]->mSource.get() == k) {
aout = n->mOutputs[ct3]->mAlloc.get();
- if(n->mOutputs[ct3]->mDstField.get() != NULL) {
+ if(n->mOutputs[ct3]->mDstField.get() != nullptr) {
fieldDep = true;
}
break;
}
}
- if (aout == NULL) {
+ if (aout == nullptr) {
for (size_t ct3=0; ct3 < mSG->mOutputs.size(); ct3++) {
if (mSG->mOutputs[ct3]->mKernel == k) {
aout = mSG->mOutputs[ct3]->mAlloc.get();
@@ -193,8 +193,8 @@
}
}
- rsAssert((k->mHasKernelOutput == (aout != NULL)) &&
- (k->mHasKernelInput == (ain != NULL)));
+ rsAssert((k->mHasKernelOutput == (aout != nullptr)) &&
+ (k->mHasKernelInput == (ain != nullptr)));
ins.push_back(ain);
inExts.push_back(inExt);
@@ -216,24 +216,24 @@
uint32_t inLen;
const Allocation **ains;
- if (ins[ct] == NULL) {
+ if (ins[ct] == nullptr) {
inLen = 0;
- ains = NULL;
+ ains = nullptr;
} else {
inLen = 1;
ains = const_cast<const Allocation**>(&ins[ct]);
}
- si->forEachMtlsSetup(ains, inLen, outs[ct], NULL, 0, NULL, &mtls);
+ si->forEachMtlsSetup(ains, inLen, outs[ct], nullptr, 0, nullptr, &mtls);
si->forEachKernelSetup(slot, &mtls);
si->preLaunch(slot, ains, inLen, outs[ct], mtls.fep.usr,
- mtls.fep.usrLen, NULL);
+ mtls.fep.usrLen, nullptr);
- mCtx->launchThreads(ains, inLen, outs[ct], NULL, &mtls);
+ mCtx->launchThreads(ains, inLen, outs[ct], nullptr, &mtls);
- si->postLaunch(slot, ains, inLen, outs[ct], NULL, 0, NULL);
+ si->postLaunch(slot, ains, inLen, outs[ct], nullptr, 0, nullptr);
}
} else {
ScriptList sl;
@@ -251,9 +251,9 @@
uint32_t inLen;
const Allocation **ains;
- if (ins[0] == NULL) {
+ if (ins[0] == nullptr) {
inLen = 0;
- ains = NULL;
+ ains = nullptr;
} else {
inLen = 1;
@@ -272,7 +272,7 @@
usrPtrs.push_back(mtls.fep.usr);
sigs.push_back(mtls.fep.usrLen);
si->preLaunch(kernels[ct]->mSlot, ains, inLen, outs[ct],
- mtls.fep.usr, mtls.fep.usrLen, NULL);
+ mtls.fep.usr, mtls.fep.usrLen, nullptr);
}
sl.sigs = &sigs.front();
@@ -285,19 +285,19 @@
Script *s = kernels[0]->mScript;
RsdCpuScriptImpl *si = (RsdCpuScriptImpl *)mCtx->lookupScript(s);
- si->forEachMtlsSetup(ains, inLen, outs[0], NULL, 0, NULL, &mtls);
+ si->forEachMtlsSetup(ains, inLen, outs[0], nullptr, 0, nullptr, &mtls);
- mtls.script = NULL;
+ mtls.script = nullptr;
mtls.kernel = (void (*)())&scriptGroupRoot;
mtls.fep.usr = &sl;
- mCtx->launchThreads(ains, inLen, outs[0], NULL, &mtls);
+ mCtx->launchThreads(ains, inLen, outs[0], nullptr, &mtls);
for (size_t ct=0; ct < kernels.size(); ct++) {
Script *s = kernels[ct]->mScript;
RsdCpuScriptImpl *si = (RsdCpuScriptImpl *)mCtx->lookupScript(s);
- si->postLaunch(kernels[ct]->mSlot, ains, inLen, outs[ct], NULL, 0,
- NULL);
+ si->postLaunch(kernels[ct]->mSlot, ains, inLen, outs[ct], nullptr, 0,
+ nullptr);
}
}
}
diff --git a/cpu_ref/rsd_cpu.h b/cpu_ref/rsd_cpu.h
index 4728b7c..b0e924e 100644
--- a/cpu_ref/rsd_cpu.h
+++ b/cpu_ref/rsd_cpu.h
@@ -112,9 +112,9 @@
static RsdCpuReference * create(Context *c, uint32_t version_major,
uint32_t version_minor, sym_lookup_t lfn, script_lookup_t slfn
#ifndef RS_COMPATIBILITY_LIB
- , bcc::RSLinkRuntimeCallback pLinkRuntimeCallback = NULL,
- RSSelectRTCallback pSelectRTCallback = NULL,
- const char *pBccPluginName = NULL
+ , bcc::RSLinkRuntimeCallback pLinkRuntimeCallback = nullptr,
+ RSSelectRTCallback pSelectRTCallback = nullptr,
+ const char *pBccPluginName = nullptr
#endif
);
virtual ~RsdCpuReference();