Hi all,

I am using the c++ packet table wrapper of hdf5-1.8.13
(H5PacketTable.h). I noticed that the 'name' parameter is always
passed as 'char*' instead of 'const char*'.
This is a bug.

Trivial patch:

--- a/hl/c++/src/H5PacketTable.cpp
+++ b/hl/c++/src/H5PacketTable.cpp
@@ -34,7 +34,7 @@
      * Opens an existing packet table, which can contain either fixed-length or
      * variable-length packets.
      */
-    PacketTable::PacketTable(hid_t fileID, char* name)
+    PacketTable::PacketTable(hid_t fileID, const char* name)
     {
         table_id = H5PTopen( fileID, name);
     }
@@ -127,7 +127,7 @@
      * the packet table, the ID of the datatype of the set, and the size
      * of a memory chunk used in chunking.
      */
-    FL_PacketTable::FL_PacketTable(hid_t fileID, char* name, hid_t dtypeID, 
hsize_t chunkSize, int compression)
+    FL_PacketTable::FL_PacketTable(hid_t fileID, const char* name, hid_t 
dtypeID, hsize_t chunkSize, int compression)
     {
         table_id = H5PTcreate_fl ( fileID, name, dtypeID, chunkSize, 
compression);
     }
@@ -136,7 +136,7 @@
      * Opens an existing fixed-length packet table.
      * Fails if the packet table specified is variable-length.
      */
-    FL_PacketTable::FL_PacketTable(hid_t fileID, char* name) : 
PacketTable(fileID, name)
+    FL_PacketTable::FL_PacketTable(hid_t fileID, const char* name) : 
PacketTable(fileID, name)
     {
 #ifdef VLPT_REMOVED
         if( H5PTis_varlen(table_id) != 0 )    // If this is not a fixed-length 
table
@@ -226,7 +226,7 @@
      * Takes the ID of the file the packet table will be created in, the name 
of
      * the packet table, and the size of a memory chunk used in chunking.
      */
-    VL_PacketTable::VL_PacketTable(hid_t fileID, char* name, hsize_t chunkSize)
+    VL_PacketTable::VL_PacketTable(hid_t fileID, const char* name, hsize_t 
chunkSize)
     {
         table_id = H5PTcreate_vl ( fileID, name, chunkSize);
     }
@@ -235,7 +235,7 @@
      * Opens an existing variable-length packet table.
      * Fails if the packet table specified is fixed-length.
      */
-    VL_PacketTable::VL_PacketTable(hid_t fileID, char* name) : 
PacketTable(fileID, name)
+    VL_PacketTable::VL_PacketTable(hid_t fileID, const char* name) : 
PacketTable(fileID, name)
     {
         if( H5PTis_varlen(table_id) != 1 )    // If this is not a 
variable-length table
         {
--- a/hl/c++/src/H5PacketTable.h
+++ b/hl/c++/src/H5PacketTable.h
@@ -42,7 +42,7 @@ public:
      * Opens an existing packet table, which can contain either fixed-length or
      * variable-length packets.
      */
-    PacketTable(hid_t fileID, char* name);
+    PacketTable(hid_t fileID, const char* name);
 
     /* Destructor
      * Cleans up the packet table
@@ -110,13 +110,13 @@ public:
      * of a memory chunk used in chunking, and the desired compression level
      * (0-9, or -1 for no compression).
      */
-    FL_PacketTable(hid_t fileID, char* name, hid_t dtypeID, hsize_t chunkSize, 
int compression = -1);
+    FL_PacketTable(hid_t fileID, const char* name, hid_t dtypeID, hsize_t 
chunkSize, int compression = -1);
 
     /* "Open" Constructor
      * Opens an existing fixed-length packet table.
      * Fails if the packet table specified is variable-length.
      */
-    FL_PacketTable(hid_t fileID, char* name);
+    FL_PacketTable(hid_t fileID, const char* name);
 
     /* AppendPacket
      * Adds a single packet to the packet table.  Takes a pointer
@@ -174,13 +174,13 @@ public:
      * Takes the ID of the file the packet table will be created in, the name 
of
      * the packet table, and the size of a memory chunk used in chunking.
      */
-    VL_PacketTable(hid_t fileID, char* name, hsize_t chunkSize);
+    VL_PacketTable(hid_t fileID, const char* name, hsize_t chunkSize);
 
     /* "Open" Constructor
      * Opens an existing variable-length packet table.
      * Fails if the packet table specified is fixed-length.
      */
-    VL_PacketTable(hid_t fileID, char* name);
+    VL_PacketTable(hid_t fileID, const char* name);
 
     /* AppendPacket
      * Adds a single packet of any length to the packet table.

-- 

with best regards
John Doe

_______________________________________________
Hdf-forum is for HDF software users discussion.
[email protected]
http://mail.lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org
Twitter: https://twitter.com/hdf5

Reply via email to