Procházet zdrojové kódy

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

master
kpl před 11 roky
rodič
revize
d92465cb37
2 změnil soubory, kde provedl 33 přidání a 17 odebrání
  1. 29
    13
      cmData.c
  2. 4
    4
      cmData.h

+ 29
- 13
cmData.c Zobrazit soubor

@@ -2146,46 +2146,60 @@ cmDtRC_t  _cmDataRecdParseInputV(cmData_t* parent, cmErr_t* err, cmRC_t errRC, u
2146 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 2151
   cmData_t* p = cmDataRecdAlloc(parent);
2152
+  if( ref != NULL )
2153
+    *ref = NULL;
2154
+
2152 2155
   cmDtRC_t rc = _cmDataRecdParseInputV(p, err, errRC, false, vl );
2153 2156
   if( rc != kOkDtRC )
2154 2157
   {
2155 2158
     cmDataFree(p);
2156 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 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 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 2179
   cmData_t* p = cmDataRecdAlloc(parent);
2180
+  if( ref != NULL )
2181
+    *ref = NULL;
2182
+
2173 2183
   cmDtRC_t rc = _cmDataRecdParseInputV(p, err, errRC, true, vl );
2174 2184
   if( rc != kOkDtRC )
2175 2185
   {
2176 2186
     cmDataFree(p);
2177 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 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 2201
   va_end(vl);
2188
-  return p;
2202
+  return rc;
2189 2203
 }
2190 2204
 
2191 2205
 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 )
3348 3362
   if( cmDataParserTest(ctx) != kOkDtRC )
3349 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 3368
     "name", kStrDtId,"This is a string.",
3353 3369
     "id",  kUIntDtId,    21,
3354 3370
     "real",kFloatDtId, 1.23,

+ 4
- 4
cmData.h Zobrazit soubor

@@ -631,11 +631,11 @@ extern "C" {
631 631
   //    call.
632 632
   // 3) The cmDataRecdAllocLabelV() arg. list should be terminated with NULL.
633 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 640
   // Extract the data in a record to C variables.
641 641
   // Var-args format:

Načítá se…
Zrušit
Uložit