glib's g_try_malloc()/g_try_malloc0() was used, use g_free() to free the
memory. Otherwise use standard free(). Never use the wrong function!
- - Never use g_malloc() or g_malloc0(). These functions do not return NULL
+ - Never use g_malloc() or g_malloc0(). These functions do not return nullptr
if not enough memory is available but rather lead to an exit() or segfault
instead. This behaviour is not acceptable.
Use g_try_malloc()/g_try_malloc0() instead and check the return value.
void AndroidLogHandler::install_callbacks()
{
- sr_log_callback_set(sr_callback, NULL);
+ sr_log_callback_set(sr_callback, nullptr);
#ifdef ENABLE_DECODE
- srd_log_callback_set(srd_callback, NULL);
+ srd_log_callback_set(srd_callback, nullptr);
#endif
}
};
const int c = getopt_long(argc, argv,
- "l:Vh?", long_options, NULL);
+ "l:Vh?", long_options, nullptr);
if (c == -1)
break;
#ifdef ENABLE_DECODE
// Initialise libsigrokdecode
- if (srd_init(NULL) != SRD_OK) {
+ if (srd_init(nullptr) != SRD_OK) {
qDebug() << "ERROR: libsigrokdecode init failed.";
break;
}
Glib::VariantBase Decoder::getter(const char *id)
{
- GVariant *val = NULL;
+ GVariant *val = nullptr;
assert(decoder_);
g_hash_table_destroy(opt_hash);
if(!decoder_inst)
- return NULL;
+ return nullptr;
// Setup the channels
GHashTable *const channels = g_hash_table_new_full(g_str_hash,
namespace decode {
Row::Row() :
- decoder_(NULL),
- row_(NULL)
+ decoder_(nullptr),
+ row_(nullptr)
{
}
Row();
Row(const srd_decoder *decoder,
- const srd_decoder_annotation_row *row = NULL);
+ const srd_decoder_annotation_row *row = nullptr);
const srd_decoder* decoder() const;
const srd_decoder_annotation_row* row() const;
{
optional<int64_t> sample_count;
srd_session *session;
- srd_decoder_inst *prev_di = NULL;
+ srd_decoder_inst *prev_di = nullptr;
assert(segment_);
// We cannot fast-forward if there is no mip-map data at
// at the minimum level.
- fast_forward = (mip_map_[level].data != NULL);
+ fast_forward = (mip_map_[level].data != nullptr);
if (min_length < MipMapScaleFactor)
{
public:
explicit MainWindow(DeviceManager &device_manager,
- const char *open_file_name = NULL,
+ const char *open_file_name = nullptr,
QWidget *parent = 0);
QAction* action_open() const;
}
// Create a group
- populate_group(NULL, global_sigs);
+ populate_group(nullptr, global_sigs);
// Create the enable/disable all buttons
connect(&enable_all_channels_, SIGNAL(clicked()),
Bool::Bool(QString name, Getter getter, Setter setter) :
Property(name, getter, setter),
- check_box_(NULL)
+ check_box_(nullptr)
{
}
return check_box_;
if (!getter_)
- return NULL;
+ return nullptr;
Glib::VariantBase variant = getter_();
if (!variant.gobj())
- return NULL;
+ return nullptr;
bool value = Glib::VariantBase::cast_dynamic<Glib::Variant<bool>>(
variant).get();
suffix_(suffix),
range_(range),
step_(step),
- spin_box_(NULL)
+ spin_box_(nullptr)
{
}
return spin_box_;
if (!getter_)
- return NULL;
+ return nullptr;
Glib::VariantBase variant = getter_();
if (!variant.gobj())
- return NULL;
+ return nullptr;
double value = Glib::VariantBase::cast_dynamic<Glib::Variant<double>>(
variant).get();
Getter getter, Setter setter) :
Property(name, getter, setter),
values_(values),
- selector_(NULL)
+ selector_(nullptr)
{
}
return selector_;
if (!getter_)
- return NULL;
+ return nullptr;
Glib::VariantBase variant = getter_();
if (!variant.gobj())
- return NULL;
+ return nullptr;
selector_ = new QComboBox(parent);
for (unsigned int i = 0; i < values_.size(); i++) {
Property(name, getter, setter),
suffix_(suffix),
range_(range),
- spin_box_(NULL)
+ spin_box_(nullptr)
{
}
return spin_box_;
if (!getter_)
- return NULL;
+ return nullptr;
value_ = getter_();
GVariant *value = value_.gobj();
if (!value)
- return NULL;
+ return nullptr;
spin_box_ = new QSpinBox(parent);
spin_box_->setSuffix(suffix_);
if (!spin_box_)
return;
- GVariant *new_value = NULL;
+ GVariant *new_value = nullptr;
const GVariantType *const type = g_variant_get_type(value_.gobj());
assert(type);
Getter getter,
Setter setter) :
Property(name, getter, setter),
- line_edit_(NULL)
+ line_edit_(nullptr)
{
}
return line_edit_;
if (!getter_)
- return NULL;
+ return nullptr;
Glib::VariantBase variant = getter_();
if (!variant.gobj())
- return NULL;
+ return nullptr;
string value = Glib::VariantBase::cast_dynamic<Glib::Variant<ustring>>(
variant).get();
device_selector_(this, session.device_manager(),
main_window.action_connect()),
configure_button_(this),
- configure_button_action_(NULL),
+ configure_button_action_(nullptr),
channels_button_(this),
sample_count_(" samples", this),
sample_rate_("Hz", this),
{
Glib::VariantContainerBase gvar_dict;
GVariant *gvar_list;
- const uint64_t *elements = NULL;
+ const uint64_t *elements = nullptr;
gsize num_elements;
map< const ConfigKey*, std::set<Capability> > keys;
QComboBox *selector = new QComboBox(parent);
- selector->addItem("-", qVariantFromValue((void*)NULL));
+ selector->addItem("-", qVariantFromValue((void*)nullptr));
if (channel_iter == dec->channels().end())
selector->setCurrentIndex(0);
Signal(session, channel),
device_(device),
data_(data),
- trigger_none_(NULL),
- trigger_rising_(NULL),
- trigger_high_(NULL),
- trigger_falling_(NULL),
- trigger_low_(NULL),
- trigger_change_(NULL)
+ trigger_none_(nullptr),
+ trigger_rising_(nullptr),
+ trigger_high_(nullptr),
+ trigger_falling_(nullptr),
+ trigger_low_(nullptr),
+ trigger_change_(nullptr)
{
shared_ptr<Trigger> trigger;
namespace view {
RowItem::RowItem() :
- owner_(NULL),
+ owner_(nullptr),
layout_v_offset_(0),
visual_v_offset_(0),
v_offset_animation_(this, "visual_v_offset")
Trace(QString::fromUtf8(channel->name().c_str())),
session_(session),
channel_(channel),
- name_widget_(NULL),
+ name_widget_(nullptr),
updating_name_widget_(false)
{
assert(channel_);
TimeItem(view),
colour_(colour),
time_(time),
- value_action_(NULL),
- value_widget_(NULL),
+ value_action_(nullptr),
+ value_widget_(nullptr),
updating_value_widget_(false)
{
}
Trace::Trace(QString name) :
name_(name),
- popup_(NULL),
- popup_form_(NULL)
+ popup_(nullptr),
+ popup_form_(nullptr)
{
}
void Trace::on_popup_closed()
{
- popup_ = NULL;
- popup_form_ = NULL;
+ popup_ = nullptr;
+ popup_form_ = nullptr;
}
void Trace::on_text_changed(const QString &text)
pv::widgets::Popup* TraceGroup::create_popup(QWidget *parent)
{
(void)parent;
- return NULL;
+ return nullptr;
}
int TraceGroup::owner_visual_v_offset() const
const int ViewItem::HighlightRadius = 3;
ViewItem::ViewItem() :
- context_parent_(NULL),
+ context_parent_(nullptr),
drag_point_(INT_MIN, INT_MIN),
selected_(false)
{
Q_OBJECT
public:
- DecoderGroupBox(QString title, QWidget *parent = NULL);
+ DecoderGroupBox(QString title, QWidget *parent = nullptr);
void add_layout(QLayout *layout);
PopupToolButton::PopupToolButton(QWidget *parent) :
QToolButton(parent),
- popup_(NULL)
+ popup_(nullptr)
{
connect(this, SIGNAL(clicked(bool)), this, SLOT(on_clicked(bool)));
}
};
public:
- SweepTimingWidget(const char *suffix, QWidget *parent = NULL);
+ SweepTimingWidget(const char *suffix, QWidget *parent = nullptr);
void show_none();
void show_min_max_step(uint64_t min, uint64_t max, uint64_t step);
static bool prepare_signals();
public:
- explicit SignalHandler(QObject* parent = NULL);
+ explicit SignalHandler(QObject* parent = nullptr);
Q_SIGNALS:
void int_received();
const AnalogSegment::Envelope &m = s.envelope_levels_[i];
BOOST_CHECK_EQUAL(m.length, 0);
BOOST_CHECK_EQUAL(m.data_length, 0);
- BOOST_CHECK(m.samples == NULL);
+ BOOST_CHECK(m.samples == nullptr);
}
// Push 8 samples of all zeros
const AnalogSegment::Envelope &m = s.envelope_levels_[i];
BOOST_CHECK_EQUAL(m.length, 0);
BOOST_CHECK_EQUAL(m.data_length, 0);
- BOOST_CHECK(m.samples == NULL);
+ BOOST_CHECK(m.samples == nullptr);
}
// Push 8 samples of 1.0s to bring the total up to 16
const AnalogSegment::Envelope &e0 = s.envelope_levels_[0];
BOOST_CHECK_EQUAL(e0.length, 1);
BOOST_CHECK_EQUAL(e0.data_length, AnalogSegment::EnvelopeDataUnit);
- BOOST_REQUIRE(e0.samples != NULL);
+ BOOST_REQUIRE(e0.samples != nullptr);
BOOST_CHECK_EQUAL(e0.samples[0].min, 0.0f);
BOOST_CHECK_EQUAL(e0.samples[0].max, 1.0f);
const AnalogSegment::Envelope &m = s.envelope_levels_[i];
BOOST_CHECK_EQUAL(m.length, 0);
BOOST_CHECK_EQUAL(m.data_length, 0);
- BOOST_CHECK(m.samples == NULL);
+ BOOST_CHECK(m.samples == nullptr);
}
// Push 240 samples of all zeros to bring the total up to 256
const AnalogSegment::Envelope &e1 = s.envelope_levels_[1];
BOOST_CHECK_EQUAL(e1.length, 1);
BOOST_CHECK_EQUAL(e1.data_length, AnalogSegment::EnvelopeDataUnit);
- BOOST_REQUIRE(e1.samples != NULL);
+ BOOST_REQUIRE(e1.samples != nullptr);
BOOST_CHECK_EQUAL(e1.samples[0].min, -1.0f);
BOOST_CHECK_EQUAL(e1.samples[0].max, 1.0f);
}
BOOST_AUTO_TEST_CASE(TwoDecoderStack)
{
- sr_context *ctx = NULL;
+ sr_context *ctx = nullptr;
BOOST_REQUIRE(sr_init(&ctx) == SR_OK);
BOOST_REQUIRE(ctx);
- BOOST_REQUIRE(srd_init(NULL) == SRD_OK);
+ BOOST_REQUIRE(srd_init(nullptr) == SRD_OK);
srd_decoder_load_all();
sr_datafeed_logic logic;
logic.length = 0;
logic.unitsize = 1;
- logic.data = NULL;
+ logic.data = nullptr;
LogicSegment s(logic);
const LogicSegment::MipMapLevel &m = s.mip_map_[i];
BOOST_CHECK_EQUAL(m.length, 0);
BOOST_CHECK_EQUAL(m.data_length, 0);
- BOOST_CHECK(m.data == NULL);
+ BOOST_CHECK(m.data == nullptr);
}
// Push 8 samples of all zeros
const LogicSegment::MipMapLevel &m = s.mip_map_[i];
BOOST_CHECK_EQUAL(m.length, 0);
BOOST_CHECK_EQUAL(m.data_length, 0);
- BOOST_CHECK(m.data == NULL);
+ BOOST_CHECK(m.data == nullptr);
}
// Push 8 samples of 0x11s to bring the total up to 16
const LogicSegment::MipMapLevel &m0 = s.mip_map_[0];
BOOST_CHECK_EQUAL(m0.length, 1);
BOOST_CHECK_EQUAL(m0.data_length, LogicSegment::MipMapDataUnit);
- BOOST_REQUIRE(m0.data != NULL);
+ BOOST_REQUIRE(m0.data != nullptr);
BOOST_CHECK_EQUAL(((uint8_t*)m0.data)[0], 0x11);
// The higher levels should still be empty
const LogicSegment::MipMapLevel &m = s.mip_map_[i];
BOOST_CHECK_EQUAL(m.length, 0);
BOOST_CHECK_EQUAL(m.data_length, 0);
- BOOST_CHECK(m.data == NULL);
+ BOOST_CHECK(m.data == nullptr);
}
// Push 240 samples of all zeros to bring the total up to 256
const LogicSegment::MipMapLevel &m1 = s.mip_map_[1];
BOOST_CHECK_EQUAL(m1.length, 1);
BOOST_CHECK_EQUAL(m1.data_length, LogicSegment::MipMapDataUnit);
- BOOST_REQUIRE(m1.data != NULL);
+ BOOST_REQUIRE(m1.data != nullptr);
BOOST_CHECK_EQUAL(((uint8_t*)m1.data)[0], 0x11);
//----- Test LogicSegment::get_subsampled_edges -----//
BOOST_CHECK_EQUAL(s.mip_map_[0].length, 62500);
BOOST_CHECK_EQUAL(s.mip_map_[0].data_length,
LogicSegment::MipMapDataUnit);
- BOOST_REQUIRE(s.mip_map_[0].data != NULL);
+ BOOST_REQUIRE(s.mip_map_[0].data != nullptr);
prev_sample = 0;
for (unsigned int i = 0; i < s.mip_map_[0].length;)
BOOST_CHECK_EQUAL(s.mip_map_[1].length, 3906);
BOOST_CHECK_EQUAL(s.mip_map_[1].data_length,
LogicSegment::MipMapDataUnit);
- BOOST_REQUIRE(s.mip_map_[1].data != NULL);
+ BOOST_REQUIRE(s.mip_map_[1].data != nullptr);
prev_sample = 0;
for (unsigned int i = 0; i < s.mip_map_[1].length; i++)
BOOST_CHECK_EQUAL(s.mip_map_[2].length, 244);
BOOST_CHECK_EQUAL(s.mip_map_[2].data_length,
LogicSegment::MipMapDataUnit);
- BOOST_REQUIRE(s.mip_map_[2].data != NULL);
+ BOOST_REQUIRE(s.mip_map_[2].data != nullptr);
prev_sample = 0;
for (unsigned int i = 0; i < s.mip_map_[2].length; i++)
BOOST_CHECK_EQUAL(s.mip_map_[3].length, 15);
BOOST_CHECK_EQUAL(s.mip_map_[3].data_length,
LogicSegment::MipMapDataUnit);
- BOOST_REQUIRE(s.mip_map_[3].data != NULL);
+ BOOST_REQUIRE(s.mip_map_[3].data != nullptr);
for (unsigned int i = 0; i < s.mip_map_[3].length; i++)
BOOST_CHECK_EQUAL(*((uint8_t*)s.mip_map_[3].data + i),
const LogicSegment::MipMapLevel &m = s.mip_map_[i];
BOOST_CHECK_EQUAL(m.length, 0);
BOOST_CHECK_EQUAL(m.data_length, 0);
- BOOST_CHECK(m.data == NULL);
+ BOOST_CHECK(m.data == nullptr);
}
//----- Test LogicSegment::get_subsampled_edges -----//
BOOST_CHECK_EQUAL(s.mip_map_[0].length, 12);
BOOST_CHECK_EQUAL(s.mip_map_[0].data_length,
LogicSegment::MipMapDataUnit);
- BOOST_REQUIRE(s.mip_map_[0].data != NULL);
+ BOOST_REQUIRE(s.mip_map_[0].data != nullptr);
for (unsigned int i = 0; i < s.mip_map_[0].length;) {
BOOST_TEST_MESSAGE("Testing mip_map[0].data[" << i << "]");
const LogicSegment::MipMapLevel &m = s.mip_map_[i];
BOOST_CHECK_EQUAL(m.length, 0);
BOOST_CHECK_EQUAL(m.data_length, 0);
- BOOST_CHECK(m.data == NULL);
+ BOOST_CHECK(m.data == nullptr);
}
//----- Test get_subsampled_edges at reduced scale -----//
BOOST_CHECK_EQUAL(s.mip_map_[0].length, 12);
BOOST_CHECK_EQUAL(s.mip_map_[0].data_length,
LogicSegment::MipMapDataUnit);
- BOOST_REQUIRE(s.mip_map_[0].data != NULL);
+ BOOST_REQUIRE(s.mip_map_[0].data != nullptr);
for (unsigned int i = 0; i < s.mip_map_[0].length;) {
for (j = 0; i < s.mip_map_[0].length && j < 2; j++) {
const LogicSegment::MipMapLevel &m = s.mip_map_[i];
BOOST_CHECK_EQUAL(m.length, 0);
BOOST_CHECK_EQUAL(m.data_length, 0);
- BOOST_CHECK(m.data == NULL);
+ BOOST_CHECK(m.data == nullptr);
}
//----- Test get_subsampled_edges at a full scale -----//