gd_close(3)

NAME
gd_close, gd_discard — close a Dirfile and free associated memory

SYNOPSIS
#include <getdata.h>

int gd_close(DIRFILE *dirfile);

int gd_discard(DIRFILE *dirfile);

DESCRIPTION
The and attempt to close the open Dirfile and free all memory associated with it. The function first flushes all pending metadata updates to disk. This step is skipped by which simply discards metadata changes. For dirfiles opened read-only, these two functions are equivalent. Next, all pending data is flushed to disk and all open data files closed. In order to ensure that modified data files associated with RAW fields are properly terminated, changes to RAW data files are still flushed to disk by Finally, if the above didn't encounter an error, these functions free memory associated with the DIRFILE object. If is NULL, nothing happens, and the call succeeds. One of these functions should be called on all pointers returned by and even if the call to those function failed. After or returns successfully, the pointer should be considered invalid. Metadata is written to disk using the current Standards Version as stored in the object. See to change or report the current Standards Version. If the dirfile metadata conforms to no known Standards Version, Standards non-compliant metadata will be written.

RETURN VALUE
and return zero on success. On error, they do not de-allocate and instead return a negative-valued error code. Possible error codes are: The library was unable to allocate memory. While attempting to flush modified metadata to disk, a field specification line exceeded the maximum allowed length. On most platforms, the maximum length is at least 2**31 bytes, so this typically indicates something pathological happening. An I/O error occurred while trying to write modified data or metadata to disk. In this case, another call to or may be attempted.

The error code is also stored in the DIRFILE object and may be retrieved after this function returns by calling A descriptive error string for the error may be obtained by calling

HISTORY
The function appeared in GetData-0.3.0. The function appeared in GetData-0.6.0. In GetData-0.7.0 these functions were renamed to and In GetData-0.10.0, the error return from these functions changed from -1 to a negative-valued error code.

SEE ALSO