Skip to content

Commit

Permalink
Bug fix decoding many variable datasets
Browse files Browse the repository at this point in the history
  • Loading branch information
cpiker committed Jun 11, 2024
1 parent 31bee99 commit a831ea7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
17 changes: 9 additions & 8 deletions das2/dataset.c
Original file line number Diff line number Diff line change
Expand Up @@ -364,16 +364,17 @@ void _DasDs_codecsGoLarger(DasDs* pThis)
/* We're already using dynamic codec array, now go even bigger */
size_t uNewSz = pThis->uSzCodecs * 2;

DasCodec* pNewCodecs = (DasCodec*) calloc(uNewSz, sizeof(DasCodec));
int* pNewItems = (int*) calloc(uNewSz, sizeof(int));

pThis->lCodecs = realloc(pThis->lCodecs, uNewSz * sizeof(DasCodec));
pThis->lItems = realloc(pThis->lCodecs, uNewSz * sizeof(int));
memcpy(pNewCodecs, pThis->lCodecs, pThis->uSzCodecs*sizeof(DasCodec));
memcpy(pNewItems, pThis->lItems, pThis->uSzCodecs*sizeof(int));

/* Null out the new memory, realloc doesn't do this */
size_t uHalfSz = (pThis->uSzCodecs) * sizeof(DasCodec);
memset(pThis->lCodecs + uHalfSz, 0, uHalfSz);

uHalfSz = (pThis->uSzCodecs) * sizeof(int);
memset(pThis->lItems + uHalfSz, 0, uHalfSz);
free(pThis->lCodecs);
free(pThis->lItems);

pThis->lCodecs = pNewCodecs;
pThis->lItems = pNewItems;

pThis->uSzCodecs = uNewSz;
}
Expand Down
3 changes: 3 additions & 0 deletions utilities/das3_cdf.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ void prnHelp()
" summary -> CATDESC\n"
" notes -> VAR_NOTES\n"
" format -> FORMAT\n"
" frame -> VECTOR_FRAME\n"
" nominalMin,nominalMax -> LIMITS_NOMINAL_MIN,LIMITS_NOMINAL_MAX\n"
" scaleMin,scaleMax -> SCALEMIN,SCALEMAX\n"
" scaleType -> SCALETYP\n"
Expand Down Expand Up @@ -475,6 +476,8 @@ const char* DasProp_cdfVarName(const DasProp* pProp)
if(strcmp(sName, "info" ) == 0) return "VAR_NOTES";
if(strcmp(sName, "notes" ) == 0) return "VAR_NOTES";

if(strcmp(sName, "frame" ) == 0) return "VECTOR_FRAME";

if(strcmp(sName, "fill" ) == 0) return "FILLVAL";
if(strcmp(sName, "format" ) == 0) return "FORMAT";
if(strcmp(sName, "info" ) == 0) return "VAR_NOTES";
Expand Down

0 comments on commit a831ea7

Please sign in to comment.