You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by gs...@apache.org on 2008/03/31 20:01:33 UTC

svn commit: r643086 - /incubator/qpid/trunk/qpid/cpp/src/qpid/framing/Array.cpp

Author: gsim
Date: Mon Mar 31 11:01:31 2008
New Revision: 643086

URL: http://svn.apache.org/viewvc?rev=643086&view=rev
Log:
Allow zero sized arrays (with no typecode or count)


Modified:
    incubator/qpid/trunk/qpid/cpp/src/qpid/framing/Array.cpp

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/framing/Array.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/framing/Array.cpp?rev=643086&r1=643085&r2=643086&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/framing/Array.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/framing/Array.cpp Mon Mar 31 11:01:31 2008
@@ -80,24 +80,26 @@
         throw SyntaxErrorException(QPID_MSG("Not enough data for array, expected " 
                                             << size << " bytes but only " << available << " available"));
     }
-    typeOctet = buffer.getOctet();
-    uint32_t count = buffer.getLong();
-
-    FieldValue dummy;
-    dummy.setType(typeOctet);
-    available = buffer.available();
-    if (available < count * dummy.getData().size()) {
-        throw SyntaxErrorException(QPID_MSG("Not enough data for array, expected " 
-                                            << count << " items of " << dummy.getData().size()
-                                            << " bytes each  but only " << available << " bytes available"));
+    if (size) {
+        typeOctet = buffer.getOctet();
+        uint32_t count = buffer.getLong();
+        
+        FieldValue dummy;
+        dummy.setType(typeOctet);
+        available = buffer.available();
+        if (available < count * dummy.getData().size()) {
+            throw SyntaxErrorException(QPID_MSG("Not enough data for array, expected " 
+                                                << count << " items of " << dummy.getData().size()
+                                                << " bytes each  but only " << available << " bytes available"));
+        }
+        
+        for (uint32_t i = 0; i < count; i++) {
+            ValuePtr value(new FieldValue);
+            value->setType(typeOctet);
+            value->getData().decode(buffer);
+            values.push_back(ValuePtr(value));
+        }    
     }
-
-    for (uint32_t i = 0; i < count; i++) {
-        ValuePtr value(new FieldValue);
-        value->setType(typeOctet);
-        value->getData().decode(buffer);
-        values.push_back(ValuePtr(value));
-    }    
 }