gd_close(3)
π gd_close(3) π
part of the GETDATA manual, bestie π
okay so listen. this is the page about gd_close() and gd_discard() β the two functions that close a Dirfile and free associated memory. it's giving cleanup era. it's giving β¨closureβ¨ (literally).
πΈ SYNOPSIS πΈ
#include <getdata.h>
int gd_close(DIRFILE *dirfile);
int gd_discard(DIRFILE *dirfile);
π¦ DESCRIPTION π¦
so gd_close() and gd_discard() both try to close the open Dirfile dirfile and free all the memory that's associated with it. no cap, all of it. π§Ή
the difference between them? okay so gd_close() first flushes all pending metadata updates to disk. that whole step? gd_discard() skips it entirely and simply discards metadata changes. yeah. it said "not me saving that" π.
but wait β for dirfiles opened read-only, these two functions are equivalent. so if you're in read-only mode, pick either one, it's the same vibe. periodt.
next up: all pending data gets flushed to disk and all open data files get closed. and here's the plot twist β in order to make sure that modified data files associated with RAW fields are properly terminated, changes to RAW data files are still flushed to disk by gd_discard(). so like, it discards metadata but it does NOT discard your RAW data. that's a whole different thing. π
finally, if the above didn't hit an error, these functions free the memory associated with the DIRFILE object. bye bestie π«Ά
if dirfile is NULL, nothing happens, and the call succeeds. iconic behaviour, honestly. no drama.
β οΈ okay this part is important: one of these functions should be called on all pointers returned bygd_cbopen(3),gd_open(3), andgd_invalid_dirfile(3)β even if the call to those function failed. yes, even then. and aftergd_close()orgd_discard()returns successfully, the pointerdirfileshould be considered invalid. do not touch it. it's gone. it's in its past lives era. π
metadata is written to disk using the current Standards Version as stored in the dirfile object. wanna change or report the current Standards Version? see gd_dirfile_standards(3). and if the dirfile metadata conforms to no known Standards Version, then Standards non-compliant metadata will be written. so like. it'll just write it anyway. bold of it but okay. π
β¨ RETURN VALUE β¨
gd_close() and gd_discard() return zero on success. slay. π
on error, they do not de-allocate dirfile and instead return a negative-valued error code. possible error codes are:
GD_E_ALLOCβ the library was unable to allocate memory. it's out of spoons. πGD_E_LINE_TOO_LONGβ 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 least2**31bytes, so this typically indicates something pathological happening. like girl what are you doing. πGD_E_IOβ an I/O error occurred while trying to write modified data or metadata to disk. in this case, another call togd_close()orgd_discard()may be attempted. so it's giving "try again bestie, we believe in you". π«Ά
the error code is also stored in the DIRFILE object and may be retrieved after this function returns by calling gd_error(3). and a descriptive error string for the error may be obtained by calling gd_error_string(3). very demure, very mindful, very informative. π
π HISTORY π
- the function
dirfile_close()appeared in GetData-0.3.0. - the function
dirfile_discard()appeared in GetData-0.6.0. - in GetData-0.7.0 these functions were renamed to
gd_close()andgd_discard(). rebrand era β¨ - in GetData-0.10.0, the error return from these functions changed from
-1to a negative-valued error code. glow up fr fr.
π SEE ALSO π
and that's the whole page, bestie. this was Version 0.10.0, dated 25 December 2016 β yeah it's a lil vintage, but so is everything good. go close your dirfiles. free your memory. hydrate. ππ¦β¨
π¦ where this page comes from
- debian bookworm: libgetdata-doc 0.11.0-6
- debian trixie: libgetdata-doc 0.11.0-15
- fedora 43: getdata-devel 0.11.0-13.fc43 Β· GPL-2.0-or-later
- fedora 43: getdata-devel 0.11.0-13.fc43 Β· GPL-2.0-or-later
- fedora 44: getdata-devel 0.11.0-14.fc44 Β· GPL-2.0-or-later
- fedora 44: getdata-devel 0.11.0-14.fc44 Β· GPL-2.0-or-later
- nixos 26.05: getdata 0.11.0
- nixpkgs unstable: getdata 0.11.0
- ubuntu jammy: libgetdata-doc 0.11.0-3ubuntu1
- ubuntu noble: libgetdata-doc 0.11.0-13
- ubuntu questing: libgetdata-doc 0.11.0-15
- ubuntu resolute: libgetdata-doc 0.11.0-17build1
- ubuntu stonking: libgetdata-doc 0.11.0-17build2
- Copyright (C) 2016 D. V. Wiebe
- Copyright (C) 2008, 2009, 2010, 2011, 2014, 2016 D.V. Wiebe
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms