]> Dogcows Code - chaz/yoink/commitdiff
packet copy bugfix
authorCharles McGarvey <chazmcgarvey@brokenzipper.com>
Fri, 14 May 2010 06:35:37 +0000 (00:35 -0600)
committerCharles McGarvey <chazmcgarvey@brokenzipper.com>
Fri, 14 May 2010 06:35:37 +0000 (00:35 -0600)
src/Makefile.am
src/Moof/Packet.cc
src/Moof/Service.cc [new file with mode: 0644]
src/Moof/Socket.hh

index 6dd508e59cc4426cd268f2d131ff8e634aeee2b4..c9b5dd9bfe79714b2287628b435b4cc128f94a89 100644 (file)
@@ -55,6 +55,7 @@ libmoof_a_SOURCES = \
                                        Moof/Resource.hh \
                                        Moof/RigidBody.hh \
                                        Moof/Script.hh \
+                                       Moof/Service.cc \
                                        Moof/Service.hh \
                                        Moof/Settings.cc \
                                        Moof/Settings.hh \
index 6923e7cb06e5d4a507ec1d8cbe2064e784503a4b..842d6c1d9e9406d89dcf488b61b5df6f8b0a8cb1 100644 (file)
@@ -144,6 +144,7 @@ Packet& Packet::operator=(const Packet& copy)
        mBoolW = copy.mBoolW;
        mBoolNumR = copy.mBoolNumR;
        mBoolNumW = copy.mBoolNumW;
+       if (mBuffer) memcpy(mBuffer, copy.mBuffer, mSize);
        return *this;
 }
 
@@ -254,7 +255,7 @@ size_t Packet::write(const void* bytes, size_t size)
                }
                if (!mBuffer) return 0;
        }
-       memcpy(&mBuffer[mW], bytes, nBytes);
+       memcpy(mBuffer + mW, bytes, nBytes);
        mW += nBytes;
        return nBytes;
 }
@@ -345,7 +346,7 @@ Packet& Packet::operator>>(double& value)
 size_t Packet::read(void* bytes, size_t size)
 {
        size_t nBytes = std::min(size, mW - mR);
-       memcpy(bytes, &mBuffer[mR], nBytes);
+       memcpy(bytes, mBuffer + mR, nBytes);
        mR += nBytes;
        return nBytes;
 }
diff --git a/src/Moof/Service.cc b/src/Moof/Service.cc
new file mode 100644 (file)
index 0000000..43689af
--- /dev/null
@@ -0,0 +1,37 @@
+
+/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+**]  All rights reserved.
+*
+* vi:ts=4 sw=4 tw=75
+*
+* Distributable under the terms and conditions of the 2-clause BSD license;
+* see the file COPYING for a complete text of the license.
+*
+**************************************************************************/
+
+#include "Service.hh"
+
+
+namespace Mf {
+
+
+ServiceBroadcaster::ServiceBroadcaster(const std::string& name)
+{
+}
+
+void ServiceBroadcaster::update(Scalar t, Scalar dt)
+{
+}
+
+
+ServiceLocator::ServiceLocator(const std::string& name)
+{
+}
+
+void ServiceLocator::update(Scalar t, Scalar dt)
+{
+}
+
+
+} // namespace Mf
+
index 948f9423785ea944087f29e580b5ef5b4f6f4391..fcf1a3edbfc0464395941929c222d699d53a1e91 100644 (file)
@@ -390,6 +390,7 @@ public:
 
        int set(int option, int value = 0)
        {
+               if (mFd == -1) mFd = socket(mAddress.family(), mAddress.type(), 0);
                if (option == SO_NONBLOCK)
                {
 #ifdef HAVE_FCNTL
@@ -404,12 +405,14 @@ public:
 
        int set(int option, const std::string& value)
        {
+               if (mFd == -1) mFd = socket(mAddress.family(), mAddress.type(), 0);
                return setsockopt(mFd, SOL_SOCKET, option,
                                value.data(), value.length());
        }
 
        int get(int option, int& value)
        {
+               if (mFd == -1) mFd = socket(mAddress.family(), mAddress.type(), 0);
                if (option == SO_NONBLOCK)
                {
 #ifdef HAVE_FCNTL
@@ -425,6 +428,7 @@ public:
 
        int get(int option, std::string& value)
        {
+               if (mFd == -1) mFd = socket(mAddress.family(), mAddress.type(), 0);
                char str[64] = {'\0'};
                socklen_t optlen = sizeof(str);
                int result = getsockopt(mFd, SOL_SOCKET, option, &str, &optlen);
This page took 0.02579 seconds and 4 git commands to generate.