gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] /srv/bzr/gnash/rtmp r9744: always use a shared_ptr for ho


From: rob
Subject: [Gnash-commit] /srv/bzr/gnash/rtmp r9744: always use a shared_ptr for holding a Buffer.
Date: Tue, 18 Nov 2008 09:08:34 -0700
User-agent: Bazaar (1.5)

------------------------------------------------------------
revno: 9744
committer: address@hidden
branch nick: rtmp
timestamp: Tue 2008-11-18 09:08:34 -0700
message:
  always use a shared_ptr for holding a Buffer.
modified:
  libnet/network.cpp
  libnet/network.h
=== modified file 'libnet/network.cpp'
--- a/libnet/network.cpp        2008-11-16 23:25:40 +0000
+++ b/libnet/network.cpp        2008-11-18 16:08:34 +0000
@@ -696,55 +696,83 @@
     return false;
 }
 
-amf::Buffer *
+boost::shared_ptr<amf::Buffer>
 Network::readNet()
 {
 //    GNASH_REPORT_FUNCTION;
 
-    amf::Buffer *buffer = new amf::Buffer;
-    int nbytes = readNet(buffer);
-    if (nbytes > 0) {
-       buffer->resize(nbytes);
-       return buffer;
+    boost::shared_ptr<amf::Buffer> buffer(new amf::Buffer);
+    int ret = readNet(buffer);
+    if (ret > 0) {
+       buffer->resize(ret);
     }
 
-    return 0;
+    return buffer;
 }
 
 // Read from the connection
 int
-Network::readNet(amf::Buffer *buffer)
-{
-//    GNASH_REPORT_FUNCTION;
-    return readNet(_sockfd, buffer->reference(), buffer->size(), _timeout);
-}
-
-int
-Network::readNet(amf::Buffer *buffer, int timeout)
-{
-//    GNASH_REPORT_FUNCTION;
-    return readNet(_sockfd, buffer->reference(), buffer->size(), timeout);
-}
-
-int
-Network::readNet(byte_t *buffer, int nbytes)
-{
-//    GNASH_REPORT_FUNCTION;
-    return readNet(_sockfd, buffer, nbytes, _timeout);
-}
-
-int
-Network::readNet(byte_t *buffer, int nbytes, int timeout)
-{
-//    GNASH_REPORT_FUNCTION;
-    return readNet(_sockfd, buffer, nbytes, timeout);
-}
-
-int
-Network::readNet(int fd, byte_t *buffer, int nbytes)
-{
-//    GNASH_REPORT_FUNCTION;
-    return readNet(fd, buffer, nbytes, _timeout);
+Network::readNet(int fd, boost::shared_ptr<amf::Buffer> buffer)
+{
+    int ret = readNet(fd, buffer->reference(), buffer->size(), _timeout);
+    if (ret > 0) {
+       buffer->resize(ret);
+    }
+
+    return ret;
+}
+
+int
+Network::readNet(boost::shared_ptr<amf::Buffer> buffer)
+{
+//    GNASH_REPORT_FUNCTION;
+    int ret = readNet(_sockfd, buffer, _timeout);
+
+    return ret;
+}
+
+int
+Network::readNet(boost::shared_ptr<amf::Buffer> buffer, int timeout)
+{
+//    GNASH_REPORT_FUNCTION;
+    int ret = readNet(_sockfd, buffer->reference(), buffer->size(), timeout);
+    if (ret > 0) {
+       buffer->resize(ret);
+    }
+
+    return ret;
+}
+
+int
+Network::readNet(int fd, boost::shared_ptr<amf::Buffer> buffer, int timeout)
+{
+    int ret = readNet(fd, buffer->reference(), buffer->size(), timeout);
+    if (ret > 0) {
+       buffer->resize(ret);
+    }
+
+    return ret;
+}
+
+int
+Network::readNet(byte_t *data, int nbytes)
+{
+//    GNASH_REPORT_FUNCTION;
+    return readNet(_sockfd, data, nbytes, _timeout);
+}
+
+int
+Network::readNet(byte_t *data, int nbytes, int timeout)
+{
+//    GNASH_REPORT_FUNCTION;
+    return readNet(_sockfd, data, nbytes, timeout);
+}
+
+int
+Network::readNet(int fd, byte_t *data, int nbytes)
+{
+//    GNASH_REPORT_FUNCTION;
+    return readNet(fd, data, nbytes, _timeout);
 }
 
 int

=== modified file 'libnet/network.h'
--- a/libnet/network.h  2008-11-06 22:41:17 +0000
+++ b/libnet/network.h  2008-11-18 16:08:34 +0000
@@ -148,13 +148,15 @@
     /// @param nbytes The number of bytes to try to read.
     ///
     /// @return The number of bytes read.
-    amf::Buffer *readNet();
-    int readNet(amf::Buffer *buffer);
-    int readNet(amf::Buffer *buffer, int timeout);
-    int readNet(byte_t *buffer, int nbytes);
-    int readNet(byte_t *buffer, int nbytes, int timeout);
-    int readNet(int fd, byte_t *buffer, int nbytes);
-    int readNet(int fd, byte_t *buffer, int nbytes, int timeout);
+    boost::shared_ptr<amf::Buffer> readNet();
+    int readNet(boost::shared_ptr<amf::Buffer> buffer);
+    int readNet(int fd, boost::shared_ptr<amf::Buffer> buffer);
+    int readNet(boost::shared_ptr<amf::Buffer> buffer, int timeout);
+    int readNet(int fd, boost::shared_ptr<amf::Buffer> buffer, int timeout);
+    int readNet(byte_t *data, int nbytes);
+    int readNet(byte_t *data, int nbytes, int timeout);
+    int readNet(int fd, byte_t *data, int nbytes);
+    int readNet(int fd, byte_t *data, int nbytes, int timeout);
     
     /// \brief Write to the opened connection.
     ///


reply via email to

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