gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] gnash ChangeLog server/stream.cpp server/stream.h


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog server/stream.cpp server/stream.h
Date: Wed, 20 Sep 2006 14:15:22 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  06/09/20 14:15:22

Modified files:
        .              : ChangeLog 
        server         : stream.cpp stream.h 

Log message:
        added memory-friendly string reader methods.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.879&r2=1.880
http://cvs.savannah.gnu.org/viewcvs/gnash/server/stream.cpp?cvsroot=gnash&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/gnash/server/stream.h?cvsroot=gnash&r1=1.11&r2=1.12

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.879
retrieving revision 1.880
diff -u -b -r1.879 -r1.880
--- ChangeLog   20 Sep 2006 12:55:58 -0000      1.879
+++ ChangeLog   20 Sep 2006 14:15:22 -0000      1.880
@@ -1,5 +1,7 @@
 2006-09-20 Sandro Santilli  <address@hidden>
 
+       * server/stream.{h,cpp}: added memory-friendly string reader
+         functions.
        * server/parser/button_character_def.cpp: more symbolic
          names.
 

Index: server/stream.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/stream.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- server/stream.cpp   14 Sep 2006 04:49:03 -0000      1.10
+++ server/stream.cpp   20 Sep 2006 14:15:22 -0000      1.11
@@ -162,6 +162,21 @@
                return retval;
        }
 
+       void
+       stream::read_string(std::string& to)
+       {
+               align();
+
+               to.clear();
+
+               char    c;
+               while ((c = read_u8()) != 0)
+               {
+                       to += c; 
+               }
+
+       }
+
 
        char*   stream::read_string_with_length()
        {
@@ -186,6 +201,20 @@
                }
        }
 
+       void stream::read_string_with_length(std::string& to)
+       {
+               align();
+
+               unsigned int    len = read_u8();
+               to.resize(len);
+
+               for (unsigned int i = 0; i < len; ++i)
+               {
+                       to[i] = read_u8();
+               }
+
+       }
+
 
        int     stream::get_position()
        {

Index: server/stream.h
===================================================================
RCS file: /sources/gnash/gnash/server/stream.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- server/stream.h     14 Sep 2006 23:54:22 -0000      1.11
+++ server/stream.h     20 Sep 2006 14:15:22 -0000      1.12
@@ -60,12 +60,26 @@
                char*   read_string();  
 
                /// \brief
+               /// Reads a null-terminated string from the given file and
+               /// assigns it to the given std::string, overriding any
+               /// previous value of it.
+               ///
+               void    read_string(std::string& to);
+
+               /// \brief
                /// Reads *and new[]'s* the string from the given file.
                /// Ownership passes to the caller; caller must delete[] the
                /// string when it is done with it.
                /// For string that begins with an 8-bit length code.
                char*   read_string_with_length();
 
+               /// \brief
+               /// Reads a sized string from the given file and
+               /// assigns it to the given std::string,k overriding any
+               /// previous value of it.
+               ///
+               void    read_string_with_length(std::string& to);
+
                /// Return our current (byte) position in the input stream.
                int     get_position();
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]