cmData.h/c : Changed cmDataRecdAllocXXX() to return a cmDtRC_t.

This commit is contained in:
kpl 2013-12-03 13:48:31 -08:00
parent 86f64739e4
commit d92465cb37
2 changed files with 33 additions and 17 deletions

View File

@ -2146,46 +2146,60 @@ cmDtRC_t _cmDataRecdParseInputV(cmData_t* parent, cmErr_t* err, cmRC_t errRC, u
return rc;
}
cmData_t* cmDataRecdAllocLabelV( cmData_t* parent, cmErr_t* err, cmRC_t errRC, va_list vl )
cmDtRC_t cmDataRecdAllocLabelV( cmData_t* parent, cmErr_t* err, cmRC_t errRC, cmData_t** ref, va_list vl )
{
cmData_t* p = cmDataRecdAlloc(parent);
if( ref != NULL )
*ref = NULL;
cmDtRC_t rc = _cmDataRecdParseInputV(p, err, errRC, false, vl );
if( rc != kOkDtRC )
{
cmDataFree(p);
p = NULL;
}
return p;
if( ref != NULL )
*ref = p;
return rc;
}
cmData_t* cmDataRecdAllocLabelA( cmData_t* parent, cmErr_t* err, cmRC_t errRC, ... )
cmDtRC_t cmDataRecdAllocLabelA( cmData_t* parent, cmErr_t* err, cmRC_t errRC, cmData_t** ref, ... )
{
va_list vl;
va_start(vl,errRC);
cmData_t* p = cmDataRecdAllocLabelV(parent,err,errRC,vl);
va_start(vl,ref);
cmDtRC_t rc = cmDataRecdAllocLabelV(parent,err,errRC,ref,vl);
va_end(vl);
return p;
return rc;
}
cmData_t* cmDataRecdAllocIdV( cmData_t* parent, cmErr_t* err, cmRC_t errRC, va_list vl )
cmDtRC_t cmDataRecdAllocIdV( cmData_t* parent, cmErr_t* err, cmRC_t errRC, cmData_t** ref, va_list vl )
{
cmData_t* p = cmDataRecdAlloc(parent);
if( ref != NULL )
*ref = NULL;
cmDtRC_t rc = _cmDataRecdParseInputV(p, err, errRC, true, vl );
if( rc != kOkDtRC )
{
cmDataFree(p);
p = NULL;
}
return p;
if( ref != NULL )
*ref = p;
return rc;
}
cmData_t* cmDataRecdAllocIdA( cmData_t* parent, cmErr_t* err, cmRC_t errRC, ... )
cmDtRC_t cmDataRecdAllocIdA( cmData_t* parent, cmErr_t* err, cmRC_t errRC, cmData_t** ref, ... )
{
va_list vl;
va_start(vl,errRC);
cmData_t* p = cmDataRecdAllocIdV(parent,err,errRC,vl);
va_start(vl,ref);
cmRC_t rc = cmDataRecdAllocIdV(parent,err,errRC,ref,vl);
va_end(vl);
return p;
return rc;
}
cmDtRC_t _cmDataRecdParseErrV( cmErr_t* err, unsigned rc, unsigned id, const cmChar_t* label, const cmChar_t* fmt, va_list vl )
@ -3348,7 +3362,9 @@ void cmDataTest( cmCtx_t* ctx )
if( cmDataParserTest(ctx) != kOkDtRC )
return;
cmData_t* d0 = cmDataRecdAllocLabelA(NULL,&ctx->err,0,
cmData_t* d0 = NULL;
cmDataRecdAllocLabelA(NULL,&ctx->err,0,&d0,
"name", kStrDtId,"This is a string.",
"id", kUIntDtId, 21,
"real",kFloatDtId, 1.23,

View File

@ -631,11 +631,11 @@ extern "C" {
// call.
// 3) The cmDataRecdAllocLabelV() arg. list should be terminated with NULL.
// The cmDataRecdAllocIdV() arg. list should be terminated with 'kInvalidDtId'.
cmData_t* cmDataRecdAllocLabelV( cmData_t* parent, cmErr_t* err, cmRC_t errRC, va_list vl );
cmData_t* cmDataRecdAllocLabelA( cmData_t* parent, cmErr_t* err, cmRC_t errRC, ... );
cmDtRC_t cmDataRecdAllocLabelV( cmData_t* parent, cmErr_t* err, cmRC_t errRC, cmData_t** ref, va_list vl );
cmDtRC_t cmDataRecdAllocLabelA( cmData_t* parent, cmErr_t* err, cmRC_t errRC, cmData_t** ref, ... );
cmData_t* cmDataRecdAllocIdV( cmData_t* parent, cmErr_t* err, cmRC_t errRC, va_list vl );
cmData_t* cmDataRecdAllocIdA( cmData_t* parent, cmErr_t* err, cmRC_t errRC, ... );
cmDtRC_t cmDataRecdAllocIdV( cmData_t* parent, cmErr_t* err, cmRC_t errRC, cmData_t** ref, va_list vl );
cmDtRC_t cmDataRecdAllocIdA( cmData_t* parent, cmErr_t* err, cmRC_t errRC, cmData_t** ref, ... );
// Extract the data in a record to C variables.
// Var-args format: