Commit Graph

2735 Commits

Author SHA1 Message Date
Johannes Schickel
417064e311 Merge pull request #417 from digitall/STACK_fixes
ALL: Fix optimization unstable code on checking for null after new.
2014-01-17 17:48:16 -08:00
clone2727
9d9ced0734 Merge pull request #366 from clone2727/he-saves-target-name
RFC: Make HE games use the target name in all save files
2014-01-17 15:59:44 -08:00
D G Turner
ac4087856f ALL: Remove optimization unstable code on checking for null after new.
These issues were identified by the STACK tool.

By default, the C++ new operator will throw an exception on allocation
failure, rather than returning a null pointer.

The result is that testing the returned pointer for null is redundant
and _may_ be removed by the compiler. This is thus optimization
unstable and may result in incorrect behaviour at runtime.

However, we do not use exceptions as they are not supported by all
compilers and may be disabled.

To make this stable without removing the null check, you could qualify
the new operator call with std::nothrow to indicate that this should
return a null, rather than throwing an exception.

However, using (std::nothrow) was not desirable due to the Symbian
toolchain lacking a <new> header.
A global solution to this was also not easy by redefining "new" as "new
(std::nothrow)" due to custom constructors in NDS toolchain and various
common classes.

Also, this would then need explicit checks for OOM adding to all new
usages as per C malloc which is untidy.

For now to remove this optimisation unstable code is best as it is
likely to not be present anyway, and OOM will cause a system library
exception instead, even without exceptions enabled in the application
code.
2014-01-15 02:36:19 +00:00
Johannes Schickel
3a8c243d34 COMMON: Revert "Fix mismatched new/delete in the MemoryPool class".
This reverts commit b585addc23.

The allocation of MemoryPool's page memory is doing in MemoryPool::allocPage,
which uses ::malloc, thus we need to use ::free to free the page memory in
MemoryPool::freeUnusedPages.
2013-12-17 00:26:50 +01:00
Filippos Karapetis
b585addc23 COMMON: Fix mismatched new/delete in the MemoryPool class
Memory is allocated with new in Hashmap::allocNode() and incorrectly
freed with free() in ~MemoryPool() and freeUnusedPages().
Issue reported by Dr. Memory
2013-12-17 01:16:28 +02:00
Johannes Schickel
df07a4655b COMMON: Add Latvian language code. 2013-12-05 16:26:44 +01:00
Johannes Schickel
a94c66f1e3 COMMON: Fix order of languages.
These are sorted according to the alphabetical order of the description. Thus,
Croatian should be between Chinese (Taiwan) and Czech.
2013-12-05 16:26:44 +01:00
Johannes Schickel
abe6d30f36 COMMON: Document Common::String::unsigned_type. 2013-11-23 21:34:55 +01:00
Johannes Schickel
4c15e51ab5 COMMON: Document U32String a bit better. 2013-11-23 21:34:54 +01:00
Johannes Schickel
b90400da44 COMMON: Add simple UTF-32 string class U32String. 2013-11-23 21:34:54 +01:00
Johannes Schickel
1a6f9378aa COMMON: Add underlying type names to Common::String.
The value_type is analogous to std::basic_string::value_type.
The unsigned_type on the other hand is an unsigned type of the value_type which
allows to obtain an character without nasty sign extension.
2013-11-23 21:34:54 +01:00
Filippos Karapetis
e36f24ad69 COMMON: Define int64 and uint64 if HAVE_CONFIG_H isn't set
This fixes compilation of sword25's pluto with Visual Studio. The issue
has been revealed with commit 34169a81. The other data types are
defined in scummsys.h, thus only the missing int64 and uint64 defines
are set.
2013-11-06 18:04:09 +02:00
Eugene Sandulenko
5d6c7fbcd1 RECORDER: Initialize variable. CID 1047258 2013-11-03 01:28:03 +02:00
Filippos Karapetis
b4f8e45a3c COMMON: SEEK_END offsets are negative
This was taken directly from the old code, which either used different
semantics, or had a genuine bug
2013-11-02 19:59:22 +02:00
Filippos Karapetis
732fb69b1c COMMON: Reenable SEEK_END seeking in GZipReadStream()
This is needed by the "Mirage" Wintermute game.
Vorbis can do backward seeking, thus we need to enable this for ZIP
streams. Since this can be a potentially slow operation, we throw a
warning (once per stream) when it occurs. Originally, SEEK_END seeks
in GZipReadStream were disabled by commit 9138128f. Refer to patch
#2050337 for more information.
2013-11-02 19:19:26 +02:00
Eugene Sandulenko
874939ae89 COMMON: Make XCode 5.0.1 happier 2013-10-27 22:45:49 +02:00
Matthew Hoops
eef7f9f46b COMMON: Fix the NE group icon resource type 2013-10-27 13:15:17 -04:00
D G Turner
a1998abed4 COMMON: Fix missing arjDecoder class variable init. CID 1002929
This fixes a couple of these variables by removing them as they
are unused or set-but-unused variables.
2013-10-05 07:02:18 +01:00
Eugene Sandulenko
e11da51202 COMMON: Make Coverity 6.6.1 happier
Apparently their tools do not include __has_feature clang extension.
I've submitted the bugreport to them but in the meantime let's have this
define in the system.
2013-09-27 11:06:22 +03:00
Filippos Karapetis
dca513dc20 COMMON: Expand the warnings thrown for broken DCL compressed data
The Russian translated versions of Neverhood have invalid unpacked
sizes for some compressed resources. This helps in identifying their
resource parameters more easily
2013-09-26 10:46:09 +03:00
Eugene Sandulenko
c55411a032 COMMON: Shut more Coverity warnings in coroutines. 2013-09-21 22:45:43 +03:00
Eugene Sandulenko
91bcfb290a COMMON: Use unused variables in coroutine macros.
This should fix couple of hundreds of Coverity detected defects.
2013-09-21 09:49:17 +03:00
Matthew Hoops
3f65a02ced COMMON: Make the two INI save file functions take a String reference 2013-08-12 20:48:55 -04:00
Johannes Schickel
7c2660c97e COMMON: Add setVal to ConfigManager::Domain.
This fixes compilation in the keymapper.
2013-08-13 00:11:46 +02:00
Johannes Schickel
818d3981e3 Merge pull request #377 from lordhoto/config-manager-cleanup
Config Manager Cleanup
2013-08-12 14:30:22 -07:00
Johannes Schickel
f7d3b06711 COMMON: Get rid of write version of ConfigManager::getGameDomains.
This can be abused to insert Domains into the game domains without any checks.
Instead, only write iterator access is given.
2013-08-12 01:33:29 +02:00
Johannes Schickel
0dae60a357 COMMON: Remove commented out include in config-manager.h. 2013-08-08 16:32:41 +02:00
Johannes Schickel
6da6e4e686 COMMON: Remove outdated comments on INIFile.
These very old comments claimed that ConfigManager uses INIFile. This is not
true however. Thus removing them should clear things up a little bit.
2013-08-08 16:30:38 +02:00
Johannes Schickel
63750d6780 COMMON: Rename ConfigFile to INIFile.
This clears up that 'ConfigFile' is actually a class handling only INI-files.
2013-08-08 16:28:38 +02:00
Johannes Schickel
774d53045d COMMON: Do not let ConfigManager::Domain inherit from StringMap.
Instead we provide wrapper functionality now. Intuitively a Domain is not a
simple StringMap.
2013-08-08 03:14:23 +02:00
Johannes Schickel
4790a4abd5 COMMON: Define all Unix98/BSD math constants in scummsys.h.
This should fix compilation on mingw64 with --enable-c++11 and also make sure
the constants are present on other systems for the uncommon case they might be
missing.
2013-08-02 20:02:02 +02:00
D G Turner
17ccd18ed3 COMMON: Add comment explaining reason for defining math constants. 2013-08-02 06:23:52 +01:00
D G Turner
26a9b528da COMMON: Move definition of math constants to scummsys header.
This should have no effect on common/math.h as scummsys is included at
the top anyway, but this will fix compilation on some toolchains when
strict ANSI language compliance is enabled i.e. -std=c++11, rather than
-std=gnu11.

This causes an issue as a side effect is to set a guard which disables
various non-standard defines in the system headers i.e. the M_PI and
M_SQRT1_2 constant definitions in the MinGW x86_64 toolchain on
buildbot.

By moving this into scummsys.h after the point of system math.h
inclusion, we can ensure that M_PI etc. are always present.
2013-07-31 06:18:58 +01:00
Johannes Schickel
2f9b7ba686 COMMON: Enforce formatting guidelines a bit more in util.h. 2013-07-30 21:02:01 +02:00
Eugene Sandulenko
67af740f3a COMMON: Revert last commit as rightfully pointed out by fuzze. 2013-07-29 12:30:47 +03:00
Eugene Sandulenko
351af76f9b COMMON: Added copy constructors and copier to Rect and Point. 2013-07-29 12:25:57 +03:00
Eugene Sandulenko
2c812ade01 Merge pull request #353 from clone2727/eventrec_timer_fix
ALL: Don't use EventRecorder at all when not compiled in
2013-07-18 08:15:28 -07:00
Eugene Sandulenko
9572bc6e30 RECORDER: Fix wrong argument order 2013-07-15 14:31:34 +03:00
Sven Hesse
989ea7cb56 JANITORIAL: Remove trailing whitespace 2013-07-14 19:01:47 +02:00
Eugene Sandulenko
aaaf466c71 RECORDER: Fix CID 1046886. Uninit class variables. 2013-07-14 19:03:29 +03:00
Matthew Hoops
1f6894ab25 COMMON: Cleanup the MacResManager a bit 2013-07-11 23:45:19 -04:00
Matthew Hoops
4a7e4e5b22 ALL: Don't use EventRecorder at all when not compiled in 2013-07-06 23:54:45 -04:00
Eugene Sandulenko
3490091ba2 RECORDER: Fix tests compilation. Patch by D G Turner 2013-07-06 07:31:28 +03:00
Filippos Karapetis
ecc43c9b92 Revert "COMMON: Fix crash when the keymapper and the event recorder are enabled"
This reverts commit 93987d999c.
2013-07-05 03:05:54 +03:00
Filippos Karapetis
93987d999c COMMON: Fix crash when the keymapper and the event recorder are enabled
DefaultEventManager registers a keymapper that is supposed to be
auto-freed. However, the event recorder then sets itself as a new
keymapper, but because the autofree flag is already set,
registerMapper() ends up deleting the event recorder itself. Setting
the autofree flag before actually freeing the mapper fixes the issue
and prevents ScummVM from crashing on startup
2013-07-05 02:56:12 +03:00
Johannes Schickel
71b031be12 COMMON: Initialize EventDispatcher::_autoFreeMapper.
This fixes a branching on uninitialized variable reported by valgrind on
startup.
2013-07-05 01:45:09 +02:00
Eugene Sandulenko
49210a803a Merge pull request #331 from sev-/gsoc2012-eventsrecorder
GSoC2012: Event Recorder (reworked)
2013-07-04 04:58:54 -07:00
Johannes Schickel
a00c3e75b0 Merge pull request #342 from RichieSams/addDeleteRangeStringMethod
COMMON: Add erase method to String class
2013-07-01 05:18:49 -07:00
richiesams
e1ff60da7a COMMON: Add erase method to String class 2013-06-20 15:40:25 -05:00
Matthew Hoops
8dace22f97 COMMON: Fix custom NE resource type names 2013-06-09 21:18:33 -04:00