summaryrefslogtreecommitdiff
path: root/plugins/gme/game-music-emu-0.6pre/gme/blargg_common.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/gme/game-music-emu-0.6pre/gme/blargg_common.cpp')
-rw-r--r--plugins/gme/game-music-emu-0.6pre/gme/blargg_common.cpp58
1 files changed, 58 insertions, 0 deletions
diff --git a/plugins/gme/game-music-emu-0.6pre/gme/blargg_common.cpp b/plugins/gme/game-music-emu-0.6pre/gme/blargg_common.cpp
new file mode 100644
index 00000000..91d2c882
--- /dev/null
+++ b/plugins/gme/game-music-emu-0.6pre/gme/blargg_common.cpp
@@ -0,0 +1,58 @@
+// Game_Music_Emu 0.6-pre. http://www.slack.net/~ant/
+
+#include "blargg_common.h"
+
+/* Copyright (C) 2008-2009 Shay Green. This module is free software; you
+can redistribute it and/or modify it under the terms of the GNU Lesser
+General Public License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version. This
+module is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+details. You should have received a copy of the GNU Lesser General Public
+License along with this module; if not, write to the Free Software Foundation,
+Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
+
+#include "blargg_source.h"
+
+BLARGG_NAMESPACE_BEGIN
+
+// defined here to avoid need for blargg_errors.cpp in simple programs
+blargg_err_def_t blargg_err_memory = BLARGG_ERR_MEMORY;
+
+void blargg_vector_::init()
+{
+ begin_ = NULL;
+ size_ = 0;
+}
+
+void blargg_vector_::clear()
+{
+ void* p = begin_;
+ begin_ = NULL;
+ size_ = 0;
+ free( p );
+}
+
+blargg_err_t blargg_vector_::resize_( size_t n, size_t elem_size )
+{
+ if ( n != size_ )
+ {
+ if ( n == 0 )
+ {
+ // Simpler to handle explicitly. Realloc will handle a size of 0,
+ // but then we have to avoid raising an error for a NULL return.
+ clear();
+ }
+ else
+ {
+ void* p = realloc( begin_, n * elem_size );
+ CHECK_ALLOC( p );
+ begin_ = p;
+ size_ = n;
+ }
+ }
+ return blargg_ok;
+}
+
+BLARGG_NAMESPACE_END