Skip to content

Commit 99fa6bf

Browse files
authored
Merge pull request #551 from ronpandolfi/master
Avoid unnecessary indirection in xml2 usage
2 parents 661c508 + ffbdbe5 commit 99fa6bf

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

ADApp/pluginSrc/NDFileHDF5LayoutXML.cpp

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ namespace hdf5
346346
attr_src = xmlTextReaderGetAttribute(this->xmlreader, (const xmlChar*)LayoutXML::ATTR_SOURCE.c_str());
347347
if (attr_src == NULL) return ret;
348348
str_attr_src = (char*)attr_src;
349-
xmlGetGlobalState()->xmlFree(attr_src);
349+
xmlFree(attr_src);
350350

351351
if (str_attr_src == LayoutXML::ATTR_SRC_DETECTOR){
352352
out = DataSource( detector );
@@ -374,7 +374,7 @@ namespace hdf5
374374
attr_src = xmlTextReaderGetAttribute(this->xmlreader, (const xmlChar*)LayoutXML::ATTR_SOURCE.c_str());
375375
if (attr_src == NULL) return ret;
376376
str_attr_src = (char*)attr_src;
377-
xmlGetGlobalState()->xmlFree(attr_src);
377+
xmlFree(attr_src);
378378

379379
std::string str_attr_val = "";
380380
xmlChar *attr_val = NULL;
@@ -389,14 +389,14 @@ namespace hdf5
389389
attr_val = xmlTextReaderGetAttribute(this->xmlreader, (const xmlChar*)LayoutXML::ATTR_SRC_NDATTR.c_str());
390390
if (attr_val != NULL) {
391391
str_attr_val = (char*)attr_val;
392-
xmlGetGlobalState()->xmlFree(attr_val);
392+
xmlFree(attr_val);
393393
}
394394
out.source = DataSource( ndattribute, str_attr_val );
395395
// Check for a when="OnFileClose" or when="OnFileOpen" tag
396396
attr_when = xmlTextReaderGetAttribute(this->xmlreader, (const xmlChar*)LayoutXML::ATTR_SRC_WHEN.c_str());
397397
if (attr_when != NULL) {
398398
str_attr_when = (char*)attr_when;
399-
xmlGetGlobalState()->xmlFree(attr_when);
399+
xmlFree(attr_when);
400400
}
401401
if (str_attr_when == "OnFileOpen"){
402402
out.source.set_when_to_save(OnFileOpen);
@@ -414,13 +414,13 @@ namespace hdf5
414414
attr_val = xmlTextReaderGetAttribute(this->xmlreader, (const xmlChar*)LayoutXML::ATTR_SRC_CONST_VALUE.c_str());
415415
if (attr_val != NULL) {
416416
str_attr_val = (char*)attr_val;
417-
xmlGetGlobalState()->xmlFree(attr_val);
417+
xmlFree(attr_val);
418418
}
419419
out.source = DataSource( constant, str_attr_val );
420420
attr_type = xmlTextReaderGetAttribute(this->xmlreader, (const xmlChar*)LayoutXML::ATTR_SRC_CONST_TYPE.c_str());
421421
if (attr_type != NULL) {
422422
str_attr_type = (char*)attr_type;
423-
xmlGetGlobalState()->xmlFree(attr_type);
423+
xmlFree(attr_type);
424424
DataType_t dtype = string;
425425
if (str_attr_type == "int") dtype = int32;
426426
else if (str_attr_type == "float") dtype = float64;
@@ -446,7 +446,7 @@ namespace hdf5
446446

447447
// Get the standard string representation of the tag
448448
std::string str_root_auto((char*)root_auto);
449-
xmlGetGlobalState()->xmlFree(root_auto);
449+
xmlFree(root_auto);
450450

451451
// Now check if we have the correct string
452452
if (str_root_auto == "false"){
@@ -472,7 +472,7 @@ namespace hdf5
472472
if (group_name == NULL) return -1;
473473

474474
std::string str_group_name((const char*)group_name);
475-
xmlGetGlobalState()->xmlFree(group_name);
475+
xmlFree(group_name);
476476

477477
// Initialise the tree if it has not already been done.
478478
if (this->ptr_tree == NULL){
@@ -495,7 +495,7 @@ namespace hdf5
495495
ndattr_default = xmlTextReaderGetAttribute(this->xmlreader, (const xmlChar *)LayoutXML::ATTR_GRP_NDATTR_DEFAULT.c_str());
496496
if (ndattr_default != NULL){
497497
std::string str_ndattr_default((char*)ndattr_default);
498-
xmlGetGlobalState()->xmlFree(ndattr_default);
498+
xmlFree(ndattr_default);
499499
// if the group has tag: ndattr_default="true" (true in lower case)
500500
// then set the group as the default container for NDAttributes.
501501
if (str_ndattr_default == "true"){
@@ -524,7 +524,7 @@ namespace hdf5
524524
if (dset_name == NULL) return -1;
525525

526526
std::string str_dset_name((char*)dset_name);
527-
xmlGetGlobalState()->xmlFree(dset_name);
527+
xmlFree(dset_name);
528528
Group *parent = (Group *)this->ptr_curr_element;
529529
Dataset *dset = NULL;
530530
dset = parent->new_dset(str_dset_name);
@@ -537,7 +537,7 @@ namespace hdf5
537537
attr_def = xmlTextReaderGetAttribute(this->xmlreader, (const xmlChar*)LayoutXML::ATTR_SRC_DET_DEFAULT.c_str());
538538
if (attr_def != NULL){
539539
str_attr_def = (char*)attr_def;
540-
xmlGetGlobalState()->xmlFree(attr_def);
540+
xmlFree(attr_def);
541541
if (str_attr_def == "true"){
542542
detector_default = true;
543543
}
@@ -556,14 +556,14 @@ namespace hdf5
556556
attr_ndname = xmlTextReaderGetAttribute(this->xmlreader, (const xmlChar*)LayoutXML::ATTR_SRC_NDATTR.c_str());
557557
if (attr_ndname != NULL){
558558
str_attr_ndname = (char*)attr_ndname;
559-
xmlGetGlobalState()->xmlFree(attr_ndname);
559+
xmlFree(attr_ndname);
560560
dset->set_ndattr_name(str_attr_ndname);
561561
//if ndattribute, check for 'when' tag
562562
xmlChar *attr_when = NULL;
563563
attr_when = xmlTextReaderGetAttribute(this->xmlreader, (const xmlChar*)LayoutXML::ATTR_SRC_WHEN.c_str());
564564
if (attr_when != NULL){
565565
std::string str_attr_when( (char*)attr_when );
566-
xmlGetGlobalState()->xmlFree(attr_when);
566+
xmlFree(attr_when);
567567
When_t when_to_save = OnFrame; //Default is to save every frame
568568
if (str_attr_when == "OnFileOpen"){
569569
when_to_save = OnFileOpen;
@@ -578,12 +578,12 @@ namespace hdf5
578578
c_val = xmlTextReaderGetAttribute(this->xmlreader, (const xmlChar*)LayoutXML::ATTR_SRC_CONST_VALUE.c_str());
579579
if (c_val != NULL) {
580580
str_val = (char*)c_val;
581-
xmlGetGlobalState()->xmlFree(c_val);
581+
xmlFree(c_val);
582582
}
583583
c_type = xmlTextReaderGetAttribute(this->xmlreader, (const xmlChar*)LayoutXML::ATTR_SRC_CONST_TYPE.c_str());
584584
if (c_type != NULL){
585585
str_type = (char*)c_type;
586-
xmlGetGlobalState()->xmlFree(c_type);
586+
xmlFree(c_type);
587587
DataType_t dtype = string;
588588
if (str_type == "int") dtype = int32;
589589
else if (str_type == "float") dtype = float64;
@@ -608,7 +608,7 @@ namespace hdf5
608608
if (ndattr_name == NULL) return -1;
609609

610610
std::string str_ndattr_name((char*)ndattr_name);
611-
xmlGetGlobalState()->xmlFree(ndattr_name);
611+
xmlFree(ndattr_name);
612612
Attribute ndattr(str_ndattr_name);
613613
this->process_attribute_xml_attribute(ndattr);
614614

@@ -625,12 +625,12 @@ namespace hdf5
625625
global_name = xmlTextReaderGetAttribute(this->xmlreader, (const xmlChar*)LayoutXML::ATTR_GLOBAL_NAME.c_str());
626626
if (global_name == NULL) return -1;
627627
std::string str_global_name((char*)global_name);
628-
xmlGetGlobalState()->xmlFree(global_name);
628+
xmlFree(global_name);
629629
xmlChar *global_value = NULL;
630630
global_value = xmlTextReaderGetAttribute(this->xmlreader, (const xmlChar*)LayoutXML::ATTR_GLOBAL_VALUE.c_str());
631631
if (global_value == NULL) return -1;
632632
std::string str_global_value((char*)global_value);
633-
xmlGetGlobalState()->xmlFree(global_value);
633+
xmlFree(global_value);
634634

635635
this->globals[str_global_name] = str_global_value;
636636
return ret;
@@ -644,12 +644,12 @@ namespace hdf5
644644
hardlink_name = xmlTextReaderGetAttribute(this->xmlreader, (const xmlChar*)LayoutXML::ATTR_ELEMENT_NAME.c_str());
645645
if (hardlink_name == NULL) return -1;
646646
std::string str_hardlink_name((char*)hardlink_name);
647-
xmlGetGlobalState()->xmlFree(hardlink_name);
647+
xmlFree(hardlink_name);
648648
xmlChar *hardlink_target = NULL;
649649
hardlink_target = xmlTextReaderGetAttribute(this->xmlreader, (const xmlChar*)LayoutXML::ATTR_HARDLINK_TARGET.c_str());
650650
if (hardlink_target == NULL) return -1;
651651
const std::string str_hardlink_target((char*)hardlink_target);
652-
xmlGetGlobalState()->xmlFree(hardlink_target);
652+
xmlFree(hardlink_target);
653653
Group *parent = (Group *)this->ptr_curr_element;
654654
HardLink *hardlink = NULL;
655655
hardlink = parent->new_hardlink(str_hardlink_name);

0 commit comments

Comments
 (0)