diff options
Diffstat (limited to 'src/lib/util')
-rw-r--r-- | src/lib/util/aviio.cpp | 2 | ||||
-rw-r--r-- | src/lib/util/corealloc.h | 2 | ||||
-rw-r--r-- | src/lib/util/options.cpp | 23 | ||||
-rw-r--r-- | src/lib/util/options.h | 5 |
4 files changed, 30 insertions, 2 deletions
diff --git a/src/lib/util/aviio.cpp b/src/lib/util/aviio.cpp index 90918c06673..a448128070b 100644 --- a/src/lib/util/aviio.cpp +++ b/src/lib/util/aviio.cpp @@ -1297,7 +1297,7 @@ avi_error avi_read_sound_samples(avi_file *file, int channel, UINT32 firstsample UINT32 bytes_per_sample; file_error filerr; avi_stream *stream; - int offset; + int offset = 0; /* get the audio stream */ stream = get_audio_stream(file, channel, &offset); diff --git a/src/lib/util/corealloc.h b/src/lib/util/corealloc.h index 4f0b961eb59..2c1df6dd46c 100644 --- a/src/lib/util/corealloc.h +++ b/src/lib/util/corealloc.h @@ -27,7 +27,9 @@ // global allocation helpers -- use these instead of new and delete #define global_alloc(_type) new _type +#define global_alloc_nothrow(_type) new (std::nothrow) _type #define global_alloc_array(_type, _num) new _type[_num] +#define global_alloc_array_nothrow(_type, _num) new (std::nothrow) _type[_num] #define global_free(_ptr) do { delete _ptr; } while (0) #define global_free_array(_ptr) do { delete[] _ptr; } while (0) diff --git a/src/lib/util/options.cpp b/src/lib/util/options.cpp index d7ab454d063..830721127ac 100644 --- a/src/lib/util/options.cpp +++ b/src/lib/util/options.cpp @@ -58,7 +58,8 @@ core_options::entry::entry(const char *name, const char *description, UINT32 fla m_seqid(0), m_error_reported(false), m_priority(OPTION_PRIORITY_DEFAULT), - m_description(description) + m_description(description), + m_changed(false) { // copy in the name(s) as appropriate if (name != nullptr) @@ -615,6 +616,16 @@ bool core_options::exists(const char *name) const } //------------------------------------------------- +// is_changed - return if option have been marked +// changed +//------------------------------------------------- + +bool core_options::is_changed(const char *name) const +{ + auto curentry = m_entrymap.find(name); + return (curentry != m_entrymap.end()) ? curentry->second->is_changed() : false; +} +//------------------------------------------------- // set_value - set the raw option value //------------------------------------------------- @@ -656,6 +667,16 @@ void core_options::set_flag(const char *name, UINT32 mask, UINT32 flag) curentry->second->set_flag(mask, flag); } +void core_options::mark_changed(const char* name) +{ + // find the entry first + auto curentry = m_entrymap.find(name); + if (curentry == m_entrymap.end()) + { + return; + } + curentry->second->mark_changed(); +} //------------------------------------------------- // reset - reset the options state, removing diff --git a/src/lib/util/options.h b/src/lib/util/options.h index 1df89bed6c7..5edf64a9fcd 100644 --- a/src/lib/util/options.h +++ b/src/lib/util/options.h @@ -89,12 +89,14 @@ public: bool is_internal() const { return m_flags & OPTION_FLAG_INTERNAL; } bool has_range() const { return (!m_minimum.empty() && !m_maximum.empty()); } int priority() const { return m_priority; } + bool is_changed() const { return m_changed; } // setters void set_value(const char *newvalue, int priority); void set_default_value(const char *defvalue); void set_description(const char *description); void set_flag(UINT32 mask, UINT32 flag); + void mark_changed() { m_changed = true; } void revert(int priority); private: @@ -110,6 +112,7 @@ public: std::string m_defdata; // default data for this item std::string m_minimum; // minimum value std::string m_maximum; // maximum value + bool m_changed; // changed flag }; // construction/destruction @@ -157,6 +160,7 @@ public: float float_value(const char *name) const { return atof(value(name)); } UINT32 seqid(const char *name) const; bool exists(const char *name) const; + bool is_changed(const char *name) const; // setting void set_command(const char *command); @@ -164,6 +168,7 @@ public: bool set_value(const char *name, int value, int priority, std::string &error_string); bool set_value(const char *name, float value, int priority, std::string &error_string); void set_flag(const char *name, UINT32 mask, UINT32 flags); + void mark_changed(const char *name); // misc static const char *unadorned(int x = 0) { return s_option_unadorned[MIN(x, MAX_UNADORNED_OPTIONS)]; } |