CVSROOT: /sources/gnash Module name: gnash Changes by: Sandro Santilli <strk> 07/06/16 12:47:55
Modified files: . : ChangeLog libbase : LoadThread.cpp LoadThread.h image.cpp image.h image_filters.cpp noseek_fd_adapter.cpp server/asobj : Global.cpp Sound.cpp Sound.h SoundFfmpeg.cpp SoundGst.cpp SoundMad.cpp xmlsocket.cpp Log message: * libbase/: image.{cpp,h}, LoadThread.{cpp,h}, image_filters.cpp, noseek_fd_adapter.cpp, reduce number of explicit deletes by using scoped pointers * server/asobj/Global.cpp: reduce explicit deletes... * server/asobj/: Sound.{cpp,h}, SoundFfmpeg.{cpp,h}, SoundGst.{cpp,h}, SoundMad.{cpp,h}: Use a smart pointer for the NetConnection reference, and implement markReachableResources to mark it. * server/asobj/xmlsocket.cpp (anydata): don't use a module-static to keep track of leftovers !! CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.3561&r2=1.3562 http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/LoadThread.cpp?cvsroot=gnash&r1=1.13&r2=1.14 http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/LoadThread.h?cvsroot=gnash&r1=1.10&r2=1.11 http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/image.cpp?cvsroot=gnash&r1=1.20&r2=1.21 http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/image.h?cvsroot=gnash&r1=1.13&r2=1.14 http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/image_filters.cpp?cvsroot=gnash&r1=1.14&r2=1.15 http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/noseek_fd_adapter.cpp?cvsroot=gnash&r1=1.19&r2=1.20 http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Global.cpp?cvsroot=gnash&r1=1.62&r2=1.63 http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Sound.cpp?cvsroot=gnash&r1=1.17&r2=1.18 http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Sound.h?cvsroot=gnash&r1=1.5&r2=1.6 http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/SoundFfmpeg.cpp?cvsroot=gnash&r1=1.10&r2=1.11 http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/SoundGst.cpp?cvsroot=gnash&r1=1.7&r2=1.8 http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/SoundMad.cpp?cvsroot=gnash&r1=1.8&r2=1.9 http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/xmlsocket.cpp?cvsroot=gnash&r1=1.28&r2=1.29 Patches: Index: ChangeLog =================================================================== RCS file: /sources/gnash/gnash/ChangeLog,v retrieving revision 1.3561 retrieving revision 1.3562 diff -u -b -r1.3561 -r1.3562 --- ChangeLog 16 Jun 2007 11:27:38 -0000 1.3561 +++ ChangeLog 16 Jun 2007 12:47:52 -0000 1.3562 @@ -1,5 +1,17 @@ 2007-06-16 Sandro Santilli <[EMAIL PROTECTED]> + * libbase/: image.{cpp,h}, LoadThread.{cpp,h}, + image_filters.cpp, noseek_fd_adapter.cpp, + reduce number of explicit deletes by using scoped pointers + * server/asobj/Global.cpp: reduce explicit deletes... + * server/asobj/: Sound.{cpp,h}, SoundFfmpeg.{cpp,h}, SoundGst.{cpp,h}, + SoundMad.{cpp,h}: Use a smart pointer for the NetConnection + reference, and implement markReachableResources to mark it. + * server/asobj/xmlsocket.cpp (anydata): don't use a module-static + to keep track of leftovers !! + +2007-06-16 Sandro Santilli <[EMAIL PROTECTED]> + * server/vm/ExecutableCode.h: implement markReachableResources for executable code. * server/movie_root.{cpp,h}: mark resources reachable by Index: libbase/LoadThread.cpp =================================================================== RCS file: /sources/gnash/gnash/libbase/LoadThread.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -u -b -r1.13 -r1.14 --- libbase/LoadThread.cpp 30 May 2007 07:28:09 -0000 1.13 +++ libbase/LoadThread.cpp 16 Jun 2007 12:47:53 -0000 1.14 @@ -16,7 +16,7 @@ // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // -// $Id: LoadThread.cpp,v 1.13 2007/05/30 07:28:09 tgc Exp $ +// $Id: LoadThread.cpp,v 1.14 2007/06/16 12:47:53 strk Exp $ #include "LoadThread.h" @@ -33,7 +33,7 @@ _loadPosition(0), _userPosition(0), _actualPosition(0), - _cache(NULL), + _cache(), _cacheStart(0), _cachedData(0), _cacheSize(0), @@ -55,7 +55,6 @@ _thread.reset(NULL); } #endif - if (_cache) delete[] _cache; } bool LoadThread::setStream(std::auto_ptr<tu_file> stream) @@ -96,7 +95,7 @@ // If the data is in the cache we used it if (_cacheStart <= _userPosition && static_cast<long>(bytes) + _userPosition <= _cacheStart + _cachedData) { - memcpy(dst, _cache + (_userPosition - _cacheStart), bytes); + memcpy(dst, _cache.get() + (_userPosition - _cacheStart), bytes); _userPosition += bytes; return bytes; @@ -144,7 +143,7 @@ // buffer, note the new position and return the actual amount read int ret = _stream->read_bytes(dst, bytes); - memcpy(_cache +(_userPosition - _cacheStart), dst, ret); + memcpy(_cache.get() +(_userPosition - _cacheStart), dst, ret); _cachedData = _userPosition - _cacheStart + ret; _userPosition += ret; _actualPosition = _userPosition; @@ -157,9 +156,8 @@ // check if the cache is big enough to contain the wanted data if (static_cast<long>(bytes) > _cacheSize-20000) { - delete[] _cache; _cacheSize = bytes+20000; - _cache = new uint8_t[_cacheSize]; + _cache.reset( new uint8_t[_cacheSize] ); } // To avoid recaching all the time, we cache some data from before @@ -185,7 +183,7 @@ // Try to read a wanted amount of bytes into the given // buffer, note the new position and return the actual amount read - int ret = _stream->read_bytes(_cache, readdata); + int ret = _stream->read_bytes(_cache.get(), readdata); _cachedData = ret; _cacheStart = newcachestart; @@ -197,7 +195,7 @@ int newret = bytes; if (static_cast<int>(bytes) > ret) newret = ret - (_userPosition - newcachestart); - memcpy(dst, _cache + (_userPosition - newcachestart), newret); + memcpy(dst, _cache.get() + (_userPosition - newcachestart), newret); _userPosition += newret; _actualPosition = newcachestart + _cachedData; if (newcachestart + _cachedData > _loadPosition) @@ -242,10 +240,10 @@ boost::mutex::scoped_lock lock(_mutex); #endif - _cache = new uint8_t[1024*500]; + _cache.reset( new uint8_t[1024*500] ); _cacheSize = 1024*500; - int ret = _stream->read_bytes(_cache, 1024); + int ret = _stream->read_bytes(_cache.get(), 1024); _cacheStart = 0; _cachedData = ret; _loadPosition = 1024; @@ -287,7 +285,7 @@ // the "the edge", and "warm up" the remaining data. int ret; if (_cachedData + _chunkSize > _cacheSize) { - ret = _stream->read_bytes(_cache + _cachedData, _cacheSize - _cachedData); + ret = _stream->read_bytes(_cache.get() + _cachedData, _cacheSize - _cachedData); _cachedData += ret; if (ret != _cacheSize - _cachedData) { @@ -302,7 +300,7 @@ } } else { - ret = _stream->read_bytes(_cache + _cachedData, _chunkSize); + ret = _stream->read_bytes(_cache.get() + _cachedData, _chunkSize); if (ret != _chunkSize) { _completed = true; } Index: libbase/LoadThread.h =================================================================== RCS file: /sources/gnash/gnash/libbase/LoadThread.h,v retrieving revision 1.10 retrieving revision 1.11 diff -u -b -r1.10 -r1.11 --- libbase/LoadThread.h 27 May 2007 14:22:03 -0000 1.10 +++ libbase/LoadThread.h 16 Jun 2007 12:47:53 -0000 1.11 @@ -25,6 +25,7 @@ #include <boost/thread/thread.hpp> #include <boost/thread/mutex.hpp> #include <boost/bind.hpp> +#include <boost/scoped_array.hpp> #include <memory> @@ -129,7 +130,7 @@ volatile long _actualPosition; // Cache... - uint8_t* _cache; + boost::scoped_array<uint8_t> _cache; // The fileposition where the cache start volatile long _cacheStart; Index: libbase/image.cpp =================================================================== RCS file: /sources/gnash/gnash/libbase/image.cpp,v retrieving revision 1.20 retrieving revision 1.21 diff -u -b -r1.20 -r1.21 --- libbase/image.cpp 2 May 2007 12:19:58 -0000 1.20 +++ libbase/image.cpp 16 Jun 2007 12:47:53 -0000 1.21 @@ -12,6 +12,7 @@ #include "jpeg.h" #include "tu_file.h" #include <cstring> +#include <boost/scoped_array.hpp> namespace image @@ -67,13 +68,14 @@ assert(m_pitch >= m_width * 3); assert((m_pitch & 3) == 0); -// m_data = (uint8_t*) dlmalloc(m_pitch * m_height); m_data = new uint8_t[m_pitch * m_height]; } rgb::~rgb() { -// dlfree(m_data); + // TODO FIXME: m_data is a member of image_base, + // so ONLY image_base should delete it ! + // USE A SCOPED POINTER FOR THIS ! delete [] m_data; } @@ -107,7 +109,9 @@ rgba::~rgba() { -// dlfree(m_data); + // TODO FIXME: m_data is a member of image_base, + // so ONLY image_base should delete it ! + // USE A SCOPED POINTER FOR THIS ! delete [] m_data; } @@ -162,7 +166,6 @@ alpha::~alpha() { -// dlfree(m_data); delete [] m_data; } @@ -298,13 +301,12 @@ void write_jpeg(tu_file* out, rgb* image, int quality) // Write the given image to the given out stream, in jpeg format. { - jpeg::output* j_out = jpeg::output::create(out, image->m_width, image->m_height, quality); + std::auto_ptr<jpeg::output> j_out ( jpeg::output::create(out, image->m_width, image->m_height, quality) ); for (int y = 0; y < image->m_height; y++) { j_out->write_scanline(scanline(image, y)); } - delete j_out; } @@ -323,22 +325,23 @@ } - rgb* read_jpeg(tu_file* in) // Create and read a new image from the stream. + // + // TODO: return by auto_ptr ! + // + rgb* read_jpeg(tu_file* in) { - jpeg::input* j_in = jpeg::input::create(in); - if (j_in == NULL) return NULL; + std::auto_ptr<jpeg::input> j_in ( jpeg::input::create(in) ); + if (!j_in.get()) return 0; - rgb* im = image::create_rgb(j_in->get_width(), j_in->get_height()); + std::auto_ptr<rgb> im ( image::create_rgb(j_in->get_width(), j_in->get_height()) ); for (int y = 0; y < j_in->get_height(); y++) { - j_in->read_scanline(scanline(im, y)); + j_in->read_scanline(scanline(im.get(), y)); } - delete j_in; - - return im; + return im.release(); } @@ -363,24 +366,27 @@ } - rgba* read_swf_jpeg3(tu_file* in) // For reading SWF JPEG3-style image data, like ordinary JPEG, // but stores the data in rgba format. + // + // TODO: return by auto_ptr ! + // + rgba* read_swf_jpeg3(tu_file* in) { - jpeg::input* j_in = jpeg::input::create_swf_jpeg2_header_only(in); - if (j_in == NULL) return NULL; + std::auto_ptr<jpeg::input> j_in ( jpeg::input::create_swf_jpeg2_header_only(in) ); + if ( ! j_in.get() ) return 0; j_in->start_image(); - rgba* im = image::create_rgba(j_in->get_width(), j_in->get_height()); + std::auto_ptr<rgba> im ( image::create_rgba(j_in->get_width(), j_in->get_height()) ); - uint8_t* line = new uint8_t[3*j_in->get_width()]; + boost::scoped_array<uint8_t> line ( new uint8_t[3*j_in->get_width()] ); for (int y = 0; y < j_in->get_height(); y++) { - j_in->read_scanline(line); + j_in->read_scanline(line.get()); - uint8_t* data = scanline(im, y); + uint8_t* data = scanline(im.get(), y); for (int x = 0; x < j_in->get_width(); x++) { data[4*x+0] = line[3*x+0]; @@ -390,12 +396,9 @@ } } - delete [] line; - j_in->finish_image(); - delete j_in; - return im; + return im.release(); // TODO: return by auto_ptr ! } @@ -428,37 +431,6 @@ } } - -#if 0 - SDL_Surface* create_SDL_Surface(rgb* image) - // Steal *image's data to create an SDL_Surface. - // - // DELETES image!!! - { - assert(image->m_pitch < 65536); // SDL_Surface only uses uint16_t for pitch!!! - - SDL_Surface* s = SDL_CreateRGBSurfaceFrom(image->m_data, - image->m_width, image->m_height, 24, image->m_pitch, - SDL_SwapLE32(0x0FF), - SDL_SwapLE32(0x0FF00), - SDL_SwapLE32(0x0FF0000), - 0); - - // s owns *image's data now -- invalidate *image. - image->m_data = 0; - image->m_height = 0; - image->m_width = 0; - image->m_pitch = 0; - delete image; - - assert(s->pixels); - assert(s->format->BytesPerPixel == 3); - assert(s->format->BitsPerPixel == 24); - - return s; - } -#endif // 0 - void make_next_miplevel(rgb* image) // Fast, in-place resample. For making mip-maps. Munges the // input image to produce the output image. Index: libbase/image.h =================================================================== RCS file: /sources/gnash/gnash/libbase/image.h,v retrieving revision 1.13 retrieving revision 1.14 diff -u -b -r1.13 -r1.14 --- libbase/image.h 2 May 2007 12:19:58 -0000 1.13 +++ libbase/image.h 16 Jun 2007 12:47:53 -0000 1.14 @@ -12,6 +12,8 @@ #include "tu_config.h" #include "tu_types.h" +#include <boost/scoped_array.hpp> + class tu_file; namespace jpeg { class input; } @@ -35,7 +37,13 @@ id_image m_type; + // TODO FIXME: m_data allocation is currently managed + // by subclasses (see rgb and rgba), this is really unsafe. + // Rather, *this* calss should manage it, using a scoped + // pointer + // USE A SCOPED POINTER FOR THIS ! uint8_t* m_data; + int m_width; int m_height; int m_pitch; // byte offset from one row to the next Index: libbase/image_filters.cpp =================================================================== RCS file: /sources/gnash/gnash/libbase/image_filters.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -u -b -r1.14 -r1.15 --- libbase/image_filters.cpp 1 Dec 2006 10:22:12 -0000 1.14 +++ libbase/image_filters.cpp 16 Jun 2007 12:47:54 -0000 1.15 @@ -11,7 +11,7 @@ // converted from K&R C to C-like C++, changed the interfaces a bit, // etc. -/* $Id: image_filters.cpp,v 1.14 2006/12/01 10:22:12 alexeev Exp $ */ +/* $Id: image_filters.cpp,v 1.15 2007/06/16 12:47:54 strk Exp $ */ #include "image.h" #include "utility.h" @@ -387,8 +387,6 @@ support = filter_table[default_type].support; -// image::rgb* tmp; /* intermediate image */ -// float xscale, yscale; /* zoom scale factors */ int i, k; /* loop variables */ unsigned int j; /* loop variables */ int n; /* pixel number */ @@ -412,7 +410,7 @@ int in_window_h = int(ceilf(in_y1) - floorf(in_y0) + 1); /* create intermediate image to hold horizontal zoom */ - image::rgb* tmp = image::create_rgb(out_width, in_window_h); + std::auto_ptr<image::rgb> tmp ( image::create_rgb(out_width, in_window_h) ); float xscale = (float) (out_width - 1) / in_width; float yscale = (float) (out_height - 1) / in_height; @@ -467,7 +465,7 @@ green += raster[pixel * 3 + 1] * contrib[i][j].weight; blue += raster[pixel * 3 + 2] * contrib[i][j].weight; } - put_pixel(tmp, i, k, red, green, blue); + put_pixel(tmp.get(), i, k, red, green, blue); } } my_cfree(raster); @@ -508,7 +506,7 @@ /* apply filter to zoom vertically from tmp to dst */ raster = (uint8_t*) my_calloc(tmp->m_height, 3); for (k = 0; k < tmp->m_width; ++k) { - get_column(raster, tmp, k); + get_column(raster, tmp.get(), k); for (i = 0; i < out_height; ++i) { float red = 0.0f; float green = 0.0f; @@ -526,7 +524,6 @@ contrib.resize(0); - delete tmp; } @@ -554,7 +551,6 @@ support = filter_table[default_type].support; - image::rgba* tmp; /* intermediate image */ float xscale, yscale; /* zoom scale factors */ int i, k; /* loop variables */ unsigned int j; /* loop variables */ @@ -579,7 +575,7 @@ int in_window_h = int(ceilf(in_y1) - floorf(in_y0) + 1); /* create intermediate image to hold horizontal zoom */ - tmp = image::create_rgba(out_width, in_window_h); + std::auto_ptr<image::rgba> tmp( image::create_rgba(out_width, in_window_h) ); xscale = (float) (out_width - 1) / in_width; yscale = (float) (out_height - 1) / in_height; @@ -636,7 +632,7 @@ blue += raster[pixel * 4 + 2] * contrib[i][j].weight; alpha += raster[pixel * 4 + 3] * contrib[i][j].weight; } - put_pixel(tmp, i, k, red, green, blue, alpha); + put_pixel(tmp.get(), i, k, red, green, blue, alpha); } } my_cfree(raster); @@ -677,7 +673,7 @@ /* apply filter to zoom vertically from tmp to dst */ raster = (uint8_t*) my_calloc(tmp->m_height, 4); for (k = 0; k < tmp->m_width; ++k) { - get_column(raster, tmp, k); + get_column(raster, tmp.get(), k); for (i = 0; i < out_height; ++i) { float red = 0.0f; float green = 0.0f; @@ -697,7 +693,6 @@ contrib.resize(0); - delete tmp; } } // end namespace image Index: libbase/noseek_fd_adapter.cpp =================================================================== RCS file: /sources/gnash/gnash/libbase/noseek_fd_adapter.cpp,v retrieving revision 1.19 retrieving revision 1.20 diff -u -b -r1.19 -r1.20 --- libbase/noseek_fd_adapter.cpp 28 May 2007 15:41:02 -0000 1.19 +++ libbase/noseek_fd_adapter.cpp 16 Jun 2007 12:47:54 -0000 1.20 @@ -27,6 +27,8 @@ #include <unistd.h> #include <cstring> +#include <boost/scoped_array.hpp> + //#define GNASH_NOSEEK_FD_VERBOSE 1 // define this if you want seeks back to be reported (on stderr) @@ -217,15 +219,14 @@ #endif - char* buf = new char[bytes_needed]; - int bytes_read = read(_fd, (void*)buf, bytes_needed); + boost::scoped_array<char> buf ( new char[bytes_needed] ); + int bytes_read = read(_fd, (void*)buf.get(), bytes_needed); if ( bytes_read < 0 ) { fprintf(stderr, "Error reading " SIZET_FMT " bytes from input stream", bytes_needed); _running = false; - delete [] buf; // this looks like a CRITICAL error (since we don't handle it..) throw gnash::GnashException("Error reading from input stream"); return; @@ -239,14 +240,12 @@ fprintf(stderr, "EOF reached\n"); #endif _running = false; - delete [] buf; return; } } - cache(buf, static_cast<size_t>(bytes_read)); + cache(buf.get(), static_cast<size_t>(bytes_read)); - delete [] buf; } /*private*/ Index: server/asobj/Global.cpp =================================================================== RCS file: /sources/gnash/gnash/server/asobj/Global.cpp,v retrieving revision 1.62 retrieving revision 1.63 diff -u -b -r1.62 -r1.63 --- server/asobj/Global.cpp 4 Jun 2007 19:21:20 -0000 1.62 +++ server/asobj/Global.cpp 16 Jun 2007 12:47:55 -0000 1.63 @@ -17,7 +17,7 @@ // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // -/* $Id: Global.cpp,v 1.62 2007/06/04 19:21:20 strk Exp $ */ +/* $Id: Global.cpp,v 1.63 2007/06/16 12:47:55 strk Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -72,6 +72,7 @@ #include "xmlsocket.h" #include <limits> // for numeric_limits<double>::quiet_NaN +#include <boost/scoped_array.hpp> // Common code to warn and return if a required single arg is not present // and to warn if there are extra args. @@ -206,8 +207,8 @@ // Set up some variables const string digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - char *input_buffer = new char[fn.arg(0).to_string().size()+1]; - char *input = input_buffer; + boost::scoped_array<char> input_buffer ( new char[fn.arg(0).to_string().size()+1] ); + char *input = input_buffer.get(); strcpy(input,fn.arg(0).to_string().c_str()); int base; bool bNegative; @@ -254,7 +255,6 @@ if (base < 2 || base > 36) { - delete [] input_buffer; as_value rv; rv.set_nan(); return rv; @@ -272,7 +272,6 @@ // If we didn't get any digits, we should return NaN if (numdigits == 0) { - delete [] input_buffer; as_value rv; rv.set_nan(); return rv; @@ -287,8 +286,6 @@ if (bNegative) result = -result; - delete [] input_buffer; - // Now return the parsed string return as_value(result); } Index: server/asobj/Sound.cpp =================================================================== RCS file: /sources/gnash/gnash/server/asobj/Sound.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -u -b -r1.17 -r1.18 --- server/asobj/Sound.cpp 4 May 2007 21:40:50 -0000 1.17 +++ server/asobj/Sound.cpp 16 Jun 2007 12:47:55 -0000 1.18 @@ -59,15 +59,15 @@ Sound::Sound() : as_object(getSoundInterface()), - connection(NULL), + connection(), soundId(-1), externalSound(false), isStreaming(false) { } -Sound::~Sound() { - if (connection) delete connection; +Sound::~Sound() +{ } @@ -140,8 +140,7 @@ log_msg(_("%s is still testing!"), __FUNCTION__); if (connection) { - log_error(_("%s: This sound already has a connection? (We try to handle this by deleting the old one...)"), __FUNCTION__); - delete connection; + log_error(_("%s: This sound already has a connection? (We try to handle this by overriding the old one...)"), __FUNCTION__); } externalURL = file; Index: server/asobj/Sound.h =================================================================== RCS file: /sources/gnash/gnash/server/asobj/Sound.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -b -r1.5 -r1.6 --- server/asobj/Sound.h 28 May 2007 15:41:08 -0000 1.5 +++ server/asobj/Sound.h 16 Jun 2007 12:47:55 -0000 1.6 @@ -58,13 +58,26 @@ std::string soundName; protected: + +#ifdef GNASH_USE_GC + /// Mark all reachable resources of a Sound, for the GC + // + /// Reachable resources are: + /// - associated NetConnection object (connection) + /// + void markReachableResources() const + { + if ( connection ) connection->setReachable(); + } +#endif // GNASH_USE_GC + bool _duration; bool _id3; bool _onID3; bool _onLoad; bool _onComplete; bool _position; - NetConnection* connection; + boost::intrusive_ptr<NetConnection> connection; int soundId; bool externalSound; Index: server/asobj/SoundFfmpeg.cpp =================================================================== RCS file: /sources/gnash/gnash/server/asobj/SoundFfmpeg.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -u -b -r1.10 -r1.11 --- server/asobj/SoundFfmpeg.cpp 30 May 2007 12:42:03 -0000 1.10 +++ server/asobj/SoundFfmpeg.cpp 16 Jun 2007 12:47:55 -0000 1.11 @@ -40,7 +40,7 @@ { SoundFfmpeg* so = static_cast<SoundFfmpeg*>(opaque); - NetConnection* nc = so->connection; + boost::intrusive_ptr<NetConnection> nc = so->connection; size_t ret = nc->read(static_cast<void*>(buf), buf_size); so->inputPos += ret; @@ -53,7 +53,7 @@ SoundFfmpeg::seekMedia(void *opaque, offset_t offset, int whence){ SoundFfmpeg* so = static_cast<SoundFfmpeg*>(opaque); - NetConnection* nc = so->connection; + boost::intrusive_ptr<NetConnection> nc = so->connection; // Offset is absolute new position in the file @@ -83,7 +83,7 @@ SoundFfmpeg::setupDecoder(SoundFfmpeg* so) { - NetConnection* nc = so->connection; + boost::intrusive_ptr<NetConnection> nc = so->connection; assert(nc); // Pass stuff from/to the NetConnection object. @@ -369,8 +369,7 @@ remainingLoops = 0; if (connection) { - log_error(_("This sound already has a connection. (We try to handle this by deleting the old one...)")); - delete connection; + log_error(_("This sound already has a connection. (We try to handle this by overriding the old one...)")); } externalURL = file; Index: server/asobj/SoundGst.cpp =================================================================== RCS file: /sources/gnash/gnash/server/asobj/SoundGst.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -u -b -r1.7 -r1.8 --- server/asobj/SoundGst.cpp 4 May 2007 21:40:50 -0000 1.7 +++ server/asobj/SoundGst.cpp 16 Jun 2007 12:47:55 -0000 1.8 @@ -62,7 +62,7 @@ { SoundGst* so = static_cast<SoundGst*>(opaque); - NetConnection* nc = so->connection; + boost::intrusive_ptr<NetConnection> nc = so->connection; size_t ret = nc->read(static_cast<void*>(buf), buf_size); so->inputPos += ret; @@ -75,7 +75,7 @@ SoundGst::seekMedia(void *opaque, int offset, int whence){ SoundGst* so = static_cast<SoundGst*>(opaque); - NetConnection* nc = so->connection; + boost::intrusive_ptr<NetConnection> nc = so->connection; // Offset is absolute new position in the file @@ -133,7 +133,7 @@ SoundGst::setupDecoder(SoundGst* so) { - NetConnection* nc = so->connection; + boost::intrusive_ptr<NetConnection> nc = so->connection; assert(nc); // Pass stuff from/to the NetConnection object. @@ -226,8 +226,7 @@ remainingLoops = 0; if (connection) { - log_error(_("%s: This sound already has a connection? (We try to handle this by deleting the old one...)"), __FUNCTION__); - delete connection; + log_error(_("%s: This sound already has a connection? (We try to handle this by overriding the old one...)"), __FUNCTION__); } externalURL = file; Index: server/asobj/SoundMad.cpp =================================================================== RCS file: /sources/gnash/gnash/server/asobj/SoundMad.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -u -b -r1.8 -r1.9 --- server/asobj/SoundMad.cpp 18 May 2007 12:51:47 -0000 1.8 +++ server/asobj/SoundMad.cpp 16 Jun 2007 12:47:55 -0000 1.9 @@ -74,7 +74,7 @@ SoundMad::setupDecoder(SoundMad* so) { - NetConnection* nc = so->connection; + boost::intrusive_ptr<NetConnection> nc = so->connection; assert(nc); // Pass stuff from/to the NetConnection object. @@ -347,8 +347,7 @@ remainingLoops = 0; if (connection) { - log_error(_("This sound already has a connection? (We try to handle this by deleting the old one...)")); - delete connection; + log_error(_("This sound already has a connection? (We try to handle this by overriding the old one...)")); } externalURL = file; Index: server/asobj/xmlsocket.cpp =================================================================== RCS file: /sources/gnash/gnash/server/asobj/xmlsocket.cpp,v retrieving revision 1.28 retrieving revision 1.29 diff -u -b -r1.28 -r1.29 --- server/asobj/xmlsocket.cpp 28 May 2007 15:41:08 -0000 1.28 +++ server/asobj/xmlsocket.cpp 16 Jun 2007 12:47:55 -0000 1.29 @@ -55,6 +55,7 @@ #endif #include <boost/algorithm/string/case_conv.hpp> +#include <boost/scoped_array.hpp> #ifndef MAXHOSTNAMELEN #define MAXHOSTNAMELEN 256 @@ -200,7 +201,7 @@ int retries = 10; char *ptr, *eom; int cr, index = 0; - static char *leftover = 0; + boost::scoped_array<char> leftover; int adjusted_size; @@ -267,12 +268,12 @@ while (strchr(ptr, '\n') > 0) { if (leftover) { processing(false); - //log_msg(_("%s: The remainder is: \"%s\""), __FUNCTION__, leftover); + //log_msg(_("%s: The remainder is: \"%s\""), __FUNCTION__, leftover.get()); //log_msg(_("%s: The rest of the message is: \"%s\""), __FUNCTION__, ptr); - adjusted_size = memadjust(cr + strlen(leftover) + 1); + adjusted_size = memadjust(cr + strlen(leftover.get()) + 1); packet = new char[adjusted_size]; memset(packet, 0, adjusted_size); - strcpy(packet, leftover); + strcpy(packet, leftover.get()); strcat(packet, ptr); eom = strrchr(packet, '\n'); // drop the CR off the end there is one if (eom) { @@ -280,8 +281,7 @@ } //log_msg(_("%s: The whole message is: \"%s\""), __FUNCTION__, packet); ptr = strchr(ptr, '\n') + 2; // messages are delimited by a "\n\0" - delete leftover; - leftover = 0; + leftover.reset(); } else { adjusted_size = memadjust(cr + 1); packet = new char[adjusted_size]; @@ -308,10 +308,10 @@ } // end of while (cr) if (strlen(ptr) > 0) { - leftover = new char[strlen(ptr) + 1]; - strcpy(leftover, ptr); + leftover.reset( new char[strlen(ptr) + 1] ); + strcpy(leftover.get(), ptr); processing(true); - //log_msg(_("%s: Adding remainder: \"%s\""), __FUNCTION__, leftover); + //log_msg(_("%s: Adding remainder: \"%s\""), __FUNCTION__, leftover.get()); } processing(false); _______________________________________________ Gnash-commit mailing list Gnash-commit@gnu.org http://lists.gnu.org/mailman/listinfo/gnash-commit