]> git.sesse.net Git - cubemap/blobdiff - stream.cpp
Fix merge snafu in last commit. (Oops.)
[cubemap] / stream.cpp
index 17b5949172a531cae5a37eb4f8948dbf177bb4a9..37961fadad9253c09b01745233c62256ab115f18 100644 (file)
@@ -206,20 +206,24 @@ void Stream::add_data_deferred(const char *data, size_t bytes)
                hdr.flags = htonl(0);
 
                iovec iov;
-               iov.iov_base = new char[sizeof(hdr)];
+               iov.iov_base = new char[bytes + sizeof(hdr)];
+               iov.iov_len = bytes + sizeof(hdr);
+
                memcpy(iov.iov_base, &hdr, sizeof(hdr));
-               iov.iov_len = sizeof(hdr);
+               memcpy(reinterpret_cast<char *>(iov.iov_base) + sizeof(hdr), data, bytes);
+
+               queued_data.push_back(iov);
+       } else if (encoding == Stream::STREAM_ENCODING_RAW) {
+               // Just add the data itself.
+               iovec iov;
+               iov.iov_base = new char[bytes];
+               memcpy(iov.iov_base, data, bytes);
+               iov.iov_len = bytes;
+
                queued_data.push_back(iov);
        } else {
                assert(encoding == Stream::STREAM_ENCODING_RAW);
        }
-
-       // Add the data itself.
-       iovec iov;
-       iov.iov_base = new char[bytes];
-       memcpy(iov.iov_base, data, bytes);
-       iov.iov_len = bytes;
-       queued_data.push_back(iov);
 }
 
 void Stream::process_queued_data()