mirror of
https://github.com/holub/mame
synced 2025-07-04 09:28:51 +03:00
Revert "Remove unnecessary null checks" for now, undefined behavior but breaks too much, will have to revisit (nw)
This reverts commit 53635d12d7
.
This commit is contained in:
parent
a545ee63bd
commit
b60ae13d77
@ -122,8 +122,15 @@ device_t::~device_t()
|
|||||||
// info for a given region
|
// info for a given region
|
||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
|
|
||||||
|
// NOTE: this being NULL in a C++ member function can lead to undefined behavior.
|
||||||
|
// However, it is relied on throughout MAME, so will remain for now.
|
||||||
|
|
||||||
memory_region *device_t::memregion(const char *_tag) const
|
memory_region *device_t::memregion(const char *_tag) const
|
||||||
{
|
{
|
||||||
|
// safety first
|
||||||
|
if (this == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
// build a fully-qualified name and look it up
|
// build a fully-qualified name and look it up
|
||||||
return machine().memory().region(subtag(_tag).c_str());
|
return machine().memory().region(subtag(_tag).c_str());
|
||||||
}
|
}
|
||||||
@ -136,6 +143,10 @@ memory_region *device_t::memregion(const char *_tag) const
|
|||||||
|
|
||||||
memory_share *device_t::memshare(const char *_tag) const
|
memory_share *device_t::memshare(const char *_tag) const
|
||||||
{
|
{
|
||||||
|
// safety first
|
||||||
|
if (this == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
// build a fully-qualified name and look it up
|
// build a fully-qualified name and look it up
|
||||||
return machine().memory().shared(subtag(_tag).c_str());
|
return machine().memory().shared(subtag(_tag).c_str());
|
||||||
}
|
}
|
||||||
@ -148,6 +159,10 @@ memory_share *device_t::memshare(const char *_tag) const
|
|||||||
|
|
||||||
memory_bank *device_t::membank(const char *_tag) const
|
memory_bank *device_t::membank(const char *_tag) const
|
||||||
{
|
{
|
||||||
|
// safety first
|
||||||
|
if (this == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
// build a fully-qualified name and look it up
|
// build a fully-qualified name and look it up
|
||||||
return machine().memory().bank(subtag(_tag).c_str());
|
return machine().memory().bank(subtag(_tag).c_str());
|
||||||
}
|
}
|
||||||
@ -160,6 +175,10 @@ memory_bank *device_t::membank(const char *_tag) const
|
|||||||
|
|
||||||
ioport_port *device_t::ioport(const char *tag) const
|
ioport_port *device_t::ioport(const char *tag) const
|
||||||
{
|
{
|
||||||
|
// safety first
|
||||||
|
if (this == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
// build a fully-qualified name and look it up
|
// build a fully-qualified name and look it up
|
||||||
return machine().ioport().port(subtag(tag).c_str());
|
return machine().ioport().port(subtag(tag).c_str());
|
||||||
}
|
}
|
||||||
@ -172,6 +191,10 @@ ioport_port *device_t::ioport(const char *tag) const
|
|||||||
|
|
||||||
std::string device_t::parameter(const char *tag) const
|
std::string device_t::parameter(const char *tag) const
|
||||||
{
|
{
|
||||||
|
// safety first
|
||||||
|
if (this == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
// build a fully-qualified name and look it up
|
// build a fully-qualified name and look it up
|
||||||
return machine().parameters().lookup(subtag(tag));
|
return machine().parameters().lookup(subtag(tag));
|
||||||
}
|
}
|
||||||
|
@ -584,6 +584,10 @@ private:
|
|||||||
|
|
||||||
inline device_t *device_t::subdevice(const char *tag) const
|
inline device_t *device_t::subdevice(const char *tag) const
|
||||||
{
|
{
|
||||||
|
// safety first
|
||||||
|
if (this == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
// empty string or NULL means this device
|
// empty string or NULL means this device
|
||||||
if (tag == NULL || *tag == 0)
|
if (tag == NULL || *tag == 0)
|
||||||
return const_cast<device_t *>(this);
|
return const_cast<device_t *>(this);
|
||||||
@ -601,6 +605,10 @@ inline device_t *device_t::subdevice(const char *tag) const
|
|||||||
|
|
||||||
inline device_t *device_t::siblingdevice(const char *tag) const
|
inline device_t *device_t::siblingdevice(const char *tag) const
|
||||||
{
|
{
|
||||||
|
// safety first
|
||||||
|
if (this == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
// empty string or NULL means this device
|
// empty string or NULL means this device
|
||||||
if (tag == NULL || *tag == 0)
|
if (tag == NULL || *tag == 0)
|
||||||
return const_cast<device_t *>(this);
|
return const_cast<device_t *>(this);
|
||||||
|
@ -653,7 +653,9 @@ public:
|
|||||||
|
|
||||||
// getters
|
// getters
|
||||||
memory_share *next() const { return m_next; }
|
memory_share *next() const { return m_next; }
|
||||||
void *ptr() const { return m_ptr; }
|
// NOTE: this being NULL in a C++ member function can lead to undefined behavior.
|
||||||
|
// However, it is relied on throughout MAME, so will remain for now.
|
||||||
|
void *ptr() const { if (this == NULL) return NULL; return m_ptr; }
|
||||||
size_t bytes() const { return m_bytes; }
|
size_t bytes() const { return m_bytes; }
|
||||||
endianness_t endianness() const { return m_endianness; }
|
endianness_t endianness() const { return m_endianness; }
|
||||||
UINT8 bitwidth() const { return m_bitwidth; }
|
UINT8 bitwidth() const { return m_bitwidth; }
|
||||||
|
Loading…
Reference in New Issue
Block a user