Skip to content

Commit 822998a

Browse files
Remove obsolete code
re: Unidata#2179 The above PR cleaned up reclaiming of complex type instances. As a temporary measure, the old code was left in place demarcated by ````#ifdef SEPDATA````. Since it appears that this change was successful, this PR removes that old SEPDATA marked code.
1 parent 10828c5 commit 822998a

11 files changed

Lines changed: 4 additions & 479 deletions

File tree

RELEASE_NOTES.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ This file contains a high-level description of this package's evolution. Release
77

88
## 4.9.2 - TBD
99

10-
* Fix 'make distcheck' error in run_interop.sh. See [Github #????](https://github.com/Unidata/netcdf-c/pull/????).
10+
* Remove obsolete code. See [Github #????](https://github.com/Unidata/netcdf-c/pull/????).
11+
* Simplify the handling of XGetopt. See [Github #2678](https://github.com/Unidata/netcdf-c/pull/2678).
12+
* Fix 'make distcheck' error in run_interop.sh. See [Github #2631](https://github.com/Unidata/netcdf-c/pull/2631).
1113
* Update `nc-config` to remove inclusion from automatically-detected `nf-config` and `ncxx-config` files, as the wrong files could be included in the output. This is in support of [GitHub #2274](https://github.com/Unidata/netcdf-c/issues/2274).
1214
* Update H5FDhttp.[ch] to work with HDF5 version 1.13.2 and later. See [Github #2635](https://github.com/Unidata/netcdf-c/pull/2635).
1315
* [Bug Fix] Update DAP code to enable CURLOPT_ACCEPT_ENCODING by default. See [Github #2630](https://github.com/Unidata/netcdf-c/pull/2630).
14-
* [Bug Fix] Fix byterange failures for certain URLs. See [Github #????](https://github.com/Unidata/netcdf-c/pull/????).
16+
* [Bug Fix] Fix byterange failures for certain URLs. See [Github #2649](https://github.com/Unidata/netcdf-c/pull/2649).
1517
* [Bug Fix] Fix 'make distcheck' error in run_interop.sh. See [Github #2631](https://github.com/Unidata/netcdf-c/pull/2631).
1618
* [Enhancement] Update `nc-config` to remove inclusion from automatically-detected `nf-config` and `ncxx-config` files, as the wrong files could be included in the output. This is in support of [GitHub #2274](https://github.com/Unidata/netcdf-c/issues/2274).
1719
* [Enhancement] Update H5FDhttp.[ch] to work with HDF5 version 1.14.0. See [Github #2615](https://github.com/Unidata/netcdf-c/pull/2615).

include/nc4internal.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,6 @@ typedef struct NC_ATT_INFO
168168
nc_type nc_typeid; /**< NetCDF type of attribute's data. */
169169
void *format_att_info; /**< Pointer to format-specific att info. */
170170
void *data; /**< The attribute data. */
171-
#ifdef SEPDATA
172-
nc_vlen_t *vldata; /**< VLEN data (only used for vlen types). */
173-
char **stdata; /**< String data (only for string type). */
174-
#endif
175171
} NC_ATT_INFO_T;
176172

177173
/** This is a struct to handle the var metadata. */

libdispatch/dcopy.c

Lines changed: 0 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -520,88 +520,6 @@ NC_copy_att(int ncid_in, int varid_in, const char *name,
520520
if ((res = nc_inq_att(ncid_in, varid_in, name, &xtype, &len)))
521521
return res;
522522

523-
#ifdef SEPDATA
524-
if (xtype < NC_STRING)
525-
{
526-
/* Handle non-string atomic types. */
527-
if (len)
528-
{
529-
size_t size = NC_atomictypelen(xtype);
530-
531-
assert(size > 0);
532-
if (!(data = malloc(len * size)))
533-
return NC_ENOMEM;
534-
}
535-
536-
res = nc_get_att(ncid_in, varid_in, name, data);
537-
if (!res)
538-
res = nc_put_att(ncid_out, varid_out, name, xtype,
539-
len, data);
540-
if (len)
541-
free(data);
542-
}
543-
#ifdef USE_NETCDF4
544-
else if (xtype == NC_STRING)
545-
{
546-
/* Copy string attributes. */
547-
char **str_data;
548-
if (!(str_data = malloc(sizeof(char *) * len)))
549-
return NC_ENOMEM;
550-
res = nc_get_att_string(ncid_in, varid_in, name, str_data);
551-
if (!res)
552-
res = nc_put_att_string(ncid_out, varid_out, name, len,
553-
(const char **)str_data);
554-
nc_free_string(len, str_data);
555-
free(str_data);
556-
}
557-
else
558-
{
559-
/* Copy user-defined type attributes. */
560-
int class;
561-
size_t size;
562-
void *data;
563-
nc_type xtype_out = NC_NAT;
564-
565-
/* Find out if there is an equal type in the output file. */
566-
/* Note: original code used a libsrc4 specific internal function
567-
which we had to "duplicate" here */
568-
if ((res = NC_find_equal_type(ncid_in, xtype, ncid_out, &xtype_out)))
569-
return res;
570-
if (xtype_out)
571-
{
572-
/* We found an equal type! */
573-
if ((res = nc_inq_user_type(ncid_in, xtype, NULL, &size,
574-
NULL, NULL, &class)))
575-
return res;
576-
if (class == NC_VLEN) /* VLENs are different... */
577-
{
578-
nc_vlen_t *vldata;
579-
int i;
580-
if (!(vldata = malloc(sizeof(nc_vlen_t) * len)))
581-
return NC_ENOMEM;
582-
if ((res = nc_get_att(ncid_in, varid_in, name, vldata)))
583-
return res;
584-
if ((res = nc_put_att(ncid_out, varid_out, name, xtype_out,
585-
len, vldata)))
586-
return res;
587-
for (i = 0; i < len; i++)
588-
if((res = nc_free_vlen(&vldata[i])))
589-
return res;
590-
free(vldata);
591-
}
592-
else /* not VLEN */
593-
{
594-
if (!(data = malloc(size * len)))
595-
return NC_ENOMEM;
596-
res = nc_get_att(ncid_in, varid_in, name, data);
597-
if (!res)
598-
res = nc_put_att(ncid_out, varid_out, name, xtype_out, len, data);
599-
free(data);
600-
}
601-
}
602-
}
603-
#endif /*!USE_NETCDF4*/
604-
#else /*!SEPDATA*/
605523
{
606524
/* Copy arbitrary attributes. */
607525
int class;
@@ -629,7 +547,6 @@ NC_copy_att(int ncid_in, int varid_in, const char *name,
629547
res = nc_put_att(ncid_out, varid_out, name, xtype_out, len, data);
630548
(void)nc_reclaim_data_all(ncid_out,xtype_out,data,len);
631549
}
632-
#endif /*SEPDATA*/
633550

634551
return res;
635552
}

libhdf5/hdf5attr.c

Lines changed: 0 additions & 158 deletions
Original file line numberDiff line numberDiff line change
@@ -552,34 +552,13 @@ nc4_put_att(NC_GRP_INFO_T* grp, int varid, const char *name, nc_type file_type,
552552
if ((retval = nc4_get_typelen_mem(h5, file_type, &type_size)))
553553
return retval;
554554

555-
#ifdef SEPDATA
556-
/* If this att has vlen or string data, release it before we lose the length value. */
557-
if (att->stdata)
558-
{
559-
int i;
560-
for (i = 0; i < att->len; i++)
561-
if(att->stdata[i])
562-
free(att->stdata[i]);
563-
free(att->stdata);
564-
att->stdata = NULL;
565-
}
566-
if (att->vldata)
567-
{
568-
int i;
569-
for (i = 0; i < att->len; i++) {
570-
nc_free_vlen(&att->vldata[i]); /* FIX: see warning of nc_free_vlen */
571-
free(att->vldata);
572-
att->vldata = NULL;
573-
}
574-
#else
575555
if (att->data)
576556
{
577557
assert(attsave.data == NULL);
578558
attsave.data = att->data;
579559
attsave.len = att->len;
580560
att->data = NULL;
581561
}
582-
#endif
583562

584563
/* If this is the _FillValue attribute, then we will also have to
585564
* copy the value to the fill_vlue pointer of the NC_VAR_INFO_T
@@ -611,74 +590,15 @@ nc4_put_att(NC_GRP_INFO_T* grp, int varid, const char *name, nc_type file_type,
611590
* one. Make up your damn mind, would you? */
612591
if (var->fill_value)
613592
{
614-
#ifdef SEPDATA
615-
if (var->type_info->nc_type_class == NC_VLEN)
616-
{
617-
if ((retval = nc_free_vlen(var->fill_value)))
618-
BAIL(retval);
619-
}
620-
else if (var->type_info->nc_type_class == NC_STRING)
621-
{
622-
if (*(char **)var->fill_value)
623-
free(*(char **)var->fill_value);
624-
}
625-
free(var->fill_value);
626-
#else
627593
/* reclaim later */
628594
fillsave.data = var->fill_value;
629595
fillsave.type = var->type_info->hdr.id;
630596
fillsave.len = 1;
631-
#endif
632597
var->fill_value = NULL;
633598
}
634599

635600
/* Determine the size of the fill value in bytes. */
636-
#ifdef SEPDATA
637-
if (var->type_info->nc_type_class == NC_VLEN)
638-
size = sizeof(hvl_t);
639-
else if (var->type_info->nc_type_class == NC_STRING)
640-
size = sizeof(char *);
641-
else
642-
size = type_size;
643-
#endif
644-
645-
#ifdef SEPDATA
646-
/* Allocate space for the fill value. */
647-
if (!(var->fill_value = calloc(1, size)))
648-
BAIL(NC_ENOMEM);
649-
650-
/* Copy the fill_value. */
651-
LOG((4, "Copying fill value into metadata for variable %s", var->hdr.name));
652-
if (var->type_info->nc_type_class == NC_VLEN)
653-
{
654-
nc_vlen_t *in_vlen = (nc_vlen_t *)data, *fv_vlen = (nc_vlen_t *)(var->fill_value);
655-
NC_TYPE_INFO_T* basetype;
656-
size_t basetypesize = 0;
657601

658-
/* get the basetype and its size */
659-
basetype = var->type_info;
660-
if ((retval = nc4_get_typelen_mem(grp->nc4_info, basetype->hdr.id, &basetypesize)))
661-
BAIL(retval);
662-
/* shallow clone the content of the vlen; shallow because it has only a temporary existence */
663-
fv_vlen->len = in_vlen->len;
664-
if (!(fv_vlen->p = malloc(basetypesize * in_vlen->len)))
665-
BAIL(NC_ENOMEM);
666-
memcpy(fv_vlen->p, in_vlen->p, in_vlen->len * basetypesize);
667-
}
668-
else if (var->type_info->nc_type_class == NC_STRING)
669-
{
670-
if (*(char **)data)
671-
{
672-
if (!(*(char **)(var->fill_value) = malloc(strlen(*(char **)data) + 1)))
673-
BAIL(NC_ENOMEM);
674-
strcpy(*(char **)var->fill_value, *(char **)data);
675-
}
676-
else
677-
*(char **)var->fill_value = NULL;
678-
}
679-
else
680-
memcpy(var->fill_value, data, type_size);
681-
#else
682602
{
683603
nc_type var_type = var->type_info->hdr.id;
684604
size_t var_type_size = var->type_info->size;
@@ -704,7 +624,6 @@ nc4_put_att(NC_GRP_INFO_T* grp, int varid, const char *name, nc_type file_type,
704624
var->fill_value = copy;
705625
copy = NULL;
706626
}
707-
#endif
708627
/* Indicate that the fill value was changed, if the variable has already
709628
* been created in the file, so the dataset gets deleted and re-created. */
710629
if (var->created)
@@ -721,82 +640,6 @@ nc4_put_att(NC_GRP_INFO_T* grp, int varid, const char *name, nc_type file_type,
721640
BAIL(retval);
722641

723642
assert(data);
724-
#ifdef SEPDATA
725-
if (type_class == NC_VLEN)
726-
{
727-
const hvl_t *vldata1;
728-
NC_TYPE_INFO_T *vltype;
729-
size_t base_typelen;
730-
731-
/* Get the type object for the attribute's type */
732-
if ((retval = nc4_find_type(h5, file_type, &vltype)))
733-
BAIL(retval);
734-
735-
/* Retrieve the size of the base type */
736-
if ((retval = nc4_get_typelen_mem(h5, vltype->u.v.base_nc_typeid, &base_typelen)))
737-
BAIL(retval);
738-
739-
vldata1 = data;
740-
if (!(att->vldata = (nc_vlen_t*)malloc(att->len * sizeof(hvl_t))))
741-
BAIL(NC_ENOMEM);
742-
for (i = 0; i < att->len; i++)
743-
{
744-
att->vldata[i].len = vldata1[i].len;
745-
/* Warning, this only works for cases described for nc_free_vlen() */
746-
if (!(att->vldata[i].p = malloc(base_typelen * att->vldata[i].len)))
747-
BAIL(NC_ENOMEM);
748-
memcpy(att->vldata[i].p, vldata1[i].p, base_typelen * att->vldata[i].len);
749-
}
750-
}
751-
else if (type_class == NC_STRING)
752-
{
753-
LOG((4, "copying array of NC_STRING"));
754-
if (!(att->stdata = malloc(sizeof(char *) * att->len))) {
755-
BAIL(NC_ENOMEM);
756-
}
757-
758-
/* If we are overwriting an existing attribute,
759-
specifically an NC_CHAR, we need to clean up
760-
the pre-existing att->data. */
761-
if (!new_att && att->data) {
762-
763-
free(att->data);
764-
att->data = NULL;
765-
}
766-
767-
for (i = 0; i < att->len; i++)
768-
{
769-
if(NULL != ((char **)data)[i]) {
770-
LOG((5, "copying string %d of size %d", i, strlen(((char **)data)[i]) + 1));
771-
if (!(att->stdata[i] = strdup(((char **)data)[i])))
772-
BAIL(NC_ENOMEM);
773-
}
774-
else
775-
att->stdata[i] = ((char **)data)[i];
776-
}
777-
}
778-
else
779-
{
780-
/* [Re]allocate memory for the attribute data */
781-
if (!new_att)
782-
free (att->data);
783-
if (!(att->data = malloc(att->len * type_size)))
784-
BAIL(NC_ENOMEM);
785-
786-
/* Just copy the data, for non-atomic types */
787-
if (type_class == NC_OPAQUE || type_class == NC_COMPOUND || type_class == NC_ENUM)
788-
memcpy(att->data, data, len * type_size);
789-
else
790-
{
791-
/* Data types are like religions, in that one can convert. */
792-
if ((retval = nc4_convert_type(data, att->data, mem_type, file_type,
793-
len, &range_error, NULL,
794-
(h5->cmode & NC_CLASSIC_MODEL),
795-
NC_NOQUANTIZE, 0)))
796-
BAIL(retval);
797-
}
798-
}
799-
#else
800643
{
801644
/* Allocate top level of the copy */
802645
if (!(copy = malloc(len * type_size)))
@@ -816,7 +659,6 @@ nc4_put_att(NC_GRP_INFO_T* grp, int varid, const char *name, nc_type file_type,
816659
/* Store it */
817660
att->data = copy; copy = NULL;
818661
}
819-
#endif
820662
}
821663
att->dirty = NC_TRUE;
822664
att->created = NC_FALSE;

libhdf5/hdf5internal.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -613,18 +613,11 @@ close_vars(NC_GRP_INFO_T *grp)
613613
{
614614
if (var->type_info)
615615
{
616-
#ifdef SEPDATA
617-
if (var->type_info->nc_type_class == NC_VLEN)
618-
nc_free_vlen((nc_vlen_t *)var->fill_value);
619-
else if (var->type_info->nc_type_class == NC_STRING && *(char **)var->fill_value)
620-
free(*(char **)var->fill_value);
621-
#else
622616
int stat = NC_NOERR;
623617
if((stat = nc_reclaim_data(grp->nc4_info->controller->ext_ncid,var->type_info->hdr.id,var->fill_value,1)))
624618
return stat;
625619
nullfree(var->fill_value);
626620
}
627-
#endif
628621
var->fill_value = NULL;
629622
}
630623
}

0 commit comments

Comments
 (0)