Skip to content

Commit 3f9b705

Browse files
committed
Replace some usage of ScopedPointer with std::unique_ptr
Signed-off-by: falkTX <falktx@falktx.com>
1 parent 31c97d2 commit 3f9b705

13 files changed

Lines changed: 40 additions & 40 deletions

File tree

source/backend/plugin/CarlaPluginBridge.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <ctime>
1818

1919
#include "extra/Base64.hpp"
20+
#include "extra/ScopedPointer.hpp"
2021
#include "extra/Time.hpp"
2122

2223
#include "water/files/File.h"

source/modules/water/containers/HashMap.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include "Array.h"
3030
#include "../text/String.h"
3131

32-
#include "extra/ScopedPointer.hpp"
32+
#include <memory>
3333

3434
namespace water {
3535

@@ -141,7 +141,7 @@ class HashMap
141141

142142
while (h != nullptr)
143143
{
144-
const ScopedPointer<HashEntry> deleter (h);
144+
const std::unique_ptr<HashEntry> deleter (h);
145145
h = h->nextEntry;
146146
}
147147

@@ -262,7 +262,7 @@ class HashMap
262262
{
263263
if (entry->value == valueToRemove)
264264
{
265-
const ScopedPointer<HashEntry> deleter (entry);
265+
const std::unique_ptr<HashEntry> deleter (entry);
266266

267267
entry = entry->nextEntry;
268268

source/modules/water/containers/OwnedArray.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
#include "ArrayAllocationBase.h"
3030

31-
#include "extra/ScopedPointer.hpp"
31+
#include <memory>
3232

3333
namespace water {
3434

@@ -372,7 +372,7 @@ class OwnedArray
372372
{
373373
if (indexToChange >= 0)
374374
{
375-
ScopedPointer<ObjectClass> toDelete;
375+
std::unique_ptr<ObjectClass> toDelete;
376376

377377
{
378378
if (indexToChange < numUsed)
@@ -536,14 +536,14 @@ class OwnedArray
536536
*/
537537
void remove (const size_t indexToRemove, bool deleteObject = true)
538538
{
539-
ScopedPointer<ObjectClass> toDelete;
539+
std::unique_ptr<ObjectClass> toDelete;
540540

541541
if (indexToRemove < numUsed)
542542
{
543543
ObjectClass** const e = data.elements + indexToRemove;
544544

545545
if (deleteObject)
546-
toDelete = *e;
546+
toDelete.reset(*e);
547547

548548
--numUsed;
549549
const size_t numToShift = numUsed - indexToRemove;

source/modules/water/files/DirectoryIterator.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ bool DirectoryIterator::next (bool* const isDirResult, int64* const fileSize, bo
9999
if (isDirectory)
100100
{
101101
if (isRecursive)
102-
subIterator = new DirectoryIterator (File::createFileWithoutCheckingPath (path + filename),
103-
true, wildCard, whatToLookFor);
102+
subIterator.reset(new DirectoryIterator (File::createFileWithoutCheckingPath (path + filename),
103+
true, wildCard, whatToLookFor));
104104

105105
matches = (whatToLookFor & File::findDirectories) != 0;
106106
}

source/modules/water/files/DirectoryIterator.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include "File.h"
3030
#include "../text/StringArray.h"
3131

32-
#include "extra/ScopedPointer.hpp"
32+
#include <memory>
3333

3434
namespace water {
3535

@@ -123,7 +123,7 @@ class DirectoryIterator
123123

124124
private:
125125
friend class DirectoryIterator;
126-
ScopedPointer<Pimpl> pimpl;
126+
std::unique_ptr<Pimpl> pimpl;
127127

128128
CARLA_DECLARE_NON_COPYABLE (NativeIterator)
129129
};
@@ -136,7 +136,7 @@ class DirectoryIterator
136136
const int whatToLookFor;
137137
const bool isRecursive;
138138
bool hasBeenAdvanced;
139-
ScopedPointer<DirectoryIterator> subIterator;
139+
std::unique_ptr<DirectoryIterator> subIterator;
140140
File currentFile;
141141

142142
static StringArray parseWildcards (const String& pattern);

source/modules/water/files/File.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ File File::withFileExtension (const char* const newExtension) const
714714
//==============================================================================
715715
FileInputStream* File::createInputStream() const
716716
{
717-
ScopedPointer<FileInputStream> fin (new FileInputStream (*this));
717+
std::unique_ptr<FileInputStream> fin (new FileInputStream (*this));
718718

719719
if (fin->openedOk())
720720
return fin.release();
@@ -724,7 +724,7 @@ FileInputStream* File::createInputStream() const
724724

725725
FileOutputStream* File::createOutputStream (const size_t bufferSize) const
726726
{
727-
ScopedPointer<FileOutputStream> out (new FileOutputStream (*this, bufferSize));
727+
std::unique_ptr<FileOutputStream> out (new FileOutputStream (*this, bufferSize));
728728

729729
return out->failedToOpen() ? nullptr
730730
: out.release();

source/modules/water/files/TemporaryFile.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
This file is part of the Water library.
55
Copyright (c) 2016 ROLI Ltd.
6-
Copyright (C) 2017-2022 Filipe Coelho <falktx@falktx.com>
6+
Copyright (C) 2017-2025 Filipe Coelho <falktx@falktx.com>
77
88
Permission is granted to use this software under the terms of the ISC license
99
http://www.isc.org/downloads/software-support-policy/isc-license/
@@ -26,7 +26,6 @@
2626
#ifndef WATER_TEMPORARYFILE_H_INCLUDED
2727
#define WATER_TEMPORARYFILE_H_INCLUDED
2828

29-
#include "TemporaryFile.h"
3029
#include "File.h"
3130

3231
namespace water {
@@ -49,7 +48,7 @@ namespace water {
4948
TemporaryFile temp (myTargetFile);
5049
5150
// create a stream to the temporary file, and write some data to it...
52-
ScopedPointer<FileOutputStream> out (temp.getFile().createOutputStream());
51+
std::unique_ptr<FileOutputStream> out (temp.getFile().createOutputStream());
5352
5453
if (out != nullptr)
5554
{

source/modules/water/memory/SharedResourcePointer.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include "ReferenceCountedObject.h"
3030
#include "../threads/SpinLock.h"
3131

32-
#include "extra/ScopedPointer.hpp"
32+
#include <memory>
3333

3434
namespace water {
3535

@@ -123,7 +123,7 @@ class SharedResourcePointer
123123
const SpinLock::ScopedLockType sl (holder.lock);
124124

125125
if (--(holder.refCount) == 0)
126-
holder.sharedInstance = nullptr;
126+
holder.sharedInstance.reset();
127127
}
128128

129129
/** Returns the shared object. */
@@ -144,7 +144,7 @@ class SharedResourcePointer
144144
struct SharedObjectHolder : public ReferenceCountedObject
145145
{
146146
SpinLock lock;
147-
ScopedPointer<SharedObjectType> sharedInstance;
147+
std::unique_ptr<SharedObjectType> sharedInstance;
148148
int refCount;
149149
};
150150

@@ -162,9 +162,9 @@ class SharedResourcePointer
162162
const SpinLock::ScopedLockType sl (holder.lock);
163163

164164
if (++(holder.refCount) == 1)
165-
holder.sharedInstance = new SharedObjectType();
165+
holder.sharedInstance.reset(new SharedObjectType());
166166

167-
sharedObject = holder.sharedInstance;
167+
sharedObject = holder.sharedInstance.get();
168168
}
169169

170170
void initialise_v2(const char* const v1, const char* const v2)
@@ -173,9 +173,9 @@ class SharedResourcePointer
173173
const SpinLock::ScopedLockType sl (holder.lock);
174174

175175
if (++(holder.refCount) == 1)
176-
holder.sharedInstance = new SharedObjectType(v1, v2);
176+
holder.sharedInstance.reset(new SharedObjectType(v1, v2));
177177

178-
sharedObject = holder.sharedInstance;
178+
sharedObject = holder.sharedInstance.get();
179179
}
180180

181181
// There's no need to assign to a SharedResourcePointer because every

source/modules/water/processors/AudioProcessorGraph.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class AudioProcessorGraph : public AudioProcessor
6969
const uint32 nodeId;
7070

7171
/** The actual processor object that this node represents. */
72-
AudioProcessor* getProcessor() const noexcept { return processor; }
72+
AudioProcessor* getProcessor() const noexcept { return processor.get(); }
7373

7474
/** Custom properties for Carla usage. */
7575
struct Properties {
@@ -112,7 +112,7 @@ class AudioProcessorGraph : public AudioProcessor
112112
//==============================================================================
113113
friend class AudioProcessorGraph;
114114

115-
const ScopedPointer<AudioProcessor> processor;
115+
const std::unique_ptr<AudioProcessor> processor;
116116
bool isPrepared;
117117

118118
Node (uint32 nodeId, AudioProcessor*) noexcept;
@@ -405,7 +405,7 @@ class AudioProcessorGraph : public AudioProcessor
405405

406406
friend class AudioGraphIOProcessor;
407407
struct AudioProcessorGraphBufferHelpers;
408-
ScopedPointer<AudioProcessorGraphBufferHelpers> audioAndCVBuffers;
408+
std::unique_ptr<AudioProcessorGraphBufferHelpers> audioAndCVBuffers;
409409

410410
MidiBuffer* currentMidiInputBuffer;
411411
MidiBuffer currentMidiOutputBuffer;

source/modules/water/threads/ChildProcess.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ uint32 ChildProcess::getPID() const noexcept
330330
#ifdef CARLA_OS_WIN
331331
bool ChildProcess::start (const String& command, Type)
332332
{
333-
activeProcess = new ActiveProcess (command);
333+
activeProcess.reset(new ActiveProcess (command));
334334

335335
if (! activeProcess->ok)
336336
activeProcess = nullptr;
@@ -370,7 +370,7 @@ bool ChildProcess::start (const StringArray& args, const Type type)
370370
if (args.size() == 0)
371371
return false;
372372

373-
activeProcess = new ActiveProcess (args, type);
373+
activeProcess.reset(new ActiveProcess (args, type));
374374

375375
if (activeProcess->childPID == 0)
376376
activeProcess = nullptr;

0 commit comments

Comments
 (0)