Re: Strings

NOTE: The netcdf-hdf mailing list is no longer active. The list archives are made available for historical reasons.


H5free shouldn't be used by a user. H5Dvlen_reclaim does all necessary work. Let me look into the test. I have no clue at this point.


At 10:33 AM 9/12/2005, Ed Hartnett wrote:
Elena Pourmal <epourmal@xxxxxxxxxxxxx> writes:

> I believe you just allocate array of char pointers, then library does
> the rest. You only have to use
> H5Dvlen_reclaim function after you are done. See tvlstr.c test in the
> test directory.
> Elena

Howdy Elena!

Well, looking at tvlstr.c was very interesting, and it leads to lots
of questions!

I am looking at function test_write_vl_string_attribute().

>From the code below it's clear that no space is allocated for
string_att_check before the H5Aread is called.

And then H5free(string_att_check) is called. Is H5free documented
anywhere on-line? I can't find it...

In this case it seems that you are writing a scalar string, and you
don't have to allocate space when reading it. Which makes sense. But
where does H5free come in to it? The user must call this function
after reading the string, right?

Will H5Dvlen_reclaim with for scalar strings? Or must the user use



static void test_write_vl_string_attribute(void)
    hid_t file, root, dataspace, att;
    hid_t type;
    herr_t ret;
    char *string_att_check;

    /* Open the file */
    file = H5Fopen(DATAFILE, H5F_ACC_RDWR, H5P_DEFAULT);
    CHECK(file, FAIL, "H5Fopen");

    /* Create a datatype to refer to. */
    type = H5Tcopy (H5T_C_S1);
    CHECK(type, FAIL, "H5Tcopy");

    ret = H5Tset_size (type, H5T_VARIABLE);
    CHECK(ret, FAIL, "H5Tset_size");

    root = H5Gopen(file, "/");
    CHECK(root, FAIL, "H5Gopen");

    dataspace = H5Screate(H5S_SCALAR);
    CHECK(dataspace, FAIL, "H5Screate");

    /* Test creating a "normal" sized string attribute */
    att = H5Acreate(root, "test_scalar", type, dataspace, H5P_DEFAULT);
    CHECK(att, FAIL, "H5Acreate");

    ret = H5Awrite(att, type, &string_att);
    CHECK(ret, FAIL, "H5Awrite");

    ret = H5Aread(att, type, &string_att_check);
    CHECK(ret, FAIL, "H5Aread");

Ed Hartnett  -- ed@xxxxxxxxxxxxxxxx

Elena Pourmal, HDF QA, Maintenance and Support Team Leader
NCSA University of Illinois at Urbana-Champaign
605 E. Springfield Ave.
Champaign, IL 61820

(217)333-0238 (office)
(217)244-1987 (fax)

  • 2005 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdf-hdf archives: