@@ -499,15 +499,28 @@ void GWKThreadsEnd(void *psThreadDataIn);
499499/* ! @cond Doxygen_Suppress */
500500typedef struct _GDALWarpChunk GDALWarpChunk;
501501
502+ struct GDALTransformerUniquePtrReleaser
503+ {
504+ void operator ()(void *p)
505+ {
506+ GDALDestroyTransformer (p);
507+ }
508+ };
509+
502510/* ! @endcond */
503511
504- class CPL_DLL GDALWarpOperation
512+ /* * Unique pointer for the argument of a GDALTransformerFunc */
513+ using GDALTransformerArgUniquePtr =
514+ std::unique_ptr<void , GDALTransformerUniquePtrReleaser>;
515+
516+ class CPL_DLL GDALWarpOperation final
505517{
506518
507519 CPL_DISALLOW_COPY_ASSIGN (GDALWarpOperation)
508520
509521 private:
510- GDALWarpOptions *psOptions;
522+ GDALWarpOptions *psOptions = nullptr ;
523+ GDALTransformerArgUniquePtr m_psOwnedTransformerArg{nullptr };
511524
512525 void WipeOptions ();
513526 int ValidateOptions ();
@@ -528,17 +541,17 @@ class CPL_DLL GDALWarpOperation
528541 static CPLErr CreateKernelMask (GDALWarpKernel *, int iBand,
529542 const char *pszType);
530543
531- CPLMutex *hIOMutex;
532- CPLMutex *hWarpMutex;
544+ CPLMutex *hIOMutex = nullptr ;
545+ CPLMutex *hWarpMutex = nullptr ;
533546
534- int nChunkListCount;
535- int nChunkListMax;
536- GDALWarpChunk *pasChunkList;
547+ int nChunkListCount = 0 ;
548+ int nChunkListMax = 0 ;
549+ GDALWarpChunk *pasChunkList = nullptr ;
537550
538- int bReportTimings;
539- unsigned long nLastTimeReported;
551+ bool bReportTimings = false ;
552+ unsigned long nLastTimeReported = 0 ;
540553
541- void *psThreadData;
554+ void *psThreadData = nullptr ;
542555
543556 // Coordinates a few special points in target image space, to determine
544557 // if ComputeSourceWindow() must use a grid based sampling.
@@ -555,9 +568,12 @@ class CPL_DLL GDALWarpOperation
555568
556569 public:
557570 GDALWarpOperation ();
558- virtual ~GDALWarpOperation ();
571+ ~GDALWarpOperation ();
559572
560- CPLErr Initialize (const GDALWarpOptions *psNewOptions);
573+ CPLErr Initialize (const GDALWarpOptions *psNewOptions,
574+ GDALTransformerFunc pfnTransformer = nullptr ,
575+ GDALTransformerArgUniquePtr psOwnedTransformerArg =
576+ GDALTransformerArgUniquePtr{nullptr });
561577 void *CreateDestinationBuffer (int nDstXSize, int nDstYSize,
562578 int *pbWasInitialized = nullptr );
563579 CPLErr InitializeDestinationBuffer (void *pDstBuffer, int nDstXSize,
0 commit comments