Skip to content

Commit

Permalink
Fixed a problem with determining the length of variable length string…
Browse files Browse the repository at this point in the history
… attributes
  • Loading branch information
mkoennecke committed May 9, 2016
1 parent 2a1b894 commit 2f16c9e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ CMakeFiles
Makefile
cmake_install.cmake
install_manifest.txt
*.cmake

# Ignore usual in-tree CMake build area
/build/
Expand Down
2 changes: 1 addition & 1 deletion applications/NXbrowse/NXbrowse.c
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ void ConvertUpperCase(char *string)
/* Checks for attributes and outputs their values */
void PrintAttributes(NXhandle fileId)
{
int status, attrLen, attrType;
int status, attrLen = 0, attrType;
NXname attrName;
void *attrBuffer;

Expand Down
4 changes: 3 additions & 1 deletion src/napi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1158,7 +1158,9 @@ NXstatus NXmalloc64(void **data, int rank,
return NX_ERROR;
}
*data = (void *)malloc(size);
memset(*data, 0, size);
if(*data != NULL){
memset(*data, 0, size);
}
return NX_OK;
}

Expand Down
14 changes: 10 additions & 4 deletions src/napi5.c
Original file line number Diff line number Diff line change
Expand Up @@ -2575,9 +2575,10 @@ NXstatus NX5getattrainfo(NXhandle handle, NXname name, int *rank, int dim[], in
{
pNexusFile5 pFile;
int i, iRet, mType, vid;
hid_t filespace, attrt;
hid_t filespace, attrt, memtype;
hsize_t myDim[H5S_MAX_RANK], myrank;
H5T_class_t tclass;
char *vlStr = NULL;

pFile = NXI5assert(handle);

Expand Down Expand Up @@ -2612,9 +2613,14 @@ NXstatus NX5getattrainfo(NXhandle handle, NXname name, int *rank, int dim[], in
if (tclass == H5T_STRING) {
myrank++;
if (H5Tis_variable_str(attrt)) {
hsize_t vlen_bytes;
H5Dvlen_get_buf_size(pFile->iCurrentA, attrt, H5S_ALL, &vlen_bytes);
myDim[myrank - 1] = vlen_bytes;
memtype = H5Tcopy (H5T_C_S1);
H5Tset_size (memtype, H5T_VARIABLE);
H5Aread(pFile->iCurrentA, memtype,&vlStr);
if(vlStr != NULL){
myDim[myrank - 1] = strlen(vlStr) +1;
H5Dvlen_reclaim (memtype, pFile->iCurrentA, H5P_DEFAULT, &vlStr);
}
H5Tclose(memtype);
} else {
myDim[myrank - 1] = H5Tget_size(attrt);
}
Expand Down

0 comments on commit 2f16c9e

Please sign in to comment.