Browse Source

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

master
kpl 11 years ago
parent
commit
d92465cb37
2 changed files with 33 additions and 17 deletions
  1. 29
    13
      cmData.c
  2. 4
    4
      cmData.h

+ 29
- 13
cmData.c View File

2146
   return rc;
2146
   return rc;
2147
 }
2147
 }
2148
 
2148
 
2149
-cmData_t*       cmDataRecdAllocLabelV( cmData_t* parent, cmErr_t* err, cmRC_t errRC, va_list vl )
2149
+cmDtRC_t cmDataRecdAllocLabelV( cmData_t* parent, cmErr_t* err, cmRC_t errRC, cmData_t** ref, va_list vl )
2150
 {
2150
 {
2151
   cmData_t* p = cmDataRecdAlloc(parent);
2151
   cmData_t* p = cmDataRecdAlloc(parent);
2152
+  if( ref != NULL )
2153
+    *ref = NULL;
2154
+
2152
   cmDtRC_t rc = _cmDataRecdParseInputV(p, err, errRC, false, vl );
2155
   cmDtRC_t rc = _cmDataRecdParseInputV(p, err, errRC, false, vl );
2153
   if( rc != kOkDtRC )
2156
   if( rc != kOkDtRC )
2154
   {
2157
   {
2155
     cmDataFree(p);
2158
     cmDataFree(p);
2156
     p = NULL;
2159
     p = NULL;
2157
   }
2160
   }
2158
-  return p;
2161
+
2162
+  if( ref != NULL )
2163
+    *ref = p;
2164
+
2165
+  return rc;
2159
 }
2166
 }
2160
 
2167
 
2161
-cmData_t*       cmDataRecdAllocLabelA( cmData_t* parent, cmErr_t* err, cmRC_t errRC, ... )
2168
+cmDtRC_t cmDataRecdAllocLabelA( cmData_t* parent, cmErr_t* err, cmRC_t errRC, cmData_t** ref, ... )
2162
 {
2169
 {
2163
   va_list vl;
2170
   va_list vl;
2164
-  va_start(vl,errRC);
2165
-  cmData_t* p = cmDataRecdAllocLabelV(parent,err,errRC,vl);
2171
+  va_start(vl,ref);
2172
+  cmDtRC_t rc = cmDataRecdAllocLabelV(parent,err,errRC,ref,vl);
2166
   va_end(vl);
2173
   va_end(vl);
2167
-  return p;
2174
+  return rc;
2168
 }
2175
 }
2169
 
2176
 
2170
-cmData_t*       cmDataRecdAllocIdV( cmData_t* parent, cmErr_t* err, cmRC_t errRC, va_list vl )
2177
+cmDtRC_t cmDataRecdAllocIdV( cmData_t* parent, cmErr_t* err, cmRC_t errRC, cmData_t** ref, va_list vl )
2171
 {
2178
 {
2172
   cmData_t* p = cmDataRecdAlloc(parent);
2179
   cmData_t* p = cmDataRecdAlloc(parent);
2180
+  if( ref != NULL )
2181
+    *ref = NULL;
2182
+
2173
   cmDtRC_t rc = _cmDataRecdParseInputV(p, err, errRC, true, vl );
2183
   cmDtRC_t rc = _cmDataRecdParseInputV(p, err, errRC, true, vl );
2174
   if( rc != kOkDtRC )
2184
   if( rc != kOkDtRC )
2175
   {
2185
   {
2176
     cmDataFree(p);
2186
     cmDataFree(p);
2177
     p = NULL;
2187
     p = NULL;
2178
   }
2188
   }
2179
-  return p;
2189
+
2190
+  if( ref != NULL )
2191
+    *ref = p;
2192
+
2193
+  return rc;
2180
 }
2194
 }
2181
 
2195
 
2182
-cmData_t*       cmDataRecdAllocIdA( cmData_t* parent, cmErr_t* err, cmRC_t errRC, ... )
2196
+cmDtRC_t cmDataRecdAllocIdA( cmData_t* parent, cmErr_t* err, cmRC_t errRC, cmData_t** ref, ... )
2183
 {
2197
 {
2184
   va_list vl;
2198
   va_list vl;
2185
-  va_start(vl,errRC);
2186
-  cmData_t* p = cmDataRecdAllocIdV(parent,err,errRC,vl);
2199
+  va_start(vl,ref);
2200
+  cmRC_t rc = cmDataRecdAllocIdV(parent,err,errRC,ref,vl);
2187
   va_end(vl);
2201
   va_end(vl);
2188
-  return p;
2202
+  return rc;
2189
 }
2203
 }
2190
 
2204
 
2191
 cmDtRC_t _cmDataRecdParseErrV( cmErr_t* err, unsigned rc, unsigned id, const cmChar_t* label, const cmChar_t* fmt, va_list vl )
2205
 cmDtRC_t _cmDataRecdParseErrV( cmErr_t* err, unsigned rc, unsigned id, const cmChar_t* label, const cmChar_t* fmt, va_list vl )
3348
   if( cmDataParserTest(ctx) != kOkDtRC )
3362
   if( cmDataParserTest(ctx) != kOkDtRC )
3349
     return;
3363
     return;
3350
 
3364
 
3351
-  cmData_t* d0 = cmDataRecdAllocLabelA(NULL,&ctx->err,0,
3365
+  cmData_t* d0 = NULL;
3366
+
3367
+  cmDataRecdAllocLabelA(NULL,&ctx->err,0,&d0,
3352
     "name", kStrDtId,"This is a string.",
3368
     "name", kStrDtId,"This is a string.",
3353
     "id",  kUIntDtId,    21,
3369
     "id",  kUIntDtId,    21,
3354
     "real",kFloatDtId, 1.23,
3370
     "real",kFloatDtId, 1.23,

+ 4
- 4
cmData.h View File

631
   //    call.
631
   //    call.
632
   // 3) The cmDataRecdAllocLabelV() arg. list should be terminated with NULL.
632
   // 3) The cmDataRecdAllocLabelV() arg. list should be terminated with NULL.
633
   //    The cmDataRecdAllocIdV() arg. list should be terminated with 'kInvalidDtId'.
633
   //    The cmDataRecdAllocIdV() arg. list should be terminated with 'kInvalidDtId'.
634
-  cmData_t*       cmDataRecdAllocLabelV( cmData_t* parent, cmErr_t* err, cmRC_t errRC, va_list vl );
635
-  cmData_t*       cmDataRecdAllocLabelA( cmData_t* parent, cmErr_t* err, cmRC_t errRC, ... );
634
+  cmDtRC_t cmDataRecdAllocLabelV( cmData_t* parent, cmErr_t* err, cmRC_t errRC, cmData_t** ref, va_list vl );
635
+  cmDtRC_t cmDataRecdAllocLabelA( cmData_t* parent, cmErr_t* err, cmRC_t errRC, cmData_t** ref, ... );
636
 
636
 
637
-  cmData_t*       cmDataRecdAllocIdV( cmData_t* parent, cmErr_t* err, cmRC_t errRC, va_list vl );
638
-  cmData_t*       cmDataRecdAllocIdA( cmData_t* parent, cmErr_t* err, cmRC_t errRC, ... );
637
+  cmDtRC_t cmDataRecdAllocIdV( cmData_t* parent, cmErr_t* err, cmRC_t errRC, cmData_t** ref, va_list vl );
638
+  cmDtRC_t cmDataRecdAllocIdA( cmData_t* parent, cmErr_t* err, cmRC_t errRC, cmData_t** ref, ... );
639
   
639
   
640
   // Extract the data in a record to C variables.
640
   // Extract the data in a record to C variables.
641
   // Var-args format:
641
   // Var-args format:

Loading…
Cancel
Save