]> granicus.if.org Git - graphviz/commitdiff
gdiplus plugin: replace use of NULL with more modern nullptr
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 18 Apr 2021 00:41:36 +0000 (17:41 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 24 Apr 2021 03:14:26 +0000 (20:14 -0700)
plugin/gdiplus/FileStream.cpp
plugin/gdiplus/gvdevice_gdiplus.cpp
plugin/gdiplus/gvloadimage_gdiplus.cpp
plugin/gdiplus/gvplugin_gdiplus.cpp
plugin/gdiplus/gvplugin_gdiplus.h
plugin/gdiplus/gvrender_gdiplus.cpp
plugin/gdiplus/gvtextlayout_gdiplus.cpp

index a4e70d18e4f8a2e49db9cbe8c30aa7103de5ac33..319bbbc1ec73414e4c688fe4223c0407a03e58f8 100644 (file)
@@ -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 */
index dcc25e46cb7101af47ca64b91e60b463bc635bad..d93af2dc938e4ad1658c801d09e1557f0ad64a14 100644 (file)
@@ -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}
 };
index 9a4a1830881592d9abe5d0dc9acafe0c4a575557..fd01ab305c5c91f330125d804c2da5bbbb48b65c 100644 (file)
@@ -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}
 };
index f7d8ea322ca754eec7b8f7b6e1808033e0022590..86f247dce96dcbdf122f8fbdc89cdbe2bd5d4d69 100644 (file)
@@ -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;
                }
 }
index 0fb9e3ae9707a7385b8cc322f49471648ecfcfe9..fc8d8d8709f6ecfe85ff0edef4e393ad665741a7 100644 (file)
@@ -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))
        {
        }
        
index f8661623e58c0e9d388a5f704e283cc788f3b507..41d49503c55a2cf1f6612375bece1e139249d49e 100644 (file)
@@ -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<Metafile**>(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}
 };
index 3fc4ab3d297629f71b95c5bd446427ad0f78bd19..2b04148222e4147668f80e0a684dbde6d259afe1 100644 (file)
@@ -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}
 };