Skip to content

Commit f995982

Browse files
committed
supernova: replace NULL by nullptr
typesafety is nice
1 parent e3ca66a commit f995982

20 files changed

+65
-67
lines changed

server/supernova/audio_backend/jack_backend.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class jack_backend:
5353

5454
public:
5555
jack_backend(void):
56-
client(NULL), is_active(false), time_is_synced(false)
56+
client(nullptr), is_active(false), time_is_synced(false)
5757
{}
5858

5959
~jack_backend(void)
@@ -93,7 +93,7 @@ class jack_backend:
9393
jack_set_thread_init_callback (client, jack_thread_init_callback, this);
9494
jack_set_process_callback (client, jack_process_callback, this);
9595
jack_set_xrun_callback(client, jack_xrun_callback, this);
96-
jack_on_info_shutdown(client, (JackInfoShutdownCallback)jack_on_info_shutdown_callback, NULL);
96+
jack_on_info_shutdown(client, (JackInfoShutdownCallback)jack_on_info_shutdown_callback, nullptr);
9797

9898
/* register ports */
9999
input_ports.clear();
@@ -129,13 +129,13 @@ class jack_backend:
129129
{
130130
if (client) {
131131
jack_client_close(client);
132-
client = NULL;
132+
client = nullptr;
133133
}
134134
}
135135

136136
bool audio_is_opened(void)
137137
{
138-
return client != NULL;
138+
return client != nullptr;
139139
}
140140

141141
bool audio_is_active(void)
@@ -178,7 +178,7 @@ class jack_backend:
178178

179179
int connect_all_inputs(const char * client_name)
180180
{
181-
const char **ports = jack_get_ports (client, client_name, NULL, JackPortIsOutput);
181+
const char **ports = jack_get_ports (client, client_name, nullptr, JackPortIsOutput);
182182

183183
if (!ports)
184184
return -1;
@@ -200,7 +200,7 @@ class jack_backend:
200200

201201
int connect_all_outputs(const char * client_name)
202202
{
203-
const char **ports = jack_get_ports (client, client_name, NULL, JackPortIsInput);
203+
const char **ports = jack_get_ports (client, client_name, nullptr, JackPortIsInput);
204204

205205
if (!ports)
206206
return -1;

server/supernova/audio_backend/portaudio_backend.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class portaudio_backend:
4949

5050
public:
5151
portaudio_backend(void):
52-
stream(NULL), blocksize_(0)
52+
stream(nullptr), blocksize_(0)
5353
{
5454
int err = Pa_Initialize();
5555
report_error(err, true);
@@ -168,7 +168,7 @@ class portaudio_backend:
168168
in_parameters.channelCount = inchans;
169169
in_parameters.sampleFormat = paFloat32 | paNonInterleaved;
170170
in_parameters.suggestedLatency = suggestedLatencyIn;
171-
in_parameters.hostApiSpecificStreamInfo = NULL;
171+
in_parameters.hostApiSpecificStreamInfo = nullptr;
172172
}
173173

174174
if (outchans) {
@@ -180,11 +180,11 @@ class portaudio_backend:
180180
out_parameters.channelCount = outchans;
181181
out_parameters.sampleFormat = paFloat32 | paNonInterleaved;
182182
out_parameters.suggestedLatency = suggestedLatencyOut;
183-
out_parameters.hostApiSpecificStreamInfo = NULL;
183+
out_parameters.hostApiSpecificStreamInfo = nullptr;
184184
}
185185

186-
PaStreamParameters * in_stream_parameters = inchans ? &in_parameters : NULL;
187-
PaStreamParameters * out_stream_parameters = outchans ? &out_parameters : NULL;
186+
PaStreamParameters * in_stream_parameters = inchans ? &in_parameters : nullptr;
187+
PaStreamParameters * out_stream_parameters = outchans ? &out_parameters : nullptr;
188188

189189
PaError supported = Pa_IsFormatSupported(in_stream_parameters, out_stream_parameters, samplerate);
190190
report_error(supported);
@@ -213,14 +213,14 @@ class portaudio_backend:
213213

214214
void close_stream(void)
215215
{
216-
if (stream == NULL)
216+
if (stream == nullptr)
217217
return;
218218

219219
deactivate_audio();
220220

221221
int err = Pa_CloseStream(stream);
222222
report_error(err);
223-
stream = NULL;
223+
stream = nullptr;
224224
}
225225

226226
void activate_audio()

server/supernova/audio_backend/sndfile_backend.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class sndfile_backend:
101101
if (!output_file)
102102
throw std::runtime_error("cannot open output file");
103103

104-
output_file.command(SFC_SET_CLIPPING, NULL, SF_TRUE);
104+
output_file.command(SFC_SET_CLIPPING, nullptr, SF_TRUE);
105105

106106
super::output_samples.resize(output_channel_count);
107107

server/supernova/dsp_thread_queue/dsp_thread.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ class dsp_thread:
6565
public:
6666
dsp_thread(dsp_queue_interpreter & interpreter, uint16_t index, size_t stack_size,
6767
thread_init_functor const & thread_init = thread_init_functor()):
68-
thread_init_functor(thread_init), interpreter(interpreter), stop(false), index(index), stack_ (NULL)
68+
thread_init_functor(thread_init), interpreter(interpreter), stop(false), index(index), stack_ (nullptr)
6969
{
7070
if (stack_size) {
7171
stack_ = malloc_aligned<char>(stack_size);
72-
if (stack_ == NULL)
72+
if (stack_ == nullptr)
7373
throw std::bad_alloc();
7474
// touch stack to avoid page faults
7575
for (size_t i = 0; i != stack_size; ++i)
@@ -106,7 +106,7 @@ class dsp_thread:
106106
{
107107
dsp_thread * self = static_cast<dsp_thread*>(arg);
108108
self->run();
109-
return NULL;
109+
return nullptr;
110110
}
111111

112112
void terminate(void)

server/supernova/dsp_thread_queue/dsp_thread_queue.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ class dsp_thread_queue_item:
194194
std::size_t i = 0;
195195
for (;;) {
196196
if (i == successors.size())
197-
return NULL;
197+
return nullptr;
198198

199199
ptr = successors[i++]->dec_activation_count(interpreter);
200200
if (ptr)
@@ -220,7 +220,7 @@ class dsp_thread_queue_item:
220220
if (current == 1)
221221
return this;
222222
else
223-
return NULL;
223+
return nullptr;
224224
}
225225

226226
std::atomic<activation_limit_t> activation_count; /**< current activation count */
@@ -355,7 +355,7 @@ class dsp_queue_interpreter
355355
*/
356356
bool init_tick(void)
357357
{
358-
if (unlikely((queue.get() == NULL) or /* no queue */
358+
if (unlikely((queue.get() == nullptr) or /* no queue */
359359
(queue->get_total_node_count() == 0) /* no nodes */
360360
))
361361
return false;
@@ -584,7 +584,7 @@ class dsp_queue_interpreter
584584
do {
585585
item = item->run(*this, index);
586586
consumed += 1;
587-
} while (item != NULL);
587+
} while (item != nullptr);
588588

589589
node_count_t remaining = node_count.fetch_sub(consumed, std::memory_order_release);
590590

server/supernova/sc/sc_osc_handler.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ server_node * find_node(int32_t target_id)
4949

5050
server_node * node = instance->find_node(target_id);
5151

52-
if (node == NULL)
52+
if (node == nullptr)
5353
log_printf("node not found: %d\n", target_id);
5454

5555
return node;
@@ -62,7 +62,7 @@ abstract_group * find_group(int32_t target_id)
6262

6363
abstract_group * node = instance->find_group(target_id);
6464

65-
if (node == NULL)
65+
if (node == nullptr)
6666
log("node not found or not a group\n");
6767
return node;
6868
}
@@ -143,7 +143,7 @@ struct movable_string
143143
movable_string(movable_string const & rhs)
144144
{
145145
data_ = rhs.data_;
146-
const_cast<movable_string&>(rhs).data_ = NULL;
146+
const_cast<movable_string&>(rhs).data_ = nullptr;
147147
}
148148

149149
~movable_string(void)
@@ -178,7 +178,7 @@ struct movable_array
178178
{
179179
length_ = rhs.length_;
180180
data_ = rhs.data_;
181-
const_cast<movable_array&>(rhs).data_ = NULL;
181+
const_cast<movable_array&>(rhs).data_ = nullptr;
182182
}
183183

184184
~movable_array(void)
@@ -1066,12 +1066,12 @@ sc_synth * add_synth(const char * name, int node_id, int action, int target_id)
10661066
return 0;
10671067

10681068
server_node * target = find_node(target_id);
1069-
if (target == NULL)
1070-
return NULL;
1069+
if (target == nullptr)
1070+
return nullptr;
10711071

10721072
node_position_constraint pos = make_pair(target, node_position(action));
10731073
if (!node_position_sanity_check(pos))
1074-
return NULL;
1074+
return nullptr;
10751075

10761076
abstract_synth * synth = instance->add_synth(name, node_id, pos);
10771077
if (!synth)
@@ -1214,7 +1214,7 @@ void handle_s_new(received_message const & msg)
12141214

12151215
sc_synth * synth = add_synth(def_name, id, action, target);
12161216

1217-
if (synth == NULL)
1217+
if (synth == nullptr)
12181218
return;
12191219

12201220
try {
@@ -1732,7 +1732,7 @@ void handle_n_order(received_message const & msg)
17321732

17331733
server_node * target = find_node(target_id);
17341734

1735-
if (target == NULL)
1735+
if (target == nullptr)
17361736
return;
17371737

17381738
abstract_group * target_parent;
@@ -1749,7 +1749,7 @@ void handle_n_order(received_message const & msg)
17491749
args >> node_id;
17501750

17511751
server_node * node = find_node(node_id);
1752-
if (node == NULL)
1752+
if (node == nullptr)
17531753
continue;
17541754

17551755
abstract_group * node_parent = node->get_parent();
@@ -3164,7 +3164,7 @@ void handle_u_cmd(received_message const & msg, int size)
31643164

31653165
server_node * target_synth = find_node(node_id);
31663166

3167-
if (target_synth == NULL || target_synth->is_group())
3167+
if (target_synth == nullptr || target_synth->is_group())
31683168
return;
31693169

31703170
sc_synth * synth = static_cast<sc_synth*>(target_synth);

server/supernova/sc/sc_plugin_interface.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ spin_lock rt_pool_guard;
6060

6161
inline Node * as_Node(server_node * node)
6262
{
63-
if (node == NULL)
64-
return NULL;
63+
if (node == nullptr)
64+
return nullptr;
6565

6666
// hack!!! we only assume that the 32bit integer mID member can be accessed via Node
6767
if (node->is_synth()) {
@@ -368,7 +368,7 @@ void * rt_alloc(World * dummy, size_t size)
368368
if (size)
369369
return nova::rt_pool.malloc(size);
370370
else
371-
return NULL;
371+
return nullptr;
372372
}
373373

374374
void * rt_realloc(World * dummy, void * ptr, size_t size)
@@ -647,7 +647,7 @@ void sc_plugin_interface::initialize(server_arguments const & args, float * cont
647647

648648
/* sndfile functions */
649649
#ifdef NO_LIBSNDFILE
650-
sc_interface.fSndFileFormatInfoFromStrings = NULL;
650+
sc_interface.fSndFileFormatInfoFromStrings = nullptr;
651651
#else
652652
sc_interface.fSndFileFormatInfoFromStrings = &sndfileFormatInfoFromStrings;
653653
#endif
@@ -906,7 +906,7 @@ void sc_plugin_interface::allocate_buffer(SndBuf * buf, uint32_t frames, uint32_
906906
throw std::runtime_error( "invalid buffer size" );
907907

908908
sample * data = nova::allocate_buffer(samples);
909-
if (data == NULL)
909+
if (data == nullptr)
910910
throw std::runtime_error( "could not allocate memory" );
911911

912912
buf->data = data;
@@ -1076,10 +1076,10 @@ void sc_plugin_interface::buffer_close(uint32_t index)
10761076
{
10771077
SndBuf * buf = World_GetNRTBuf(&world, index);
10781078

1079-
if (buf->sndfile == NULL)
1079+
if (buf->sndfile == nullptr)
10801080
return;
10811081
sf_close(buf->sndfile);
1082-
buf->sndfile = NULL;
1082+
buf->sndfile = nullptr;
10831083
}
10841084

10851085

server/supernova/sc/sc_synth.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ sc_synth::sc_synth(int node_id, sc_synth_definition_ptr const & prototype):
6262
char * raw_chunk = rt_synthesis ? (char*)rt_pool.malloc(total_alloc_size)
6363
: (char*)malloc(total_alloc_size);
6464

65-
if (raw_chunk == NULL)
65+
if (raw_chunk == nullptr)
6666
throw std::bad_alloc();
6767

6868
linear_allocator allocator(raw_chunk);

server/supernova/sc/sc_synthdef.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ void sc_synthdef::prepare(void)
342342
current_ugen_spec.buffer_mapping.resize(current_ugen_spec.output_specs.size());
343343

344344
sc_ugen_def * ugen = sc_factory->find_ugen(current_ugen_spec.name);
345-
if (unlikely(ugen == NULL)) {
345+
if (unlikely(ugen == nullptr)) {
346346
/* we cannot prepare the synthdef, if the ugens are not installed */
347347
boost::format frmt("Cannot load synth %1%: Unit generator %2% not installed");
348348
frmt % name_.c_str() % current_ugen_spec.name.c_str();

server/supernova/sc/sc_ugen_factory.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ sample * sc_bufgen_def::run(World * world, uint32_t buffer_index, struct sc_msg_
143143
(func)(world, buf, args);
144144

145145
if (data == buf->data)
146-
return NULL;
146+
return nullptr;
147147
else
148148
return data;
149149
}
@@ -198,7 +198,7 @@ sample * sc_plugin_container::run_bufgen(World * world, const char * name, uint3
198198
bufgen_set_type::iterator it = bufgen_set.find(name, named_hash_hash(), named_hash_equal());
199199
if (it == bufgen_set.end()) {
200200
std::cout << "unable to find buffer generator: " << name << std::endl;
201-
return NULL;
201+
return nullptr;
202202
}
203203

204204
return it->run(world, buffer_index, args);
@@ -242,7 +242,7 @@ void sc_ugen_factory::load_plugin ( boost::filesystem::path const & path )
242242
using namespace std;
243243

244244
void * handle = dlopen(path.string().c_str(), RTLD_NOW | RTLD_LOCAL);
245-
if (handle == NULL)
245+
if (handle == nullptr)
246246
return;
247247

248248
typedef int (*info_function)();
@@ -304,7 +304,7 @@ void sc_ugen_factory::load_plugin ( boost::filesystem::path const & path )
304304
char *s;
305305
DWORD lastErr = GetLastError();
306306
FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
307-
NULL, lastErr , MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (char*)&s, 0, NULL );
307+
nullptr, lastErr , MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (char*)&s, 0, NULL );
308308

309309
std::cout << "Cannot open plugin: " << path << s << std::endl;
310310
LocalFree( s );
@@ -336,7 +336,7 @@ void sc_ugen_factory::load_plugin ( boost::filesystem::path const & path )
336336
if (!ptr) {
337337
char *s;
338338
FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
339-
NULL, GetLastError() , MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (char*)&s, 0, NULL );
339+
nullptr, GetLastError() , MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (char*)&s, 0, NULL );
340340

341341
std::cout << "*** ERROR: GetProcAddress err " << s << std::endl;
342342
LocalFree( s );

0 commit comments

Comments
 (0)