Skip to content

Commit

Permalink
[clang-tidy: modernize-use-nullptr]
Browse files Browse the repository at this point in the history
  • Loading branch information
drdanz committed Nov 19, 2018
1 parent dec136c commit 091030f
Show file tree
Hide file tree
Showing 22 changed files with 97 additions and 97 deletions.
10 changes: 5 additions & 5 deletions src/carriers/h264_carrier/H264Decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ GstFlowReturn new_sample(GstAppSink *appsink, gpointer user_data)

data_for_gst_callback *dec_data = (data_for_gst_callback*)user_data;

GstSample *sample = NULL;
GstSample *sample = nullptr;
g_signal_emit_by_name (appsink, "pull-sample", &sample, NULL);
if(!sample)
{
Expand Down Expand Up @@ -316,7 +316,7 @@ class H264DecoderHelper

bool istantiateElements()
{
gst_init(NULL, NULL);
gst_init(nullptr, nullptr);
pipeline = gst_pipeline_new ("video-player");
source = gst_element_factory_make ("udpsrc", "video-source");
rtpDepay = gst_element_factory_make ("rtph264depay", "rtp-depay");
Expand Down Expand Up @@ -349,10 +349,10 @@ class H264DecoderHelper
GstAppSinkCallbacks cbs; // Does this need to be kept alive?

// Set Video Sink callback methods
cbs.eos = NULL;
cbs.new_preroll = NULL;
cbs.eos = nullptr;
cbs.new_preroll = nullptr;
cbs.new_sample = &new_sample;
gst_app_sink_set_callbacks( GST_APP_SINK( sink ), &cbs, &gst_cbk_data, NULL );
gst_app_sink_set_callbacks( GST_APP_SINK( sink ), &cbs, &gst_cbk_data, nullptr );

/* //3) add watch ( a message handler)
bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
Expand Down
12 changes: 6 additions & 6 deletions src/carriers/h264_carrier/H264Stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,27 @@ using namespace yarp::sig;
using namespace std;

H264Stream::H264Stream(h264Decoder_cfgParamters &config) :
delegate(NULL),
delegate(nullptr),
blobHeader{0,0,0},
phase(0),
cursor(NULL),
cursor(nullptr),
remaining(0),
decoder(nullptr),
cfg(config)
{}

H264Stream::~H264Stream()
{
if (decoder!=NULL)
if (decoder!=nullptr)
{
delete decoder;
decoder = NULL;
decoder = nullptr;
}

if (delegate!=NULL)
if (delegate!=nullptr)
{
delete delegate;
delegate = NULL;
delegate = nullptr;
}
}

Expand Down
12 changes: 6 additions & 6 deletions src/carriers/mpi_carrier/src/MpiBcastCarrier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ void MpiBcastCarrier::close() {
if (electionMember) {
getCaster().remove(name, this);
MpiBcastCarrier* elect = getCaster().getElect(name);
if (elect == NULL) {
if (elect == nullptr) {
delete comm;
}
} else {
Expand All @@ -37,7 +37,7 @@ void MpiBcastCarrier::close() {
void MpiBcastCarrier::createStream(bool sender) {
if (sender) {
MpiBcastCarrier* elect = getCaster().getElect(name);
if (elect != NULL) {
if (elect != nullptr) {
comm = elect->comm;
}
else {
Expand Down Expand Up @@ -81,14 +81,14 @@ void MpiBcastCarrier::prepareDisconnect() {
* Adopted from MCastCarrier
* ----------------------------
*/
ElectionOf<yarp::os::PeerRecord<MpiBcastCarrier> > *MpiBcastCarrier::caster = NULL;
ElectionOf<yarp::os::PeerRecord<MpiBcastCarrier> > *MpiBcastCarrier::caster = nullptr;

ElectionOf<yarp::os::PeerRecord<MpiBcastCarrier> >& MpiBcastCarrier::getCaster() {
yarp::os::NetworkBase::lock();
if (caster==NULL) {
if (caster==nullptr) {
caster = new ElectionOf<yarp::os::PeerRecord<MpiBcastCarrier> >;
yarp::os::NetworkBase::unlock();
if (caster==NULL) {
if (caster==nullptr) {
yError("No memory for MpiBcastCarrier::caster");
std::exit(1);
}
Expand All @@ -99,7 +99,7 @@ ElectionOf<yarp::os::PeerRecord<MpiBcastCarrier> >& MpiBcastCarrier::getCaster()
}
bool MpiBcastCarrier::isElect() const {
MpiBcastCarrier *elect = getCaster().getElect(name);
return elect==this || elect==NULL;
return elect==this || elect==nullptr;
}

bool MpiBcastCarrier::isActive() const {
Expand Down
2 changes: 1 addition & 1 deletion src/carriers/mpi_carrier/src/MpiCarrier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ using namespace yarp::os;
using yarp::os::impl::Logger;
#endif

MpiCarrier::MpiCarrier() : stream(NULL), comm(NULL) {
MpiCarrier::MpiCarrier() : stream(nullptr), comm(nullptr) {
#ifdef MPI_DEBUG
Logger::get().setVerbosity(1);
#endif
Expand Down
8 changes: 4 additions & 4 deletions src/carriers/mpi_carrier/src/MpiComm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ using namespace yarp::os;
/* --------------------------------------- */
/* MpiControlThread */

yarp::os::MpiControlThread *MpiControl = NULL;
yarp::os::MpiControlThread *MpiControl = nullptr;

void finalizeMPI() {
if (MpiControl) {
MpiControl->finalize();
delete MpiControl;
MpiControl = NULL;
MpiControl = nullptr;
}
int ct = 0;
int finalized;
Expand Down Expand Up @@ -60,7 +60,7 @@ bool MpiControlThread::threadInit() {
// We need full multithread support for MPI
int requested = MPI_THREAD_MULTIPLE;
// Passing NULL for argc/argv pointers is fine for MPI-2
int err = MPI_Init_thread(NULL, NULL, requested , &provided);
int err = MPI_Init_thread(nullptr, nullptr, requested , &provided);
if (err != MPI_SUCCESS ) {
yError("MpiControlThread: Couldn't initialize MPI\n");
return false;
Expand All @@ -81,7 +81,7 @@ bool MpiControlThread::threadInit() {
/* MpiComm */

MpiComm::MpiComm(std::string name) : name(name) {
if (MpiControl == NULL) {
if (MpiControl == nullptr) {
MpiControl = new yarp::os::MpiControlThread;
}
if (! MpiControl->isRunning()) {
Expand Down
4 changes: 2 additions & 2 deletions src/carriers/mpi_carrier/src/MpiStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ using namespace yarp::os;

MpiStream::MpiStream(std::string n, MpiComm* c)
: terminate(false), name(n), comm(c) {
readBuffer = NULL;
readBuffer = nullptr;
resetBuffer();

}
Expand All @@ -33,7 +33,7 @@ void MpiStream::resetBuffer() {
readAt = 0;
readAvail = 0;
delete [] readBuffer;
readBuffer = NULL;
readBuffer = nullptr;
}

bool MpiStream::isOk() const {
Expand Down
2 changes: 1 addition & 1 deletion src/devices/laserHokuyo/laserHokuyo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ bool laserHokuyo::open(yarp::os::Searchable& config)
return false;
}

pSerial=0;
pSerial=nullptr;
driver.view(pSerial);

if (!pSerial)
Expand Down
30 changes: 15 additions & 15 deletions src/devices/portaudio/PortAudioDeviceDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ static int bufferIOCallback( const void *inputBuffer, void *outputBuffer,
finished = paContinue;
}

if( inputBuffer == NULL )
if( inputBuffer == nullptr )
{
for( i=0; i<framesToCalc; i++ )
{
Expand Down Expand Up @@ -135,12 +135,12 @@ static int bufferIOCallback( const void *inputBuffer, void *outputBuffer,
}

PortAudioDeviceDriver::PortAudioDeviceDriver() :
stream(0),
stream(nullptr),
err(paNoError),
i(0),
numSamples(0),
numBytes(0),
system_resource(NULL),
system_resource(nullptr),
numChannels(0),
frequency(0),
loopBack(false),
Expand Down Expand Up @@ -213,9 +213,9 @@ bool PortAudioDeviceDriver::open(PortAudioDeviceDriverSettings& config)
numBytes = numSamples * sizeof(SAMPLE) * numChannels;
int twiceTheBuffer = numBytes * 2;
dataBuffers.numChannels=numChannels;
if (dataBuffers.playData==0)
if (dataBuffers.playData==nullptr)
dataBuffers.playData = new circularBuffer(twiceTheBuffer);
if (dataBuffers.recData==0)
if (dataBuffers.recData==nullptr)
dataBuffers.recData = new circularBuffer(twiceTheBuffer);
if (wantRead) dataBuffers.canRec = true;
if (wantWrite) dataBuffers.canPlay = true;
Expand All @@ -230,21 +230,21 @@ bool PortAudioDeviceDriver::open(PortAudioDeviceDriverSettings& config)
printf("Device number %d\n", inputParameters.device);
inputParameters.channelCount = numChannels;
inputParameters.sampleFormat = PA_SAMPLE_TYPE;
if ((Pa_GetDeviceInfo( inputParameters.device ))!=0) {
if ((Pa_GetDeviceInfo( inputParameters.device ))!=nullptr) {
inputParameters.suggestedLatency = Pa_GetDeviceInfo( inputParameters.device )->defaultLowInputLatency;
}
inputParameters.hostApiSpecificStreamInfo = NULL;
inputParameters.hostApiSpecificStreamInfo = nullptr;

outputParameters.device = (deviceNumber==-1)?Pa_GetDefaultOutputDevice():deviceNumber;
outputParameters.channelCount = numChannels;
outputParameters.sampleFormat = PA_SAMPLE_TYPE;
outputParameters.suggestedLatency = Pa_GetDeviceInfo( outputParameters.device )->defaultLowOutputLatency;
outputParameters.hostApiSpecificStreamInfo = NULL;
outputParameters.hostApiSpecificStreamInfo = nullptr;

err = Pa_OpenStream(
&stream,
wantRead?(&inputParameters):NULL,
wantWrite?(&outputParameters):NULL,
wantRead?(&inputParameters):nullptr,
wantWrite?(&outputParameters):nullptr,
frequency,
DEFAULT_FRAMES_PER_BUFFER,
paClipOff,
Expand Down Expand Up @@ -292,7 +292,7 @@ void PortAudioDeviceDriver::handleError()
bool PortAudioDeviceDriver::close()
{
pThread.stop();
if (stream != 0)
if (stream != nullptr)
{
err = Pa_CloseStream( stream );
if( err != paNoError )
Expand All @@ -303,15 +303,15 @@ bool PortAudioDeviceDriver::close()
}
}

if (this->dataBuffers.playData != 0)
if (this->dataBuffers.playData != nullptr)
{
delete this->dataBuffers.playData;
this->dataBuffers.playData = 0;
this->dataBuffers.playData = nullptr;
}
if (this->dataBuffers.recData != 0)
if (this->dataBuffers.recData != nullptr)
{
delete this->dataBuffers.recData;
this->dataBuffers.recData = 0;
this->dataBuffers.recData = nullptr;
}

return (err==paNoError);
Expand Down
2 changes: 1 addition & 1 deletion src/devices/test_grabber/TestFrameGrabber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ void TestFrameGrabber::printTime(unsigned char* pixbuf, int pixbuf_w, int pixbuf
int pixelsize = 5;
for (int i = 0; i<size; i++)
{
char* num_p = 0;
char* num_p = nullptr;
switch (s[i])
{
case '0': num_p = num[0].data; break;
Expand Down
2 changes: 1 addition & 1 deletion src/libYARP_OS/src/posix/TcpAcceptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ int TcpAcceptor::shared_open(const Contact& address) {
* Accept connection and set field for clientAddress.
*/
int TcpAcceptor::accept(TcpStream &new_stream) {
sockaddr *addr = 0;
sockaddr *addr = nullptr;
int len = 0; int *len_ptr = &len;

new_stream.set_handle( ::accept(get_handle(), (struct sockaddr *)&addr, (socklen_t*)len_ptr) );
Expand Down
20 changes: 10 additions & 10 deletions src/libYARP_dev/src/ControlBoardHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,19 +162,19 @@ class yarp::dev::ControlBoardHelper::PrivateUnitsHandler
ControlBoardHelper::ControlBoardHelper(int n, const int *aMap, const double *angToEncs, const double *zs, const double *newtons, const double *amps, const double *volts, const double *dutycycles, const double *kbemf, const double *ktau)
{
yAssert(n>=0); // if number of joints is negative complain!
yAssert(aMap!=0); // at least the axisMap is required
yAssert(aMap!=nullptr); // at least the axisMap is required
mPriv = new PrivateUnitsHandler(n);

memcpy(mPriv->axisMap, aMap, sizeof(int)*n);

if (zs!=0) memcpy(mPriv->position_zeros, zs, sizeof(double)*n);
if (angToEncs!=0) memcpy(mPriv->angleToEncoders, angToEncs, sizeof(double)*n);
if (newtons!=0) memcpy(mPriv->newtonsToSensors, newtons, sizeof(double)*n);
if (amps!=0) memcpy(mPriv->ampereToSensors, amps, sizeof(double)*n);
if (volts!=0) memcpy(mPriv->voltToSensors, volts, sizeof(double)*n);
if (dutycycles != 0) memcpy(mPriv->dutycycleToPWMs, dutycycles, sizeof(double)*n);
if (kbemf != 0) memcpy(mPriv->bemfToRaws, kbemf, sizeof(double)*n);
if (ktau != 0) memcpy(mPriv->ktauToRaws, ktau, sizeof(double)*n);
if (zs!=nullptr) memcpy(mPriv->position_zeros, zs, sizeof(double)*n);
if (angToEncs!=nullptr) memcpy(mPriv->angleToEncoders, angToEncs, sizeof(double)*n);
if (newtons!=nullptr) memcpy(mPriv->newtonsToSensors, newtons, sizeof(double)*n);
if (amps!=nullptr) memcpy(mPriv->ampereToSensors, amps, sizeof(double)*n);
if (volts!=nullptr) memcpy(mPriv->voltToSensors, volts, sizeof(double)*n);
if (dutycycles != nullptr) memcpy(mPriv->dutycycleToPWMs, dutycycles, sizeof(double)*n);
if (kbemf != nullptr) memcpy(mPriv->bemfToRaws, kbemf, sizeof(double)*n);
if (ktau != nullptr) memcpy(mPriv->ktauToRaws, ktau, sizeof(double)*n);

// invert the axis map
memset (mPriv->invAxisMap, 0, sizeof(int) * n);
Expand All @@ -195,7 +195,7 @@ ControlBoardHelper::ControlBoardHelper(int n, const int *aMap, const double *ang

ControlBoardHelper::~ControlBoardHelper()
{
if (mPriv) { delete mPriv; mPriv = 0; }
if (mPriv) { delete mPriv; mPriv = nullptr; }
}

yarp::dev::ControlBoardHelper::ControlBoardHelper(const ControlBoardHelper & other)
Expand Down
22 changes: 11 additions & 11 deletions src/libYARP_dev/src/ImplementAmplifierControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ using namespace yarp::dev;
ImplementAmplifierControl::ImplementAmplifierControl(yarp::dev::IAmplifierControlRaw *y)
{
iAmplifier= y;
helper = 0;
dTemp=0;
iTemp=0;
helper = nullptr;
dTemp=nullptr;
iTemp=nullptr;
}

ImplementAmplifierControl::~ImplementAmplifierControl()
Expand All @@ -33,15 +33,15 @@ ImplementAmplifierControl::~ImplementAmplifierControl()

bool ImplementAmplifierControl:: initialize (int size, const int *amap, const double *enc, const double *zos, const double *ampereFactor, const double *voltFactor)
{
if (helper!=0)
if (helper!=nullptr)
return false;

helper=(void *)(new ControlBoardHelper(size, amap, enc, zos,nullptr, ampereFactor, voltFactor));
yAssert (helper != 0);
yAssert (helper != nullptr);
dTemp=new double[size];
yAssert (dTemp != 0);
yAssert (dTemp != nullptr);
iTemp=new int[size];
yAssert (iTemp != 0);
yAssert (iTemp != nullptr);

return true;
}
Expand All @@ -52,15 +52,15 @@ bool ImplementAmplifierControl:: initialize (int size, const int *amap, const do
*/
bool ImplementAmplifierControl::uninitialize ()
{
if (helper!=0)
if (helper!=nullptr)
delete castToMapper(helper);

delete [] dTemp;
delete [] iTemp;

helper=0;
dTemp=0;
iTemp=0;
helper=nullptr;
dTemp=nullptr;
iTemp=nullptr;
return true;
}

Expand Down
Loading

0 comments on commit 091030f

Please sign in to comment.