[tidy/linux] modernize-use-nullptr

This commit is contained in:
Bruno de Oliveira Abinader
2016-06-14 16:19:15 +03:00
parent 7413061f8e
commit 6b5caf4b2c
6 changed files with 21 additions and 21 deletions

View File

@@ -74,7 +74,7 @@ private:
#if MBGL_USE_GLX
Display *xDisplay = nullptr;
GLXFBConfig *fbConfigs = nullptr;
GLXContext glContext = 0;
GLXContext glContext = nullptr;
GLXPbuffer glxPbuffer = 0;
#endif

View File

@@ -23,12 +23,12 @@ void HeadlessView::createContext() {
if (!glXIsDirect(xDisplay, glContext)) {
Log::Error(Event::OpenGL, "failed to create direct OpenGL Legacy context");
glXDestroyContext(xDisplay, glContext);
glContext = 0;
glContext = nullptr;
}
}
}
if (glContext == 0) {
if (glContext == nullptr) {
throw std::runtime_error("Error creating GL context object.");
}

View File

@@ -30,15 +30,15 @@ std::string encodePNG(const PremultipliedImage& pre) {
UnassociatedImage src = util::unpremultiply(std::move(copy));
png_voidp error_ptr = 0;
png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, error_ptr, NULL, NULL);
png_voidp error_ptr = nullptr;
png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, error_ptr, nullptr, nullptr);
if (!png_ptr) {
throw std::runtime_error("couldn't create png_ptr");
}
png_infop info_ptr = png_create_info_struct(png_ptr);
if (!png_ptr) {
png_destroy_write_struct(&png_ptr, (png_infopp)0);
png_destroy_write_struct(&png_ptr, (png_infopp)nullptr);
throw std::runtime_error("couldn't create info_ptr");
}
@@ -55,7 +55,7 @@ std::string encodePNG(const PremultipliedImage& pre) {
png_set_write_fn(png_ptr, &result, [](png_structp png_ptr_, png_bytep data, png_size_t length) {
std::string *out = static_cast<std::string *>(png_get_io_ptr(png_ptr_));
out->append(reinterpret_cast<char *>(data), length);
}, NULL);
}, nullptr);
struct ptrs {
ptrs(size_t count) : rows(new png_bytep[count]) {}
@@ -68,7 +68,7 @@ std::string encodePNG(const PremultipliedImage& pre) {
}
png_set_rows(png_ptr, info_ptr, pointers.rows);
png_write_png(png_ptr, info_ptr, PNG_TRANSFORM_IDENTITY, NULL);
png_write_png(png_ptr, info_ptr, PNG_TRANSFORM_IDENTITY, nullptr);
png_destroy_write_struct(&png_ptr, &info_ptr);
return result;

View File

@@ -55,7 +55,7 @@ static void skip(j_decompress_ptr cinfo, long count) {
{
wrap->stream->seekg(count - wrap->manager.bytes_in_buffer, std::ios_base::cur);
// trigger buffer fill
wrap->manager.next_input_byte = 0;
wrap->manager.next_input_byte = nullptr;
wrap->manager.bytes_in_buffer = 0; //bytes_in_buffer may be zero on return.
}
}
@@ -63,7 +63,7 @@ static void skip(j_decompress_ptr cinfo, long count) {
static void term(j_decompress_ptr) {}
static void attach_stream(j_decompress_ptr cinfo, input_stream* in) {
if (cinfo->src == 0) {
if (cinfo->src == nullptr) {
cinfo->src = (struct jpeg_source_mgr *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, sizeof(jpeg_stream_wrapper));
}
@@ -74,7 +74,7 @@ static void attach_stream(j_decompress_ptr cinfo, input_stream* in) {
src->manager.resync_to_restart = jpeg_resync_to_restart;
src->manager.term_source = term;
src->manager.bytes_in_buffer = 0;
src->manager.next_input_byte = 0;
src->manager.next_input_byte = nullptr;
src->stream = in;
}

View File

@@ -46,7 +46,7 @@ struct png_struct_guard {
i_(info_ptr_ptr) {}
~png_struct_guard() {
png_destroy_read_struct(p_,i_,0);
png_destroy_read_struct(p_,i_,nullptr);
}
png_structpp p_;
@@ -66,7 +66,7 @@ PremultipliedImage decodePNG(const uint8_t* data, size_t size) {
if (!is_png)
throw std::runtime_error("File or stream is not a png");
png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0);
png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr);
if (!png_ptr)
throw std::runtime_error("failed to allocate png_ptr");
@@ -87,7 +87,7 @@ PremultipliedImage decodePNG(const uint8_t* data, size_t size) {
png_uint_32 height = 0;
int bit_depth = 0;
int color_type = 0;
png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, 0, 0, 0);
png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, nullptr, nullptr, nullptr);
UnassociatedImage image { width, height };
@@ -125,7 +125,7 @@ PremultipliedImage decodePNG(const uint8_t* data, size_t size) {
rows[row] = image.data.get() + row * width * 4;
png_read_image(png_ptr, rows.get());
png_read_end(png_ptr, 0);
png_read_end(png_ptr, nullptr);
return util::premultiply(std::move(image));
}

View File

@@ -18,10 +18,10 @@ std::string uppercase(const std::string& str)
for (; itr < end; itr = nitr)
{
uint32_t code_point = 0;
char const* buf = 0;
char const* buf = nullptr;
nitr = _nu_toupper(itr, end, nu_utf8_read, &code_point, &buf, 0);
if (buf != 0)
nitr = _nu_toupper(itr, end, nu_utf8_read, &code_point, &buf, nullptr);
if (buf != nullptr)
{
do
{
@@ -51,10 +51,10 @@ std::string lowercase(const std::string& str)
for (; itr < end; itr = nitr)
{
uint32_t code_point = 0;
char const* buf = 0;
char const* buf = nullptr;
nitr = _nu_tolower(itr, end, nu_utf8_read, &code_point, &buf, 0);
if (buf != 0)
nitr = _nu_tolower(itr, end, nu_utf8_read, &code_point, &buf, nullptr);
if (buf != nullptr)
{
do
{