@@ -251,14 +251,8 @@ CFE_Status_t CFE_TBL_Share(CFE_TBL_Handle_t *TblHandlePtr, const char *TblName)
251
251
AccessDescPtr -> RegIndex = CFE_TBL_TxnRegId (& Txn );
252
252
AccessDescPtr -> UsedFlag = true;
253
253
254
- AccessDescPtr -> PrevLink = CFE_TBL_END_OF_LIST ; /* We are the new head of the list */
255
- AccessDescPtr -> NextLink = RegRecPtr -> HeadOfAccessList ;
256
-
257
- /* Make sure the old head of the list now sees this as the head */
258
- CFE_TBL_Global .Handles [RegRecPtr -> HeadOfAccessList ].PrevLink = CFE_TBL_TxnHandle (& Txn );
259
-
260
- /* Make sure the Registry Record see this as the head of the list */
261
- RegRecPtr -> HeadOfAccessList = CFE_TBL_TxnHandle (& Txn );
254
+ CFE_TBL_HandleLinkInit (& AccessDescPtr -> Link );
255
+ CFE_TBL_HandleListInsertLink (RegRecPtr , AccessDescPtr );
262
256
}
263
257
264
258
CFE_TBL_TxnFinish (& Txn );
@@ -647,7 +641,7 @@ CFE_Status_t CFE_TBL_Update(CFE_TBL_Handle_t TblHandle)
647
641
/*
648
642
* Note that (Status < 0) specifically matches ERROR, not WARNING codes. The CFE_TBL_UpdateInternal() function
649
643
* currently only produces two possible codes (aside from CFE_SUCCESS) and both of these are defined as
650
- * warnings, not errors. Therefore, its impossible to reach this code with RegRegPtr != NULL.
644
+ * warnings, not errors. Therefore, its impossible to reach this code with RegRecPtr != NULL.
651
645
*/
652
646
CFE_EVS_SendEventWithAppID (CFE_TBL_UPDATE_ERR_EID , CFE_EVS_EventType_ERROR , CFE_TBL_Global .TableTaskAppId ,
653
647
"%s Failed to update table, Status=0x%08X" , AppName , (unsigned int )Status );
@@ -1088,7 +1082,6 @@ CFE_Status_t CFE_TBL_GetInfo(CFE_TBL_Info_t *TblInfoPtr, const char *TblName)
1088
1082
int32 Status = CFE_SUCCESS ;
1089
1083
int32 NumAccessDescriptors = 0 ;
1090
1084
CFE_TBL_RegistryRec_t * RegRecPtr ;
1091
- CFE_TBL_Handle_t HandleIterator ;
1092
1085
1093
1086
if (TblInfoPtr == NULL || TblName == NULL )
1094
1087
{
@@ -1117,13 +1110,7 @@ CFE_Status_t CFE_TBL_GetInfo(CFE_TBL_Info_t *TblInfoPtr, const char *TblName)
1117
1110
strncpy (TblInfoPtr -> LastFileLoaded , RegRecPtr -> LastFileLoaded , sizeof (TblInfoPtr -> LastFileLoaded ) - 1 );
1118
1111
TblInfoPtr -> LastFileLoaded [sizeof (TblInfoPtr -> LastFileLoaded ) - 1 ] = 0 ;
1119
1112
1120
- /* Count the number of Access Descriptors to determine the number of users */
1121
- HandleIterator = RegRecPtr -> HeadOfAccessList ;
1122
- while (HandleIterator != CFE_TBL_END_OF_LIST )
1123
- {
1124
- NumAccessDescriptors ++ ;
1125
- HandleIterator = CFE_TBL_Global .Handles [HandleIterator ].NextLink ;
1126
- }
1113
+ CFE_TBL_ForeachAccessDescriptor (RegRecPtr , CFE_TBL_CountAccessDescHelper , & NumAccessDescriptors );
1127
1114
1128
1115
TblInfoPtr -> NumUsers = NumAccessDescriptors ;
1129
1116
@@ -1190,6 +1177,23 @@ CFE_Status_t CFE_TBL_DumpToBuffer(CFE_TBL_Handle_t TblHandle)
1190
1177
return Status ;
1191
1178
}
1192
1179
1180
+ /*----------------------------------------------------------------
1181
+ *
1182
+ * Local helper function, not invoked outside this unit
1183
+ * Intended to be used with CFE_TBL_ForeachAccessDescriptor()
1184
+ *
1185
+ *-----------------------------------------------------------------*/
1186
+ static void CFE_TBL_NotifyOtherAppHelper (CFE_TBL_AccessDescriptor_t * AccessDescPtr , void * Arg )
1187
+ {
1188
+ CFE_TBL_TxnState_t * Txn = Arg ;
1189
+
1190
+ /* Only notify *OTHER* applications that the contents have changed */
1191
+ if (!CFE_RESOURCEID_TEST_EQUAL (AccessDescPtr -> AppId , CFE_TBL_TxnAppId (Txn )))
1192
+ {
1193
+ AccessDescPtr -> Updated = true;
1194
+ }
1195
+ }
1196
+
1193
1197
/*----------------------------------------------------------------
1194
1198
*
1195
1199
* Implemented per public API
@@ -1201,7 +1205,6 @@ CFE_Status_t CFE_TBL_Modified(CFE_TBL_Handle_t TblHandle)
1201
1205
CFE_TBL_TxnState_t Txn ;
1202
1206
int32 Status ;
1203
1207
CFE_TBL_RegistryRec_t * RegRecPtr = NULL ;
1204
- CFE_TBL_Handle_t AccessIterator ;
1205
1208
CFE_ES_AppId_t ThisAppId ;
1206
1209
size_t FilenameLen ;
1207
1210
@@ -1241,17 +1244,8 @@ CFE_Status_t CFE_TBL_Modified(CFE_TBL_Handle_t TblHandle)
1241
1244
strncpy (& RegRecPtr -> LastFileLoaded [sizeof (RegRecPtr -> LastFileLoaded ) - 4 ], "(*)" , 4 );
1242
1245
}
1243
1246
1244
- AccessIterator = RegRecPtr -> HeadOfAccessList ;
1245
- while (AccessIterator != CFE_TBL_END_OF_LIST )
1246
- {
1247
- /* Only notify *OTHER* applications that the contents have changed */
1248
- if (!CFE_RESOURCEID_TEST_EQUAL (CFE_TBL_Global .Handles [AccessIterator ].AppId , ThisAppId ))
1249
- {
1250
- CFE_TBL_Global .Handles [AccessIterator ].Updated = true;
1251
- }
1252
-
1253
- AccessIterator = CFE_TBL_Global .Handles [AccessIterator ].NextLink ;
1254
- }
1247
+ /* Only notify *OTHER* applications that the contents have changed */
1248
+ CFE_TBL_ForeachAccessDescriptor (RegRecPtr , CFE_TBL_NotifyOtherAppHelper , & Txn );
1255
1249
}
1256
1250
else
1257
1251
{
0 commit comments