From 0debd730a686199fb3017d87097b371876be4c0a Mon Sep 17 00:00:00 2001 From: kevin Date: Tue, 5 Nov 2013 14:37:38 -0800 Subject: [PATCH] cmData.c : Initial implementation of cmDataSerialize(). --- cmData.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/cmData.c b/cmData.c index b5725d0..8abb797 100644 --- a/cmData.c +++ b/cmData.c @@ -2161,10 +2161,28 @@ char* _cmDataSerializeWrite( cmData_t* np, char* dp, const char* ep ) return dp; } +char* _cmDataSerialize( const cmData_t* p, char* buf, const char* ep ) +{ + + buf = _cmDataSerializeWrite(p,buf,ep); + + // if this data type has a child then write the child + if( kMinStructDtId <= p->tid && p->tid <= kMaxStructDtId && p->u.child != NULL ) + buf = _cmDataSerialize(p->u.child,buf,ep); + + // if this data type has siblings then write sibings + cmData_t* dp = p->u.child; + for(; dp != NULL; dp=dp->sibling ) + buf = cmDataSerialize(dp->sibling,buf,ep); + + return buf; +} + cmDtRC_t cmDataSerialize( const cmData_t* p, void* buf, unsigned bufByteCnt ) { - - + const char* ep = (char*)p + bufByteCnt; + buf = _cmDataSerialize(p,buf,bufByteCnt); + assert( buf <= ep ); return kOkDtRC; }