+size_t wxDataObject::GetBufferOffset(const wxDataFormat& format )
+{
+ // if we prepend the size of the data to the buffer itself, account for it
+ return NeedsVerbatimData(format) ? 0 : sizeof(size_t);
+}
+
+const void* wxDataObject::GetSizeFromBuffer( const void* buffer, size_t* size,
+ const wxDataFormat& format )
+{
+ size_t realsz = ::HeapSize(::GetProcessHeap(), 0, buffer);
+ if ( realsz == (size_t)-1 )
+ {
+ // note that HeapSize() does not set last error
+ wxLogApiError(wxT("HeapSize"), 0);
+ return NULL;
+ }
+
+ *size = realsz;
+
+ // check if this data has its size prepended (as it was by default for wx
+ // programs prior 2.6.3):
+ size_t *p = (size_t *)buffer;
+ if ( *p == realsz )
+ {
+ if ( NeedsVerbatimData(format) )
+ wxLogDebug(wxT("Apparent data format mismatch: size not needed"));
+
+ p++; // this data has its size prepended; skip first DWORD
+ }
+
+ return p;
+}
+
+void* wxDataObject::SetSizeInBuffer( void* buffer, size_t size,
+ const wxDataFormat& format )
+{
+ size_t* p = (size_t *)buffer;
+ if ( !NeedsVerbatimData(format) )
+ {
+ // prepend the size to the data and skip it
+ *p++ = size;
+ }
+
+ return p;
+}
+