File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -494,11 +494,9 @@ static ErrCode init(void* arg) {
494494 UrmSettings::metaConfigs.mPluginCount = (uint32_t )std::stol (resultBuffer);
495495
496496 uint32_t pluginCount = UrmSettings::metaConfigs.mPluginCount ;
497- if (pluginCount > MAX_EXTENSION_LIB_HANDLES ) {
498- extensionLibHandles = (void **) malloc (pluginCount * sizeof (void *));
499- if (extensionLibHandles == nullptr ) {
500- return RC_MODULE_INIT_FAILURE ;
501- }
497+ extensionLibHandles = (void **) calloc (pluginCount, sizeof (void *));
498+ if (extensionLibHandles == nullptr ) {
499+ return RC_MODULE_INIT_FAILURE ;
502500 }
503501
504502 if (RC_IS_NOTOK (fetchMetaConfigs ())) {
Original file line number Diff line number Diff line change @@ -173,7 +173,67 @@ static int8_t isKeyTypeList(const std::string& keyName) {
173173 return false ;
174174}
175175
176+ static int32_t onDeviceNodesCount (const std::string& filePath) {
177+ SETUP_LIBYAML_PARSING (filePath);
178+
179+ int8_t parsingDone = false ;
180+ int8_t docMarker = false ;
181+ int8_t parsingKey = false ;
182+ int32_t count = 0 ;
183+
184+ std::string value = " " ;
185+
186+ while (!parsingDone) {
187+ if (!yaml_parser_parse (&parser, &event)) {
188+ return RC_YAML_PARSING_ERROR ;
189+ }
190+
191+ switch (event.type ) {
192+ case YAML_STREAM_END_EVENT :
193+ parsingDone = true ;
194+ break ;
195+
196+ case YAML_MAPPING_START_EVENT :
197+ if (!docMarker) {
198+ docMarker = true ;
199+ }
200+ break ;
201+
202+ case YAML_SCALAR_EVENT :
203+ if (event.data .scalar .value != nullptr ) {
204+ value = reinterpret_cast <char *>(event.data .scalar .value );
205+ }
206+
207+ if (value == RESOURCE_CONFIGS_ELEM_RESOURCEPATH ) {
208+ parsingKey = true ;
209+ } else {
210+ if (parsingKey) {
211+ if (AuxRoutines::fileExists (value)) {
212+ count++;
213+ }
214+ }
215+ parsingKey = false ;
216+ }
217+
218+ break ;
219+
220+ default :
221+ break ;
222+ }
223+
224+ yaml_event_delete (&event);
225+ }
226+
227+ TEARDOWN_LIBYAML_PARSING
228+ return count;
229+ }
230+
176231ErrCode RestuneParser::parseResourceConfigYamlNode (const std::string& filePath) {
232+ if (onDeviceNodesCount (filePath) == 0 ) {
233+ // None of the nodes exsit, no need to parse these configs
234+ return RC_SUCCESS ;
235+ }
236+
177237 SETUP_LIBYAML_PARSING (filePath);
178238
179239 ErrCode rc = RC_SUCCESS ;
You can’t perform that action at this time.
0 commit comments