--- a/mozglue/android/APKOpen.cpp
+++ b/mozglue/android/APKOpen.cpp
@@ -94,56 +94,56 @@ static uint64_t TimeStamp_Now()
if (rv != 0) {
return 0;
}
uint64_t baseNs = (uint64_t)ts.tv_sec * 1000000000;
return baseNs + (uint64_t)ts.tv_nsec;
}
-static struct mapping_info * lib_mapping = NULL;
+static struct mapping_info * lib_mapping = nullptr;
NS_EXPORT const struct mapping_info *
getLibraryMapping()
{
return lib_mapping;
}
void
JNI_Throw(JNIEnv* jenv, const char* classname, const char* msg)
{
__android_log_print(ANDROID_LOG_ERROR, "GeckoLibLoad", "Throw\n");
jclass cls = jenv->FindClass(classname);
- if (cls == NULL) {
+ if (cls == nullptr) {
__android_log_print(ANDROID_LOG_ERROR, "GeckoLibLoad", "Couldn't find exception class (or exception pending) %s\n", classname);
exit(FAILURE);
}
int rc = jenv->ThrowNew(cls, msg);
if (rc < 0) {
__android_log_print(ANDROID_LOG_ERROR, "GeckoLibLoad", "Error throwing exception %s\n", msg);
exit(FAILURE);
}
jenv->DeleteLocalRef(cls);
}
#define JNI_STUBS
#include "jni-stubs.inc"
#undef JNI_STUBS
-static void * xul_handle = NULL;
+static void * xul_handle = nullptr;
#ifndef MOZ_FOLD_LIBS
-static void * sqlite_handle = NULL;
-static void * nspr_handle = NULL;
-static void * plc_handle = NULL;
+static void * sqlite_handle = nullptr;
+static void * nspr_handle = nullptr;
+static void * plc_handle = nullptr;
#else
#define sqlite_handle nss_handle
#define nspr_handle nss_handle
#define plc_handle nss_handle
#endif
-static void * nss_handle = NULL;
+static void * nss_handle = nullptr;
template <typename T> inline void
xul_dlsym(const char *symbolName, T *value)
{
*value = (T) (uintptr_t) __wrap_dlsym(xul_handle, symbolName);
}
static int mapping_count = 0;
@@ -300,18 +300,18 @@ loadNSSLibs(const char *apkName)
}
extern "C" NS_EXPORT void JNICALL
Java_org_mozilla_gecko_mozglue_GeckoLoader_loadGeckoLibsNative(JNIEnv *jenv, jclass jGeckoAppShellClass, jstring jApkName)
{
const char* str;
// XXX: java doesn't give us true UTF8, we should figure out something
// better to do here
- str = jenv->GetStringUTFChars(jApkName, NULL);
- if (str == NULL)
+ str = jenv->GetStringUTFChars(jApkName, nullptr);
+ if (str == nullptr)
return;
int res = loadGeckoLibs(str);
if (res != SUCCESS) {
JNI_Throw(jenv, "java/lang/Exception", "Error loading gecko libraries");
}
jenv->ReleaseStringUTFChars(jApkName, str);
}
@@ -320,18 +320,18 @@ extern "C" NS_EXPORT void JNICALL
Java_org_mozilla_gecko_mozglue_GeckoLoader_loadSQLiteLibsNative(JNIEnv *jenv, jclass jGeckoAppShellClass, jstring jApkName, jboolean jShouldExtract) {
if (jShouldExtract) {
putenv("MOZ_LINKER_EXTRACT=1");
}
const char* str;
// XXX: java doesn't give us true UTF8, we should figure out something
// better to do here
- str = jenv->GetStringUTFChars(jApkName, NULL);
- if (str == NULL)
+ str = jenv->GetStringUTFChars(jApkName, nullptr);
+ if (str == nullptr)
return;
__android_log_print(ANDROID_LOG_ERROR, "GeckoLibLoad", "Load sqlite start\n");
mozglueresult rv = loadSQLiteLibs(str);
if (rv != SUCCESS) {
JNI_Throw(jenv, "java/lang/Exception", "Error loading sqlite libraries");
}
__android_log_print(ANDROID_LOG_ERROR, "GeckoLibLoad", "Load sqlite done\n");
@@ -342,18 +342,18 @@ extern "C" NS_EXPORT void JNICALL
Java_org_mozilla_gecko_mozglue_GeckoLoader_loadNSSLibsNative(JNIEnv *jenv, jclass jGeckoAppShellClass, jstring jApkName, jboolean jShouldExtract) {
if (jShouldExtract) {
putenv("MOZ_LINKER_EXTRACT=1");
}
const char* str;
// XXX: java doesn't give us true UTF8, we should figure out something
// better to do here
- str = jenv->GetStringUTFChars(jApkName, NULL);
- if (str == NULL)
+ str = jenv->GetStringUTFChars(jApkName, nullptr);
+ if (str == nullptr)
return;
__android_log_print(ANDROID_LOG_ERROR, "GeckoLibLoad", "Load nss start\n");
mozglueresult rv = loadNSSLibs(str);
if (rv != SUCCESS) {
JNI_Throw(jenv, "java/lang/Exception", "Error loading nss libraries");
}
__android_log_print(ANDROID_LOG_ERROR, "GeckoLibLoad", "Load nss done\n");
@@ -362,17 +362,17 @@ Java_org_mozilla_gecko_mozglue_GeckoLoad
typedef void (*GeckoStart_t)(void *, const nsXREAppData *);
extern "C" NS_EXPORT void JNICALL
Java_org_mozilla_gecko_mozglue_GeckoLoader_nativeRun(JNIEnv *jenv, jclass jc, jstring jargs)
{
GeckoStart_t GeckoStart;
xul_dlsym("GeckoStart", &GeckoStart);
- if (GeckoStart == NULL)
+ if (GeckoStart == nullptr)
return;
// XXX: java doesn't give us true UTF8, we should figure out something
// better to do here
int len = jenv->GetStringUTFLength(jargs);
// GeckoStart needs to write in the args buffer, so we need a copy.
char *args = (char *) malloc(len + 1);
jenv->GetStringUTFRegion(jargs, 0, len, args);
args[len] = '\0';
--- a/mozglue/android/NSSBridge.cpp
+++ b/mozglue/android/NSSBridge.cpp
@@ -44,17 +44,17 @@ NSS_WRAPPER_INT(PL_Base64Encode)
NSS_WRAPPER_INT(PL_Base64Decode)
NSS_WRAPPER_INT(PL_strfree)
int
setup_nss_functions(void *nss_handle,
void *nspr_handle,
void *plc_handle)
{
- if (nss_handle == NULL || nspr_handle == NULL || plc_handle == NULL) {
+ if (nss_handle == nullptr || nspr_handle == nullptr || plc_handle == nullptr) {
LOG("Missing handle\n");
return FAILURE;
}
#define GETFUNC(name) f_ ## name = (name ## _t) (uintptr_t) __wrap_dlsym(nss_handle, #name); \
if (!f_ ##name) return FAILURE;
GETFUNC(NSS_Initialize);
GETFUNC(NSS_Shutdown);
GETFUNC(PK11SDR_Encrypt);
@@ -99,20 +99,20 @@ throwError(JNIEnv* jenv, const char * fu
extern "C" NS_EXPORT jstring JNICALL
Java_org_mozilla_gecko_NSSBridge_nativeEncrypt(JNIEnv* jenv, jclass,
jstring jPath,
jstring jValue)
{
jstring ret = jenv->NewStringUTF("");
const char* path;
- path = jenv->GetStringUTFChars(jPath, NULL);
+ path = jenv->GetStringUTFChars(jPath, nullptr);
const char* value;
- value = jenv->GetStringUTFChars(jValue, NULL);
+ value = jenv->GetStringUTFChars(jValue, nullptr);
char* result;
SECStatus rv = doCrypto(jenv, path, value, &result, true);
if (rv == SECSuccess) {
ret = jenv->NewStringUTF(result);
free(result);
}
@@ -125,20 +125,20 @@ Java_org_mozilla_gecko_NSSBridge_nativeE
extern "C" NS_EXPORT jstring JNICALL
Java_org_mozilla_gecko_NSSBridge_nativeDecrypt(JNIEnv* jenv, jclass,
jstring jPath,
jstring jValue)
{
jstring ret = jenv->NewStringUTF("");
const char* path;
- path = jenv->GetStringUTFChars(jPath, NULL);
+ path = jenv->GetStringUTFChars(jPath, nullptr);
const char* value;
- value = jenv->GetStringUTFChars(jValue, NULL);
+ value = jenv->GetStringUTFChars(jValue, nullptr);
char* result;
SECStatus rv = doCrypto(jenv, path, value, &result, false);
if (rv == SECSuccess) {
ret = jenv->NewStringUTF(result);
free(result);
}
@@ -168,17 +168,17 @@ doCrypto(JNIEnv* jenv, const char *path,
slot = f_PK11_GetInternalKeySlot();
if (!slot) {
throwError(jenv, "PK11_GetInternalKeySlot");
return SECFailure;
}
if (f_PK11_NeedUserInit(slot)) {
LOG("Initializing key3.db with default blank password.\n");
- rv = f_PK11_InitPin(slot, NULL, NULL);
+ rv = f_PK11_InitPin(slot, nullptr, nullptr);
if (rv != SECSuccess) {
throwError(jenv, "PK11_InitPin");
return rv;
}
}
SECItem request;
SECItem reply;
@@ -190,17 +190,17 @@ doCrypto(JNIEnv* jenv, const char *path,
// This can print sensitive data. Uncomment if you need it.
// LOG("Encrypting: %s\n", value);
request.data = (unsigned char*)value;
request.len = strlen(value);
SECItem keyid;
keyid.data = 0;
keyid.len = 0;
- rv = f_PK11SDR_Encrypt(&keyid, &request, &reply, NULL);
+ rv = f_PK11SDR_Encrypt(&keyid, &request, &reply, nullptr);
if (rv != SECSuccess) {
throwError(jenv, "PK11SDR_Encrypt");
goto done;
}
rv = encode(reply.data, reply.len, result);
if (rv != SECSuccess) {
@@ -211,17 +211,17 @@ doCrypto(JNIEnv* jenv, const char *path,
} else {
LOG("Decoding: %s\n", value);
rv = decode(value, &request.data, (int32_t*)&request.len);
if (rv != SECSuccess) {
throwError(jenv, "decode");
return rv;
}
- rv = f_PK11SDR_Decrypt(&request, &reply, NULL);
+ rv = f_PK11SDR_Decrypt(&request, &reply, nullptr);
if (rv != SECSuccess) {
throwError(jenv, "PK11SDR_Decrypt");
goto done;
}
*result = (char *)malloc(reply.len+1);
strncpy(*result, (char *)reply.data, reply.len);
(*result)[reply.len] = '\0';
@@ -238,17 +238,17 @@ done:
/*
* Base64 encodes the data passed in. The caller must deallocate _retval using free();
*/
SECStatus
encode(const unsigned char *data, int32_t dataLen, char **_retval)
{
SECStatus rv = SECSuccess;
- char *encoded = f_PL_Base64Encode((const char *)data, dataLen, NULL);
+ char *encoded = f_PL_Base64Encode((const char *)data, dataLen, nullptr);
if (!encoded)
rv = SECFailure;
if (!*encoded)
rv = SECFailure;
if (rv == SECSuccess) {
*_retval = (char *)malloc(strlen(encoded)+1);
strcpy(*_retval, encoded);
@@ -273,17 +273,17 @@ decode(const char *data, unsigned char *
/* Compute length adjustment */
if (len > 0 && data[len-1] == '=') {
adjust++;
if (data[len-2] == '=') adjust++;
}
char *decoded;
- decoded = f_PL_Base64Decode(data, len, NULL);
+ decoded = f_PL_Base64Decode(data, len, nullptr);
if (!decoded) {
return SECFailure;
}
if (!*decoded) {
return SECFailure;
}
*length = (len*3)/4 - adjust;
--- a/mozglue/android/SQLiteBridge.cpp
+++ b/mozglue/android/SQLiteBridge.cpp
@@ -82,55 +82,55 @@ JNI_Setup(JNIEnv* jenv)
{
if (initialized) return;
jclass lObjectClass = jenv->FindClass("java/lang/Object");
jclass lStringClass = jenv->FindClass("java/lang/String");
jclass lByteBufferClass = jenv->FindClass("java/nio/ByteBuffer");
jclass lCursorClass = jenv->FindClass("org/mozilla/gecko/sqlite/MatrixBlobCursor");
- if (lStringClass == NULL
- || lObjectClass == NULL
- || lByteBufferClass == NULL
- || lCursorClass == NULL) {
+ if (lStringClass == nullptr
+ || lObjectClass == nullptr
+ || lByteBufferClass == nullptr
+ || lCursorClass == nullptr) {
LOG("Error finding classes");
JNI_Throw(jenv, "org/mozilla/gecko/sqlite/SQLiteBridgeException",
"FindClass error");
return;
}
// Those are only local references. Make them global so they work
// across calls and threads.
objectClass = (jclass)jenv->NewGlobalRef(lObjectClass);
stringClass = (jclass)jenv->NewGlobalRef(lStringClass);
byteBufferClass = (jclass)jenv->NewGlobalRef(lByteBufferClass);
cursorClass = (jclass)jenv->NewGlobalRef(lCursorClass);
- if (stringClass == NULL || objectClass == NULL
- || byteBufferClass == NULL
- || cursorClass == NULL) {
+ if (stringClass == nullptr || objectClass == nullptr
+ || byteBufferClass == nullptr
+ || cursorClass == nullptr) {
LOG("Error getting global references");
JNI_Throw(jenv, "org/mozilla/gecko/sqlite/SQLiteBridgeException",
"NewGlobalRef error");
return;
}
// public static ByteBuffer allocateDirect(int capacity)
jByteBufferAllocateDirect =
jenv->GetStaticMethodID(byteBufferClass, "allocateDirect", "(I)Ljava/nio/ByteBuffer;");
// new MatrixBlobCursor(String [])
jCursorConstructor =
jenv->GetMethodID(cursorClass, "<init>", "([Ljava/lang/String;)V");
// public void addRow (Object[] columnValues)
jCursorAddRow =
jenv->GetMethodID(cursorClass, "addRow", "([Ljava/lang/Object;)V");
- if (jByteBufferAllocateDirect == NULL
- || jCursorConstructor == NULL
- || jCursorAddRow == NULL) {
+ if (jByteBufferAllocateDirect == nullptr
+ || jCursorConstructor == nullptr
+ || jCursorAddRow == nullptr) {
LOG("Error finding methods");
JNI_Throw(jenv, "org/mozilla/gecko/sqlite/SQLiteBridgeException",
"GetMethodId error");
return;
}
initialized = true;
}
@@ -140,22 +140,22 @@ Java_org_mozilla_gecko_sqlite_SQLiteBrid
jstring jDb,
jstring jQuery,
jobjectArray jParams,
jlongArray jQueryRes)
{
JNI_Setup(jenv);
int rc;
- jobject jCursor = NULL;
+ jobject jCursor = nullptr;
const char* dbPath;
sqlite3 *db;
char* errorMsg;
- dbPath = jenv->GetStringUTFChars(jDb, NULL);
+ dbPath = jenv->GetStringUTFChars(jDb, nullptr);
rc = f_sqlite3_open(dbPath, &db);
jenv->ReleaseStringUTFChars(jDb, dbPath);
if (rc != SQLITE_OK) {
asprintf(&errorMsg, "Can't open database: %s\n", f_sqlite3_errmsg(db));
LOG("Error in SQLiteBridge: %s\n", errorMsg);
JNI_Throw(jenv, "org/mozilla/gecko/sqlite/SQLiteBridgeException", errorMsg);
// errorMsg is allocated by asprintf, it needs to be freed by libc.
__real_free(errorMsg);
@@ -170,34 +170,34 @@ extern "C" NS_EXPORT jobject JNICALL
Java_org_mozilla_gecko_sqlite_SQLiteBridge_sqliteCallWithDb(JNIEnv* jenv, jclass,
jlong jDb,
jstring jQuery,
jobjectArray jParams,
jlongArray jQueryRes)
{
JNI_Setup(jenv);
- jobject jCursor = NULL;
+ jobject jCursor = nullptr;
sqlite3 *db = (sqlite3*)jDb;
jCursor = sqliteInternalCall(jenv, db, jQuery, jParams, jQueryRes);
return jCursor;
}
extern "C" NS_EXPORT jlong JNICALL
Java_org_mozilla_gecko_sqlite_SQLiteBridge_openDatabase(JNIEnv* jenv, jclass,
jstring jDb)
{
JNI_Setup(jenv);
int rc;
const char* dbPath;
sqlite3 *db;
char* errorMsg;
- dbPath = jenv->GetStringUTFChars(jDb, NULL);
+ dbPath = jenv->GetStringUTFChars(jDb, nullptr);
rc = f_sqlite3_open(dbPath, &db);
jenv->ReleaseStringUTFChars(jDb, dbPath);
if (rc != SQLITE_OK) {
asprintf(&errorMsg, "Can't open database: %s\n", f_sqlite3_errmsg(db));
LOG("Error in SQLiteBridge: %s\n", errorMsg);
JNI_Throw(jenv, "org/mozilla/gecko/sqlite/SQLiteBridgeException", errorMsg);
// errorMsg is allocated by asprintf, it needs to be freed by libc.
__real_free(errorMsg);
@@ -219,60 +219,60 @@ static jobject
sqliteInternalCall(JNIEnv* jenv,
sqlite3 *db,
jstring jQuery,
jobjectArray jParams,
jlongArray jQueryRes)
{
JNI_Setup(jenv);
- jobject jCursor = NULL;
+ jobject jCursor = nullptr;
char* errorMsg;
jsize numPars = 0;
const char *pzTail;
sqlite3_stmt *ppStmt;
int rc;
const char* queryStr;
- queryStr = jenv->GetStringUTFChars(jQuery, NULL);
+ queryStr = jenv->GetStringUTFChars(jQuery, nullptr);
rc = f_sqlite3_prepare_v2(db, queryStr, -1, &ppStmt, &pzTail);
- if (rc != SQLITE_OK || ppStmt == NULL) {
+ if (rc != SQLITE_OK || ppStmt == nullptr) {
asprintf(&errorMsg, "Can't prepare statement: %s\n", f_sqlite3_errmsg(db));
goto error_close;
}
jenv->ReleaseStringUTFChars(jQuery, queryStr);
// Check if number of parameters matches
- if (jParams != NULL) {
+ if (jParams != nullptr) {
numPars = jenv->GetArrayLength(jParams);
}
int sqlNumPars;
sqlNumPars = f_sqlite3_bind_parameter_count(ppStmt);
if (numPars != sqlNumPars) {
asprintf(&errorMsg, "Passed parameter count (%d) doesn't match SQL parameter count (%d)\n",
numPars, sqlNumPars);
goto error_close;
}
- if (jParams != NULL) {
+ if (jParams != nullptr) {
// Bind parameters, if any
if (numPars > 0) {
for (int i = 0; i < numPars; i++) {
jobject jObjectParam = jenv->GetObjectArrayElement(jParams, i);
// IsInstanceOf or isAssignableFrom? String is final, so IsInstanceOf
// should be OK.
jboolean isString = jenv->IsInstanceOf(jObjectParam, stringClass);
if (isString != JNI_TRUE) {
asprintf(&errorMsg, "Parameter is not of String type");
goto error_close;
}
jstring jStringParam = (jstring)jObjectParam;
- const char* paramStr = jenv->GetStringUTFChars(jStringParam, NULL);
+ const char* paramStr = jenv->GetStringUTFChars(jStringParam, nullptr);
// SQLite parameters index from 1.
rc = f_sqlite3_bind_text(ppStmt, i + 1, paramStr, -1, SQLITE_TRANSIENT);
jenv->ReleaseStringUTFChars(jStringParam, paramStr);
if (rc != SQLITE_OK) {
asprintf(&errorMsg, "Error binding query parameter");
goto error_close;
}
}
@@ -289,34 +289,34 @@ sqliteInternalCall(JNIEnv* jenv,
// Get the column count and names
int cols;
cols = f_sqlite3_column_count(ppStmt);
{
// Allocate a String[cols]
jobjectArray jStringArray = jenv->NewObjectArray(cols,
stringClass,
- NULL);
- if (jStringArray == NULL) {
+ nullptr);
+ if (jStringArray == nullptr) {
asprintf(&errorMsg, "Can't allocate String[]\n");
goto error_close;
}
// Assign column names to the String[]
for (int i = 0; i < cols; i++) {
const char* colName = f_sqlite3_column_name(ppStmt, i);
jstring jStr = jenv->NewStringUTF(colName);
jenv->SetObjectArrayElement(jStringArray, i, jStr);
}
// Construct the MatrixCursor(String[]) with given column names
jCursor = jenv->NewObject(cursorClass,
jCursorConstructor,
jStringArray);
- if (jCursor == NULL) {
+ if (jCursor == nullptr) {
asprintf(&errorMsg, "Can't allocate MatrixBlobCursor\n");
goto error_close;
}
}
// Return the id and number of changed rows in jQueryRes
{
jlong id = f_sqlite3_last_insert_rowid(db);
@@ -329,50 +329,50 @@ sqliteInternalCall(JNIEnv* jenv,
// For each row, add an Object[] to the passed ArrayList,
// with that containing either String or ByteArray objects
// containing the columns
while (rc != SQLITE_DONE) {
// Process row
// Construct Object[]
jobjectArray jRow = jenv->NewObjectArray(cols,
objectClass,
- NULL);
- if (jRow == NULL) {
+ nullptr);
+ if (jRow == nullptr) {
asprintf(&errorMsg, "Can't allocate jRow Object[]\n");
goto error_close;
}
for (int i = 0; i < cols; i++) {
int colType = f_sqlite3_column_type(ppStmt, i);
if (colType == SQLITE_BLOB) {
// Treat as blob
const void* blob = f_sqlite3_column_blob(ppStmt, i);
int colLen = f_sqlite3_column_bytes(ppStmt, i);
// Construct ByteBuffer of correct size
jobject jByteBuffer =
jenv->CallStaticObjectMethod(byteBufferClass,
jByteBufferAllocateDirect,
colLen);
- if (jByteBuffer == NULL) {
+ if (jByteBuffer == nullptr) {
goto error_close;
}
// Get its backing array
void* bufferArray = jenv->GetDirectBufferAddress(jByteBuffer);
- if (bufferArray == NULL) {
+ if (bufferArray == nullptr) {
asprintf(&errorMsg, "Failure calling GetDirectBufferAddress\n");
goto error_close;
}
memcpy(bufferArray, blob, colLen);
jenv->SetObjectArrayElement(jRow, i, jByteBuffer);
jenv->DeleteLocalRef(jByteBuffer);
} else if (colType == SQLITE_NULL) {
- jenv->SetObjectArrayElement(jRow, i, NULL);
+ jenv->SetObjectArrayElement(jRow, i, nullptr);
} else {
// Treat everything else as text
const char* txt = (const char*)f_sqlite3_column_text(ppStmt, i);
jstring jStr = jenv->NewStringUTF(txt);
jenv->SetObjectArrayElement(jRow, i, jStr);
jenv->DeleteLocalRef(jStr);
}
}
--- a/mozglue/android/nsGeckoUtils.cpp
+++ b/mozglue/android/nsGeckoUtils.cpp
@@ -14,29 +14,29 @@
extern "C"
__attribute__ ((visibility("default")))
void JNICALL
Java_org_mozilla_gecko_mozglue_GeckoLoader_putenv(JNIEnv *jenv, jclass, jstring map)
{
const char* str;
// XXX: java doesn't give us true UTF8, we should figure out something
// better to do here
- str = jenv->GetStringUTFChars(map, NULL);
- if (str == NULL)
+ str = jenv->GetStringUTFChars(map, nullptr);
+ if (str == nullptr)
return;
putenv(strdup(str));
jenv->ReleaseStringUTFChars(map, str);
}
extern "C"
__attribute__ ((visibility("default")))
jobject JNICALL
Java_org_mozilla_gecko_mozglue_DirectBufferAllocator_nativeAllocateDirectBuffer(JNIEnv *jenv, jclass, jlong size)
{
- jobject buffer = NULL;
+ jobject buffer = nullptr;
void* mem = malloc(size);
if (mem) {
buffer = jenv->NewDirectByteBuffer(mem, size);
if (!buffer)
free(mem);
}
return buffer;
}
@@ -50,17 +50,17 @@ Java_org_mozilla_gecko_mozglue_DirectBuf
}
extern "C"
__attribute__ ((visibility("default")))
jlong JNICALL
Java_org_mozilla_gecko_mozglue_NativeZip_getZip(JNIEnv *jenv, jclass, jstring path)
{
const char* str;
- str = jenv->GetStringUTFChars(path, NULL);
+ str = jenv->GetStringUTFChars(path, nullptr);
if (!str || !*str) {
if (str)
jenv->ReleaseStringUTFChars(path, str);
JNI_Throw(jenv, "java/lang/IllegalArgumentException", "Invalid path");
return 0;
}
mozilla::RefPtr<Zip> zip = ZipCollection::GetZip(str);
jenv->ReleaseStringUTFChars(path, str);
@@ -99,28 +99,28 @@ Java_org_mozilla_gecko_mozglue_NativeZip
extern "C"
__attribute__ ((visibility("default")))
jobject JNICALL
Java_org_mozilla_gecko_mozglue_NativeZip__1getInputStream(JNIEnv *jenv, jobject jzip, jlong obj, jstring path)
{
Zip *zip = (Zip *)obj;
const char* str;
- str = jenv->GetStringUTFChars(path, NULL);
+ str = jenv->GetStringUTFChars(path, nullptr);
Zip::Stream stream;
bool res = zip->GetStream(str, &stream);
jenv->ReleaseStringUTFChars(path, str);
if (!res) {
- return NULL;
+ return nullptr;
}
jobject buf = jenv->NewDirectByteBuffer(const_cast<void *>(stream.GetBuffer()), stream.GetSize());
if (!buf) {
JNI_Throw(jenv, "java/lang/RuntimeException", "Failed to create ByteBuffer");
- return NULL;
+ return nullptr;
}
jclass nativeZip = jenv->GetObjectClass(jzip);
jmethodID method = jenv->GetMethodID(nativeZip, "createInputStream", "(Ljava/nio/ByteBuffer;I)Ljava/io/InputStream;");
// Since this function is only expected to be called from Java, it is safe
// to skip exception checking for the method call below, as long as no
// other Native -> Java call doesn't happen before returning to Java.
return jenv->CallObjectMethod(jzip, method, buf, (jint) stream.GetType());
}
--- a/mozglue/build/Nuwa.cpp
+++ b/mozglue/build/Nuwa.cpp
@@ -159,26 +159,26 @@ struct thread_info : public mozilla::Lin
TLSInfoList tlsInfo;
pthread_mutex_t *reacquireMutex;
void *stk;
};
typedef struct thread_info thread_info_t;
-static thread_info_t *sCurrentRecreatingThread = NULL;
+static thread_info_t *sCurrentRecreatingThread = nullptr;
/**
* This function runs the custom recreation function registered when calling
* NuwaMarkCurrentThread() after thread stack is restored.
*/
static void
RunCustomRecreation() {
thread_info_t *tinfo = sCurrentRecreatingThread;
- if (tinfo->recrFunc != NULL) {
+ if (tinfo->recrFunc != nullptr) {
tinfo->recrFunc(tinfo->recrArg);
}
}
/**
* Every thread should be marked as either TINFO_FLAG_NUWA_SUPPORT or
* TINFO_FLAG_NUWA_SKIP, or it means a potential error. We force
* Gecko code to mark every single thread to make sure there are no accidents
@@ -252,17 +252,17 @@ GetThreadInfoInner(pthread_t threadID) {
for (thread_info_t *tinfo = sAllThreads.getFirst();
tinfo;
tinfo = tinfo->getNext()) {
if (pthread_equal(tinfo->origThreadID, threadID)) {
return tinfo;
}
}
- return NULL;
+ return nullptr;
}
/**
* Get thread info using the specified thread ID.
*
* @return thread_info_t which has threadID == specified threadID
*/
static thread_info_t *
@@ -301,19 +301,19 @@ GetCurThreadInfo() {
}
}
pthread_mutex_unlock(&sThreadCountLock);
return tinfo;
}
#define CUR_THREAD_INFO GetCurThreadInfo()
#define SET_THREAD_INFO(x) /* Nothing to do. */
#else
-// Is not NULL only for threads created by pthread_create() in an Nuwa process.
-// It is always NULL for the main thread.
-static __thread thread_info_t *sCurThreadInfo = NULL;
+// Is not nullptr only for threads created by pthread_create() in an Nuwa process.
+// It is always nullptr for the main thread.
+static __thread thread_info_t *sCurThreadInfo = nullptr;
#define CUR_THREAD_INFO sCurThreadInfo
#define SET_THREAD_INFO(x) do { sCurThreadInfo = (x); } while(0)
#endif // HAVE_THREAD_TLS_KEYWORD
/*
* Track all epoll fds and handling events.
*/
class EpollManager {
@@ -381,26 +381,26 @@ public:
typedef std::map<int, EpollInfo> EpollInfoMap;
typedef EpollInfoMap::iterator iterator;
typedef EpollInfoMap::const_iterator const_iterator;
public:
void AddEpollInfo(int aEpollFd, int aBackSize) {
EpollInfo *oldinfo = FindEpollInfo(aEpollFd);
- if (oldinfo != NULL) {
+ if (oldinfo != nullptr) {
abort();
}
mEpollFdsInfo[aEpollFd] = EpollInfo(aBackSize);
}
EpollInfo *FindEpollInfo(int aEpollFd) {
iterator it = mEpollFdsInfo.find(aEpollFd);
if (it == mEpollFdsInfo.end()) {
- return NULL;
+ return nullptr;
}
return &it->second;
}
void RemoveEpollInfo(int aEpollFd) {
if (!mEpollFdsInfo.erase(aEpollFd)) {
abort();
}
@@ -420,17 +420,17 @@ public:
}
static void Shutdown() {
if (!sInstance) {
abort();
}
delete sInstance;
- sInstance = NULL;
+ sInstance = nullptr;
}
private:
static EpollManager *sInstance;
~EpollManager() {
mEpollFdsInfo.clear();
}
@@ -441,20 +441,20 @@ private:
EpollManager* EpollManager::sInstance;
static thread_info_t *
thread_info_new(void) {
/* link tinfo to sAllThreads */
thread_info_t *tinfo = new thread_info_t();
tinfo->flags = 0;
- tinfo->recrFunc = NULL;
- tinfo->recrArg = NULL;
+ tinfo->recrFunc = nullptr;
+ tinfo->recrArg = nullptr;
tinfo->recreatedThreadID = 0;
- tinfo->reacquireMutex = NULL;
+ tinfo->reacquireMutex = nullptr;
tinfo->stk = malloc(NUWA_STACK_SIZE);
pthread_attr_init(&tinfo->threadAttr);
REAL(pthread_mutex_lock)(&sThreadCountLock);
// Insert to the tail.
sAllThreads.insertBack(tinfo);
sThreadCount++;
@@ -585,17 +585,17 @@ extern "C" MFBT_API int
static void
SaveTLSInfo(thread_info_t *tinfo) {
REAL(pthread_mutex_lock)(&sTLSKeyLock);
tinfo->tlsInfo.clear();
for (TLSKeySet::const_iterator it = sTLSKeys.begin();
it != sTLSKeys.end();
it++) {
void *value = pthread_getspecific(it->first);
- if (value == NULL) {
+ if (value == nullptr) {
continue;
}
pthread_key_t key = it->first;
tinfo->tlsInfo.push_back(TLSInfoList::value_type(key, value));
}
pthread_mutex_unlock(&sTLSKeyLock);
}
@@ -657,17 +657,17 @@ extern "C" MFBT_API pthread_t
return tinfo->origThreadID;
}
return REAL(pthread_self)();
}
extern "C" MFBT_API int
__wrap_pthread_join(pthread_t thread, void **retval) {
thread_info_t *tinfo = GetThreadInfo(thread);
- if (tinfo == NULL) {
+ if (tinfo == nullptr) {
return REAL(pthread_join)(thread, retval);
}
// pthread_join() need to use the real thread ID in the spawned process.
return REAL(pthread_join)(tinfo->recreatedThreadID, retval);
}
/**
* The following are used to synchronize between the main thread and the
@@ -1169,17 +1169,17 @@ extern "C" MFBT_API int
int rv = REAL(epoll_ctl)(aEpollFd, aOp, aFd, aEvent);
if (!sIsNuwaProcess || rv == -1) {
return rv;
}
EpollManager::EpollInfo *info =
EpollManager::Singleton()->FindEpollInfo(aEpollFd);
- if (info == NULL) {
+ if (info == nullptr) {
abort();
}
switch(aOp) {
case EPOLL_CTL_ADD:
info->AddEvents(aFd, *aEvent);
break;
@@ -1230,26 +1230,26 @@ thread_recreate_startup(void *arg) {
* thread_recreate_startup() are equivalent, so
* thread_create_startup() will return successfully.
*/
thread_info_t *tinfo = (thread_info_t *)arg;
RestoreTLSInfo(tinfo);
if (setjmp(tinfo->retEnv) != 0) {
- return NULL;
+ return nullptr;
}
// longjump() to recreate the stack on the new thread.
longjmp(tinfo->jmpEnv, 1);
// Never go here!
abort();
- return NULL;
+ return nullptr;
}
/**
* Recreate the context given by tinfo at a new thread.
*/
static void
thread_recreate(thread_info_t *tinfo) {
pthread_t thread;
@@ -1275,17 +1275,17 @@ RecreateThreads() {
}
sConstructors.clear();
REAL(pthread_mutex_lock)(&sThreadCountLock);
thread_info_t *tinfo = sAllThreads.getFirst();
pthread_mutex_unlock(&sThreadCountLock);
RECREATE_START();
- while (tinfo != NULL) {
+ while (tinfo != nullptr) {
if (tinfo->flags & TINFO_FLAG_NUWA_SUPPORT) {
RECREATE_BEFORE(tinfo);
thread_recreate(tinfo);
RECREATE_WAIT();
if (tinfo->reacquireMutex) {
REAL(pthread_mutex_lock)(tinfo->reacquireMutex);
}
} else if(!(tinfo->flags & TINFO_FLAG_NUWA_SKIP)) {
@@ -1418,19 +1418,19 @@ ReplaceIPC(NuwaProtoFdInfo *aInfoList, i
}
}
/**
* Add a new content process at the chrome process.
*/
static void
AddNewProcess(pid_t pid, NuwaProtoFdInfo *aInfoList, int aInfoSize) {
- static bool (*AddNewIPCProcess)(pid_t, NuwaProtoFdInfo *, int) = NULL;
+ static bool (*AddNewIPCProcess)(pid_t, NuwaProtoFdInfo *, int) = nullptr;
- if (AddNewIPCProcess == NULL) {
+ if (AddNewIPCProcess == nullptr) {
AddNewIPCProcess = (bool (*)(pid_t, NuwaProtoFdInfo *, int))
dlsym(RTLD_DEFAULT, "AddNewIPCProcess");
}
AddNewIPCProcess(pid, aInfoList, aInfoSize);
}
static void
PrepareProtoSockets(NuwaProtoFdInfo *aInfoList, int aInfoSize) {
@@ -1556,18 +1556,18 @@ PrepareNuwaProcess() {
// Make marked threads block in one freeze point.
REAL(pthread_mutex_lock)(&sThreadFreezeLock);
}
// Make current process as a Nuwa process.
MFBT_API void
MakeNuwaProcess() {
- void (*GetProtoFdInfos)(NuwaProtoFdInfo *, int, int *) = NULL;
- void (*OnNuwaProcessReady)() = NULL;
+ void (*GetProtoFdInfos)(NuwaProtoFdInfo *, int, int *) = nullptr;
+ void (*OnNuwaProcessReady)() = nullptr;
sIsFreezing = true;
REAL(pthread_mutex_lock)(&sThreadCountLock);
// wait until all threads are frozen.
while ((sThreadFreezeCount + sThreadSkipCount) != sThreadCount) {
REAL(pthread_cond_wait)(&sThreadChangeCond, &sThreadCountLock);
}
@@ -1595,17 +1595,17 @@ MakeNuwaProcess() {
*/
MFBT_API void
NuwaMarkCurrentThread(void (*recreate)(void *), void *arg) {
if (!sIsNuwaProcess) {
return;
}
thread_info_t *tinfo = CUR_THREAD_INFO;
- if (tinfo == NULL) {
+ if (tinfo == nullptr) {
abort();
}
tinfo->flags |= TINFO_FLAG_NUWA_SUPPORT;
tinfo->recrFunc = recreate;
tinfo->recrArg = arg;
}
@@ -1613,17 +1613,17 @@ NuwaMarkCurrentThread(void (*recreate)(v
* Mark the current thread as not supporting Nuwa. Don't recreate this thread in
* the spawned process.
*/
MFBT_API void
NuwaSkipCurrentThread() {
if (!sIsNuwaProcess) return;
thread_info_t *tinfo = CUR_THREAD_INFO;
- if (tinfo == NULL) {
+ if (tinfo == nullptr) {
abort();
}
if (!(tinfo->flags & TINFO_FLAG_NUWA_SKIP)) {
sThreadSkipCount++;
}
tinfo->flags |= TINFO_FLAG_NUWA_SKIP;
}
--- a/mozglue/build/arm.cpp
+++ b/mozglue/build/arm.cpp
@@ -125,31 +125,31 @@ get_arm_cpu_flags(void)
bool armv6_processor = false;
flags = 0;
/*Reading /proc/self/auxv would be easier, but that doesn't work reliably on
Android. This also means that detection will fail in Scratchbox, which is
desirable, as NEON does not work in the qemu shipped with the Maemo 5 SDK.
I don't know if /proc/self/auxv would do any better in that case, anyway,
or if it would return random flags from the host CPU.*/
fin = fopen ("/proc/cpuinfo","r");
- if (fin != NULL)
+ if (fin != nullptr)
{
/*512 should be enough for anybody (it's even enough for all the flags that
x86 has accumulated... so far).*/
char buf[512];
- while (fgets(buf, 511, fin) != NULL)
+ while (fgets(buf, 511, fin) != nullptr)
{
if (memcmp(buf, "Features", 8) == 0)
{
char *p;
p = strstr(buf, " edsp");
- if (p != NULL && (p[5] == ' ' || p[5] == '\n'))
+ if (p != nullptr && (p[5] == ' ' || p[5] == '\n'))
flags |= MOZILLA_HAS_EDSP_FLAG;
p = strstr(buf, " neon");
- if( p != NULL && (p[5] == ' ' || p[5] == '\n'))
+ if( p != nullptr && (p[5] == ' ' || p[5] == '\n'))
flags |= MOZILLA_HAS_NEON_FLAG;
}
if (memcmp(buf, "CPU architecture:", 17) == 0)
{
int version;
version = atoi(buf + 17);
if (version >= 6)
flags |= MOZILLA_HAS_ARMV6_FLAG;