Skip to content

Commit

Permalink
Remove TBBT_INTERNALS scheme
Browse files Browse the repository at this point in the history
The TBBT code used a weird scheme where the main data structures
were defined differently in the header and source files in an
attempt to hide private details. This has been switched to use
a PIMPL scheme with properly hidden data instead.
  • Loading branch information
derobins committed Feb 14, 2024
1 parent 6ff01fb commit bd085c3
Show file tree
Hide file tree
Showing 7 changed files with 256 additions and 222 deletions.
2 changes: 1 addition & 1 deletion hdf/src/hdatainfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ GRgetattdatainfo(int32 id, int32 attrindex, int32 *offset, int32 *length)
HGOTO_ERROR(DFE_ARGS, FAIL);

/* Search for an attribute with the same index */
aentry = (void **)tbbtfirst((TBBT_NODE *)*search_tree);
aentry = (void **)tbbtfirst(search_tree->root);
found = FALSE;
while (!found && (aentry != NULL)) {
at_ptr = (at_info_t *)*aentry;
Expand Down
16 changes: 8 additions & 8 deletions hdf/src/mfan.c
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ ANInumann(int32 an_id, /* IN: annotation interface id */
}

/* Traverse the list looking for a match */
for (entry = tbbtfirst((TBBT_NODE *)*(file_rec->an_tree[type])); entry != NULL; entry = tbbtnext(entry)) {
for (entry = tbbtfirst(file_rec->an_tree[type]->root); entry != NULL; entry = tbbtnext(entry)) {
ann_entry = (ANentry *)entry->data; /* get annotation entry from node */
if ((ann_entry->elmref == elem_ref) && (ann_entry->elmtag == elem_tag)) {
nanns++; /* increment ref counter if match */
Expand Down Expand Up @@ -744,7 +744,7 @@ ANIannlist(int32 an_id, /* IN: annotation interface id */
}

/* Traverse the list looking for a match */
for (entry = tbbtfirst((TBBT_NODE *)*(file_rec->an_tree[type])); entry != NULL; entry = tbbtnext(entry)) {
for (entry = tbbtfirst(file_rec->an_tree[type]->root); entry != NULL; entry = tbbtnext(entry)) {
ann_entry = (ANentry *)entry->data; /* get annotation entry from node */
if ((ann_entry->elmref == elem_ref) &&
(ann_entry->elmtag == elem_tag)) { /* save ref of ann match in list */
Expand Down Expand Up @@ -1329,7 +1329,7 @@ ANend(int32 an_id /* IN: Annotation ID of file to close */)
/* free file label annotation rb tree */
if (file_rec->an_tree[AN_FILE_LABEL] !=
NULL) { /* Traverse tree puling ann_id's to delete from annotation atom group */
for (aentry = tbbtfirst((TBBT_NODE *)*(file_rec->an_tree[AN_FILE_LABEL])); aentry != NULL;
for (aentry = tbbtfirst(file_rec->an_tree[AN_FILE_LABEL]->root); aentry != NULL;
aentry = tbbtnext(aentry)) { /* get annotation entry from node */
ann_entry = (ANentry *)aentry->data;

Expand All @@ -1346,7 +1346,7 @@ ANend(int32 an_id /* IN: Annotation ID of file to close */)
/* free file desc annotation rb tree */
if (file_rec->an_tree[AN_FILE_DESC] !=
NULL) { /* Traverse tree puling ann_id's to delete from annotation atom group */
for (aentry = tbbtfirst((TBBT_NODE *)*(file_rec->an_tree[AN_FILE_DESC])); aentry != NULL;
for (aentry = tbbtfirst(file_rec->an_tree[AN_FILE_DESC]->root); aentry != NULL;
aentry = tbbtnext(aentry)) { /* get annotation entry from node */
ann_entry = (ANentry *)aentry->data;

Expand All @@ -1364,7 +1364,7 @@ ANend(int32 an_id /* IN: Annotation ID of file to close */)
/* free label annotation rb tree */
if (file_rec->an_tree[AN_DATA_LABEL] !=
NULL) { /* Traverse tree puling ann_id's to delete from annotation atom group */
for (aentry = tbbtfirst((TBBT_NODE *)*(file_rec->an_tree[AN_DATA_LABEL])); aentry != NULL;
for (aentry = tbbtfirst(file_rec->an_tree[AN_DATA_LABEL]->root); aentry != NULL;
aentry = tbbtnext(aentry)) { /* get annotation entry from node */
ann_entry = (ANentry *)aentry->data;

Expand All @@ -1381,7 +1381,7 @@ ANend(int32 an_id /* IN: Annotation ID of file to close */)
/* free desc annotation rb tree */
if (file_rec->an_tree[AN_DATA_DESC] !=
NULL) { /* Traverse tree pulling ann_id's to delete from annotation atom group */
for (aentry = tbbtfirst((TBBT_NODE *)*(file_rec->an_tree[AN_DATA_DESC])); aentry != NULL;
for (aentry = tbbtfirst(file_rec->an_tree[AN_DATA_DESC]->root); aentry != NULL;
aentry = tbbtnext(aentry)) { /* get annotation entry from node */
ann_entry = (ANentry *)aentry->data;

Expand Down Expand Up @@ -1534,7 +1534,7 @@ ANselect(int32 an_id, /* IN: annotation interface ID */
HE_REPORT_GOTO("bad index", FAIL);

/* find 'index' entry */
if ((entry = tbbtindx((TBBT_NODE *)*(file_rec->an_tree[type]), index)) == NULL)
if ((entry = tbbtindx(file_rec->an_tree[type]->root, index)) == NULL)
HE_REPORT_GOTO("failed to find 'index' entry", FAIL);

ann_entry = (ANentry *)entry->data;
Expand Down Expand Up @@ -1774,7 +1774,7 @@ ANget_tagref(int32 an_id, /* IN: annotation interface ID */
HE_REPORT_GOTO("bad index", FAIL);

/* find 'index' entry */
if ((entry = tbbtindx((TBBT_NODE *)*(file_rec->an_tree[type]), index)) == NULL)
if ((entry = tbbtindx(file_rec->an_tree[type]->root, index)) == NULL)
HE_REPORT_GOTO("failed to find 'index' entry", FAIL);

ann_entry = (ANentry *)entry->data;
Expand Down
14 changes: 7 additions & 7 deletions hdf/src/mfgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1995,7 +1995,7 @@ GRend(int32 grid)
void **t2;
ri_info_t *img_ptr; /* ptr to the image */

if (NULL == (t2 = (void **)tbbtfirst((TBBT_NODE *)*(gr_ptr->grtree)))) {
if (NULL == (t2 = (void **)tbbtfirst(gr_ptr->grtree->root))) {
HGOTO_ERROR(DFE_NOTINTABLE, FAIL);
} /* end if */
else
Expand Down Expand Up @@ -2029,7 +2029,7 @@ GRend(int32 grid)
void **t3;
at_info_t *attr_ptr; /* ptr to the attribute */

if (NULL == (t3 = (void **)tbbtfirst((TBBT_NODE *)*(img_ptr->lattree)))) {
if (NULL == (t3 = (void **)tbbtfirst(img_ptr->lattree->root))) {
HGOTO_ERROR(DFE_NOTINTABLE, FAIL);
} /* end if */
else
Expand Down Expand Up @@ -2082,7 +2082,7 @@ GRend(int32 grid)
void **t2;
at_info_t *attr_ptr; /* ptr to the attribute */

if (NULL == (t2 = (void **)tbbtfirst((TBBT_NODE *)*(gr_ptr->gattree)))) {
if (NULL == (t2 = (void **)tbbtfirst(gr_ptr->gattree->root))) {
HGOTO_ERROR(DFE_NOTINTABLE, FAIL);
} /* end if */
else
Expand Down Expand Up @@ -2358,7 +2358,7 @@ GRnametoindex(int32 grid, const char *name)
if (NULL == (gr_ptr = (gr_info_t *)HAatom_object(grid)))
HGOTO_ERROR(DFE_GRNOTFOUND, FAIL);

if ((t = (void **)tbbtfirst((TBBT_NODE *)*(gr_ptr->grtree))) == NULL)
if ((t = (void **)tbbtfirst(gr_ptr->grtree->root)) == NULL)
HGOTO_ERROR(DFE_RINOTFOUND, FAIL);
do {
ri_ptr = (ri_info_t *)*t;
Expand Down Expand Up @@ -3352,7 +3352,7 @@ GRreftoindex(int32 grid, uint16 ref)
if (NULL == (gr_ptr = (gr_info_t *)HAatom_object(grid)))
HGOTO_ERROR(DFE_GRNOTFOUND, FAIL);

if ((t = (void **)tbbtfirst((TBBT_NODE *)*(gr_ptr->grtree))) == NULL)
if ((t = (void **)tbbtfirst(gr_ptr->grtree->root)) == NULL)
HGOTO_ERROR(DFE_RINOTFOUND, FAIL);
do {
ri_ptr = (ri_info_t *)*t;
Expand Down Expand Up @@ -4392,7 +4392,7 @@ GRsetattr(int32 id, const char *name, int32 attr_nt, int32 count, const void *da
HGOTO_ERROR(DFE_ARGS, FAIL);

/* Search for an attribute with the same name */
if ((t = (void **)tbbtfirst((TBBT_NODE *)*search_tree)) != NULL) {
if ((t = (void **)tbbtfirst(search_tree->root)) != NULL) {
do {
at_ptr = (at_info_t *)*t;
if (at_ptr != NULL && strcmp(at_ptr->name, name) == 0) /* ie. the name matches */
Expand Down Expand Up @@ -4755,7 +4755,7 @@ GRfindattr(int32 id, const char *name)
else /* shouldn't get here, but what the heck... */
HGOTO_ERROR(DFE_ARGS, FAIL);

if ((t = (void **)tbbtfirst((TBBT_NODE *)*search_tree)) == NULL)
if ((t = (void **)tbbtfirst(search_tree->root)) == NULL)
HGOTO_ERROR(DFE_RINOTFOUND, FAIL);
do {
at_ptr = (at_info_t *)*t;
Expand Down
Loading

0 comments on commit bd085c3

Please sign in to comment.