Browse Source

cmPrefs.c/h Added use of kMaxVarPrId

master
kpl 11 years ago
parent
commit
fc08764718
2 changed files with 14 additions and 1 deletions
  1. 6
    0
      cmPrefs.c
  2. 8
    1
      cmPrefs.h

+ 6
- 0
cmPrefs.c View File

@@ -305,6 +305,8 @@ cmPrRC_t cmPrefsInitialize( cmPrH_t* hp, const cmChar_t* fn, cmPrefsOnChangeFunc
305 305
   p->fn = cmLHeapAllocZ( p->lhH, strlen(fn)+1 );
306 306
   strcpy(p->fn,fn);
307 307
 
308
+  p->id = kMaxVarPrId;
309
+
308 310
   hp->h = p;
309 311
 
310 312
  errLabel:
@@ -1169,6 +1171,10 @@ cmPrRC_t  _cmPrefsCreateJsonNode(
1169 1171
   int             i;
1170 1172
 
1171 1173
   assert( pathCnt >= 1 );
1174
+
1175
+  if( id != cmInvalidId && id >= kMaxVarPrId )
1176
+    return cmErrMsg(&p->err,kNodeCreateFailPrRC,"User supplied id's must be less than 0x%x.",kMaxVarPrId);
1177
+
1172 1178
   
1173 1179
   // for each path element
1174 1180
   for(i=0; i<pathCnt; ++i)

+ 8
- 1
cmPrefs.h View File

@@ -24,6 +24,12 @@ extern "C" {
24 24
     kDuplicateIdPrRC
25 25
   };
26 26
 
27
+  enum
28
+  {
29
+    kMaxVarPrId = 0x7fffffff // User assigned variable id's given to cmPrefsCreateXXX()
30
+                             // must be less than kMaxVarPrId
31
+  };
32
+
27 33
   typedef void (*cmPrefsOnChangeFunc_t)( cmPrH_t h, void* cbDataPtr, unsigned id ); 
28 34
 
29 35
   extern cmPrH_t cmPrNullHandle;
@@ -139,7 +145,8 @@ extern "C" {
139 145
   // The 'id' argument is optional.  If 'id' is set to cmInvalidId then the
140 146
   // variable will be automatically assigned an id.  The value of the
141 147
   // automatically assigned id can be found from the path string
142
-  // via cmPrefsId()
148
+  // via cmPrefsId().  If 'id' is not set to cmInvalidId then it must be less than 
149
+  // kMaxVarId.
143 150
 
144 151
   // Set kForceValuePrFl 
145 152
   enum { kForceValuePrFl=0x01 };

Loading…
Cancel
Save