From: Matthew Fernandez Date: Sun, 18 Apr 2021 00:41:36 +0000 (-0700) Subject: gdiplus plugin: replace use of NULL with more modern nullptr X-Git-Tag: 2.47.2~48^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bba53d3065be9d1ae2d925895b39be2af3486236;p=graphviz gdiplus plugin: replace use of NULL with more modern nullptr --- diff --git a/plugin/gdiplus/FileStream.cpp b/plugin/gdiplus/FileStream.cpp index a4e70d18e..319bbbc1e 100644 --- a/plugin/gdiplus/FileStream.cpp +++ b/plugin/gdiplus/FileStream.cpp @@ -46,7 +46,7 @@ HRESULT FileStream::QueryInterface( } else { - *ppvObject = NULL; + *ppvObject = nullptr; return E_NOINTERFACE; } } @@ -178,14 +178,14 @@ HRESULT FileStream::Stat( /* fill in filename, if needed */ if (grfStatFlag != STATFLAG_NONAME) { - int wide_count = MultiByteToWideChar(CP_UTF8, 0, _name, -1, NULL, 0); + int wide_count = MultiByteToWideChar(CP_UTF8, 0, _name, -1, nullptr, 0); if (wide_count > 0) { pstatstg->pwcsName = (LPOLESTR)CoTaskMemAlloc(wide_count * 2); MultiByteToWideChar(CP_UTF8, 0, _name, -1, pstatstg->pwcsName, wide_count); } else - pstatstg->pwcsName = NULL; + pstatstg->pwcsName = nullptr; } /* fill out rest of STATSTG */ diff --git a/plugin/gdiplus/gvdevice_gdiplus.cpp b/plugin/gdiplus/gvdevice_gdiplus.cpp index dcc25e46c..d93af2dc9 100644 --- a/plugin/gdiplus/gvdevice_gdiplus.cpp +++ b/plugin/gdiplus/gvdevice_gdiplus.cpp @@ -31,7 +31,7 @@ static void gdiplus_format(GVJ_t *job) /* allocate memory and attach stream to it */ HGLOBAL buffer = GlobalAlloc(GMEM_MOVEABLE, 0); - IStream *stream = NULL; + IStream *stream = nullptr; CreateStreamOnHGlobal(buffer, FALSE, &stream); /* FALSE means don't deallocate buffer when releasing stream */ Bitmap bitmap( @@ -52,9 +52,9 @@ static void gdiplus_format(GVJ_t *job) } static gvdevice_engine_t gdiplus_engine = { - NULL, /* gdiplus_initialize */ + nullptr, /* gdiplus_initialize */ gdiplus_format, - NULL, /* gdiplus_finalize */ + nullptr, /* gdiplus_finalize */ }; static gvdevice_features_t device_features_gdiplus = { @@ -74,5 +74,5 @@ gvplugin_installed_t gvdevice_gdiplus_types_for_cairo[] = { {FORMAT_PNG, "png:cairo", 8, &gdiplus_engine, &device_features_gdiplus}, {FORMAT_TIFF, "tif:cairo", 8, &gdiplus_engine, &device_features_gdiplus}, {FORMAT_TIFF, "tiff:cairo", 8, &gdiplus_engine, &device_features_gdiplus}, - {0, NULL, 0, NULL, NULL} + {0, nullptr, 0, nullptr, nullptr} }; diff --git a/plugin/gdiplus/gvloadimage_gdiplus.cpp b/plugin/gdiplus/gvloadimage_gdiplus.cpp index 9a4a18308..fd01ab305 100644 --- a/plugin/gdiplus/gvloadimage_gdiplus.cpp +++ b/plugin/gdiplus/gvloadimage_gdiplus.cpp @@ -37,13 +37,13 @@ static Image* gdiplus_loadimage(GVJ_t * job, usershape_t *us) if (us->data && us->datafree != gdiplus_freeimage) { us->datafree(us); /* free incompatible cache data */ - us->data = NULL; - us->datafree = NULL; + us->data = nullptr; + us->datafree = nullptr; } if (!us->data) { /* read file into cache */ if (!gvusershape_file_access(us)) - return NULL; + return nullptr; /* create image from the usershape file */ /* NOTE: since Image::FromStream consumes the stream, we assume FileStream's lifetime should be shorter than us->name and us->f... */ @@ -75,11 +75,11 @@ static gvloadimage_engine_t engine = { }; gvplugin_installed_t gvloadimage_gdiplus_types[] = { - {FORMAT_BMP, "bmp:gdiplus", 8, &engine, NULL}, - {FORMAT_GIF, "gif:gdiplus", 8, &engine, NULL}, - {FORMAT_JPEG, "jpe:gdiplus", 8, &engine, NULL}, - {FORMAT_JPEG, "jpeg:gdiplus", 8, &engine, NULL}, - {FORMAT_JPEG, "jpg:gdiplus", 8, &engine, NULL}, - {FORMAT_PNG, "png:gdiplus", 8, &engine, NULL}, - {0, NULL, 0, NULL, NULL} + {FORMAT_BMP, "bmp:gdiplus", 8, &engine, nullptr}, + {FORMAT_GIF, "gif:gdiplus", 8, &engine, nullptr}, + {FORMAT_JPEG, "jpe:gdiplus", 8, &engine, nullptr}, + {FORMAT_JPEG, "jpeg:gdiplus", 8, &engine, nullptr}, + {FORMAT_JPEG, "jpg:gdiplus", 8, &engine, nullptr}, + {FORMAT_PNG, "png:gdiplus", 8, &engine, nullptr}, + {0, nullptr, 0, nullptr, nullptr} }; diff --git a/plugin/gdiplus/gvplugin_gdiplus.cpp b/plugin/gdiplus/gvplugin_gdiplus.cpp index f7d8ea322..86f247dce 100644 --- a/plugin/gdiplus/gvplugin_gdiplus.cpp +++ b/plugin/gdiplus/gvplugin_gdiplus.cpp @@ -34,7 +34,7 @@ static GUID format_id [] = { ImageFormatTIFF }; -static ULONG_PTR _gdiplusToken = NULL; +static ULONG_PTR _gdiplusToken = 0; static void UnuseGdiplus() { @@ -47,7 +47,7 @@ void UseGdiplus() if (!_gdiplusToken) { GdiplusStartupInput input; - GdiplusStartup(&_gdiplusToken, &input, NULL); + GdiplusStartup(&_gdiplusToken, &input, nullptr); atexit(&UnuseGdiplus); } } @@ -63,7 +63,7 @@ void SaveBitmapToStream(Bitmap &bitmap, IStream *stream, int format) /* search the encoders for one that matches our device id, then save the bitmap there */ GdiplusStartupInput gdiplusStartupInput; ULONG_PTR gdiplusToken; - GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); + GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, nullptr); UINT encoderNum; UINT encoderSize; GetImageEncodersSize(&encoderNum, &encoderSize); @@ -72,7 +72,7 @@ void SaveBitmapToStream(Bitmap &bitmap, IStream *stream, int format) GetImageEncoders(encoderNum, encoderSize, codecs); for (UINT i = 0; i < encoderNum; ++i) if (memcmp(&(format_id[format]), &codecs[i].FormatID, sizeof(GUID)) == 0) { - bitmap.Save(stream, &codecs[i].Clsid, NULL); + bitmap.Save(stream, &codecs[i].Clsid, nullptr); break; } } diff --git a/plugin/gdiplus/gvplugin_gdiplus.h b/plugin/gdiplus/gvplugin_gdiplus.h index 0fb9e3ae9..fc8d8d870 100644 --- a/plugin/gdiplus/gvplugin_gdiplus.h +++ b/plugin/gdiplus/gvplugin_gdiplus.h @@ -36,7 +36,7 @@ struct DeviceContext HWND hwnd; HDC hdc; - DeviceContext(HWND wnd = NULL): hwnd(wnd), hdc(GetDC(wnd)) + DeviceContext(HWND wnd = nullptr): hwnd(wnd), hdc(GetDC(wnd)) { } diff --git a/plugin/gdiplus/gvrender_gdiplus.cpp b/plugin/gdiplus/gvrender_gdiplus.cpp index f8661623e..41d49503c 100644 --- a/plugin/gdiplus/gvrender_gdiplus.cpp +++ b/plugin/gdiplus/gvrender_gdiplus.cpp @@ -41,14 +41,14 @@ static void gdiplusgen_begin_job(GVJ_t *job) { UseGdiplus(); if (!job->external_context) - job->context = NULL; + job->context = nullptr; else if (job->device.id == FORMAT_METAFILE) { /* save the passed-in context in the window field, so we can create a Metafile in the context field later on */ job->window = job->context; auto m = reinterpret_cast(job->window); - *m = NULL; - job->context = NULL; + *m = nullptr; + job->context = nullptr; } } @@ -78,7 +78,7 @@ static void gdiplusgen_end_job(GVJ_t *job) /* blast the streamed buffer back to the gvdevice */ /* NOTE: this is somewhat inefficient since we should be streaming directly to gvdevice rather than buffering first */ /* ... however, GDI+ requires any such direct IStream to implement Seek Read, Write, Stat methods and gvdevice really only offers a write-once model */ - HGLOBAL buffer = NULL; + HGLOBAL buffer = nullptr; GetHGlobalFromStream(stream, &buffer); stream->Release(); gvwrite(job, (unsigned char*)GlobalLock(buffer), GlobalSize(buffer)); @@ -95,7 +95,7 @@ static void gdiplusgen_begin_page(GVJ_t *job) if (!job->external_context) { /* allocate memory and attach stream to it */ HGLOBAL buffer = GlobalAlloc(GMEM_MOVEABLE, 0); - IStream *stream = NULL; + IStream *stream = nullptr; CreateStreamOnHGlobal(buffer, FALSE, &stream); /* FALSE means don't deallocate buffer when releasing stream */ Image *image; @@ -309,7 +309,7 @@ static gvrender_engine_t gdiplusgen_engine = { static gvrender_features_t render_features_gdiplus = { GVRENDER_Y_GOES_DOWN | GVRENDER_DOES_TRANSFORM, /* flags */ 4., /* default pad - graph units */ - NULL, /* knowncolors */ + nullptr, /* knowncolors */ 0, /* sizeof knowncolors */ RGBA_BYTE /* color_type */ }; @@ -333,20 +333,20 @@ static gvdevice_features_t device_features_gdiplus = { gvplugin_installed_t gvrender_gdiplus_types[] = { {0, "gdiplus", 1, &gdiplusgen_engine, &render_features_gdiplus}, - {0, NULL, 0, NULL, NULL} + {0, nullptr, 0, nullptr, nullptr} }; gvplugin_installed_t gvdevice_gdiplus_types[] = { - {FORMAT_METAFILE, "metafile:gdiplus", 8, NULL, &device_features_gdiplus_emf}, - {FORMAT_BMP, "bmp:gdiplus", 8, NULL, &device_features_gdiplus}, - {FORMAT_EMF, "emf:gdiplus", 8, NULL, &device_features_gdiplus_emf}, - {FORMAT_EMFPLUS, "emfplus:gdiplus", 8, NULL, &device_features_gdiplus_emf}, - {FORMAT_GIF, "gif:gdiplus", 8, NULL, &device_features_gdiplus}, - {FORMAT_JPEG, "jpe:gdiplus", 8, NULL, &device_features_gdiplus}, - {FORMAT_JPEG, "jpeg:gdiplus", 8, NULL, &device_features_gdiplus}, - {FORMAT_JPEG, "jpg:gdiplus", 8, NULL, &device_features_gdiplus}, - {FORMAT_PNG, "png:gdiplus", 8, NULL, &device_features_gdiplus}, - {FORMAT_TIFF, "tif:gdiplus", 8, NULL, &device_features_gdiplus}, - {FORMAT_TIFF, "tiff:gdiplus", 8, NULL, &device_features_gdiplus}, - {0, NULL, 0, NULL, NULL} + {FORMAT_METAFILE, "metafile:gdiplus", 8, nullptr, &device_features_gdiplus_emf}, + {FORMAT_BMP, "bmp:gdiplus", 8, nullptr, &device_features_gdiplus}, + {FORMAT_EMF, "emf:gdiplus", 8, nullptr, &device_features_gdiplus_emf}, + {FORMAT_EMFPLUS, "emfplus:gdiplus", 8, nullptr, &device_features_gdiplus_emf}, + {FORMAT_GIF, "gif:gdiplus", 8, nullptr, &device_features_gdiplus}, + {FORMAT_JPEG, "jpe:gdiplus", 8, nullptr, &device_features_gdiplus}, + {FORMAT_JPEG, "jpeg:gdiplus", 8, nullptr, &device_features_gdiplus}, + {FORMAT_JPEG, "jpg:gdiplus", 8, nullptr, &device_features_gdiplus}, + {FORMAT_PNG, "png:gdiplus", 8, nullptr, &device_features_gdiplus}, + {FORMAT_TIFF, "tif:gdiplus", 8, nullptr, &device_features_gdiplus}, + {FORMAT_TIFF, "tiff:gdiplus", 8, nullptr, &device_features_gdiplus}, + {0, nullptr, 0, nullptr, nullptr} }; diff --git a/plugin/gdiplus/gvtextlayout_gdiplus.cpp b/plugin/gdiplus/gvtextlayout_gdiplus.cpp index 3fc4ab3d2..2b0414822 100644 --- a/plugin/gdiplus/gvtextlayout_gdiplus.cpp +++ b/plugin/gdiplus/gvtextlayout_gdiplus.cpp @@ -105,6 +105,6 @@ static gvtextlayout_engine_t gdiplus_textlayout_engine = { }; gvplugin_installed_t gvtextlayout_gdiplus_types[] = { - {0, "textlayout", 8, &gdiplus_textlayout_engine, NULL}, - {0, NULL, 0, NULL, NULL} + {0, "textlayout", 8, &gdiplus_textlayout_engine, nullptr}, + {0, nullptr, 0, nullptr, nullptr} };