Browse Source

cmData.c : Initial implementation of cmDataSerialize().

master
kevin 11 years ago
parent
commit
0debd730a6
1 changed files with 19 additions and 1 deletions
  1. 19
    1
      cmData.c

+ 19
- 1
cmData.c View File

2161
   return dp;
2161
   return dp;
2162
 }
2162
 }
2163
 
2163
 
2164
-cmDtRC_t cmDataSerialize( const cmData_t* p, void* buf, unsigned bufByteCnt )
2164
+char* _cmDataSerialize( const cmData_t* p, char* buf, const char* ep )
2165
 {
2165
 {
2166
+
2167
+  buf = _cmDataSerializeWrite(p,buf,ep);
2168
+
2169
+  // if this data type has a child then write the child
2170
+  if( kMinStructDtId <= p->tid && p->tid <= kMaxStructDtId && p->u.child != NULL )
2171
+    buf = _cmDataSerialize(p->u.child,buf,ep);
2166
   
2172
   
2173
+  // if this data type has siblings then write sibings
2174
+  cmData_t* dp = p->u.child;
2175
+  for(; dp != NULL; dp=dp->sibling )
2176
+    buf = cmDataSerialize(dp->sibling,buf,ep);
2177
+
2178
+  return buf;
2179
+}
2167
 
2180
 
2181
+cmDtRC_t cmDataSerialize( const cmData_t* p, void* buf, unsigned bufByteCnt )
2182
+{
2183
+  const char* ep = (char*)p + bufByteCnt;
2184
+  buf = _cmDataSerialize(p,buf,bufByteCnt);
2185
+  assert( buf <= ep );
2168
   return kOkDtRC;
2186
   return kOkDtRC;
2169
 }
2187
 }
2170
 
2188
 

Loading…
Cancel
Save