This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
Hello, Thank you for the patch. The C++ 4.2 libraries are deprecated (as you note), but I will take a look to see if the same issue occurs in the latest C++ libraries and, if so, will apply your patch to address the issue. Thanks again, have a great day, -Ward > Hi > > In debugging netcdf apps using valgrind, I get warnings related to the > use of uninitialized variables. > > In the older C++ lib, I suggest that you change the NcVar constructor to > be as follows: > > NcVar::NcVar(NcFile* nc, int id) > : NcTypedComponent(nc), the_id(id) > { > char nam[NC_MAX_NAME]; > memset(nam, 0, NC_MAX_NAME); <<<===== add this line > if (the_file > && NcError::set_err( > nc_inq_varname(the_file->id(), the_id, nam) > ) == NC_NOERR) { > the_name = new char[1 + strlen(nam)]; > strcpy(the_name, nam); > } else { > the_name = 0; > } > init_cur(); > } > > i.e. add the memset call to clear the nam variable before it is used. > > I did this in a valgrind test environment and it cleared up a lot of > warnings. > > Thanks > > Mike Dixon > > > Ticket Details =================== Ticket ID: PHC-148715 Department: Support netCDF Priority: Normal Status: Closed