Fix deprecated use of 0/NULL in faiss/python/python_callbacks.cpp + 1
Summary: `nullptr` is typesafe. `0` and `NULL` are not. In the future, only `nullptr` will be allowed. This diff helps us embrace the future _now_ in service of enabling `-Wzero-as-null-pointer-constant`. Reviewed By: palmje Differential Revision: D56650318 fbshipit-source-id: 803ae62114c39143b65946f6f0387715eaf7f534pull/3365/head^2
parent
a233bc93e3
commit
c5599a0684
|
@ -46,7 +46,7 @@ size_t PyCallbackIOWriter::operator()(
|
|||
size_t wi = ws > bs ? bs : ws;
|
||||
PyObject* result = PyObject_CallFunction(
|
||||
callback, "(N)", PyBytes_FromStringAndSize(ptr, wi));
|
||||
if (result == NULL) {
|
||||
if (result == nullptr) {
|
||||
FAISS_THROW_MSG("py err");
|
||||
}
|
||||
// TODO check nb of bytes written
|
||||
|
@ -77,7 +77,7 @@ size_t PyCallbackIOReader::operator()(void* ptrv, size_t size, size_t nitems) {
|
|||
while (rs > 0) {
|
||||
size_t ri = rs > bs ? bs : rs;
|
||||
PyObject* result = PyObject_CallFunction(callback, "(n)", ri);
|
||||
if (result == NULL) {
|
||||
if (result == nullptr) {
|
||||
FAISS_THROW_MSG("propagate py error");
|
||||
}
|
||||
if (!PyBytes_Check(result)) {
|
||||
|
@ -122,7 +122,7 @@ bool PyCallbackIDSelector::is_member(faiss::idx_t id) const {
|
|||
FAISS_THROW_IF_NOT((id >> 32) == 0);
|
||||
PyThreadLock gil;
|
||||
PyObject* result = PyObject_CallFunction(callback, "(n)", int(id));
|
||||
if (result == NULL) {
|
||||
if (result == nullptr) {
|
||||
FAISS_THROW_MSG("propagate py error");
|
||||
}
|
||||
bool b = PyObject_IsTrue(result);
|
||||
|
|
Loading…
Reference in New Issue