2025-10-11 01:35:43 +01:00
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
< html xmlns = "http://www.w3.org/1999/xhtml" lang = "en-US" >
< head >
< meta http-equiv = "Content-Type" content = "text/xhtml;charset=UTF-8" / >
< meta http-equiv = "X-UA-Compatible" content = "IE=11" / >
2026-04-11 23:17:09 +01:00
< meta name = "generator" content = "Doxygen 1.16.1" / >
2025-10-11 01:35:43 +01:00
< meta name = "viewport" content = "width=device-width, initial-scale=1" / >
< title > libaaruformat: src/close.c File Reference< / title >
< link href = "tabs.css" rel = "stylesheet" type = "text/css" / >
< script type = "text/javascript" src = "jquery.js" > < / script >
< script type = "text/javascript" src = "dynsections.js" > < / script >
< script type = "text/javascript" src = "clipboard.js" > < / script >
< link href = "navtree.css" rel = "stylesheet" type = "text/css" / >
< script type = "text/javascript" src = "navtreedata.js" > < / script >
< script type = "text/javascript" src = "navtree.js" > < / script >
< script type = "text/javascript" src = "cookie.js" > < / script >
< link href = "search/search.css" rel = "stylesheet" type = "text/css" / >
< script type = "text/javascript" src = "search/searchdata.js" > < / script >
< script type = "text/javascript" src = "search/search.js" > < / script >
< link href = "doxygen.css" rel = "stylesheet" type = "text/css" / >
< / head >
< body >
< div id = "top" > <!-- do not remove this div, it is closed by doxygen! -->
< div id = "titlearea" >
< table cellspacing = "0" cellpadding = "0" >
< tbody >
< tr id = "projectrow" >
< td id = "projectalign" >
< div id = "projectname" > libaaruformat< span id = "projectnumber" >   1.0< / span >
< / div >
< div id = "projectbrief" > Aaru Data Preservation Suite - Format Library< / div >
< / td >
< / tr >
< / tbody >
< / table >
< / div >
<!-- end header part -->
2026-04-11 23:17:09 +01:00
<!-- Generated by Doxygen 1.16.1 -->
2025-10-11 01:35:43 +01:00
< script type = "text/javascript" >
var searchBox = new SearchBox("searchBox", "search/",'.html');
< / script >
< script type = "text/javascript" >
$(function() { codefold.init(); });
< / script >
< script type = "text/javascript" src = "menudata.js" > < / script >
< script type = "text/javascript" src = "menu.js" > < / script >
< script type = "text/javascript" >
$(function() {
initMenu('',true,false,'search.php','Search',true);
$(function() { init_search(); });
});
< / script >
< div id = "main-nav" > < / div >
< / div > <!-- top -->
< div id = "side-nav" class = "ui-resizable side-nav-resizable" >
< div id = "nav-tree" >
< div id = "nav-tree-contents" >
< div id = "nav-sync" class = "sync" > < / div >
< / div >
< / div >
< div id = "splitbar" style = "-moz-user-select:none;"
class="ui-resizable-handle">
< / div >
< / div >
< script type = "text/javascript" >
$(function(){initNavTree('close_8c.html','',''); });
< / script >
< div id = "container" >
< div id = "doc-content" >
<!-- window showing the filter options -->
< div id = "MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
< / div >
<!-- iframe showing the search results (closed by default) -->
< div id = "MSearchResultsWindow" >
< div id = "MSearchResults" >
< div class = "SRPage" >
< div id = "SRIndex" >
< div id = "SRResults" > < / div >
< div class = "SRStatus" id = "Loading" > Loading...< / div >
< div class = "SRStatus" id = "Searching" > Searching...< / div >
< div class = "SRStatus" id = "NoMatches" > No Matches< / div >
< / div >
< / div >
< / div >
< / div >
< div class = "header" >
< div class = "headertitle" > < div class = "title" > close.c File Reference< / div > < / div >
< / div > <!-- header -->
< div class = "contents" >
2026-04-11 23:17:09 +01:00
< p > Resource cleanup and public < a class = "el" href = "#a6823e139f81a9dfd08efcb0e9b213a49" title = "Close an Aaru image context, flushing pending data structures and releasing resources." > aaruf_close()< / a > entry point for libaaruformat.
2025-10-11 01:35:43 +01:00
< a href = "#details" > More...< / a > < / p >
< div class = "textblock" > < code > #include < errno.h> < / code > < br / >
< code > #include < stdio.h> < / code > < br / >
< code > #include < stdlib.h> < / code > < br / >
2026-04-11 23:17:09 +01:00
< code > #include < string.h> < / code > < br / >
2025-10-11 01:35:43 +01:00
< code > #include < < a class = "el" href = "aaruformat_8h_source.html" > aaruformat.h< / a > > < / code > < br / >
2026-04-11 23:17:09 +01:00
< code > #include " < a class = "el" href = "erasure__internal_8h_source.html" > erasure_internal.h< / a > " < / code > < br / >
2025-10-11 01:35:43 +01:00
< code > #include " < a class = "el" href = "internal_8h_source.html" > internal.h< / a > " < / code > < br / >
< code > #include " < a class = "el" href = "log_8h_source.html" > log.h< / a > " < / code > < br / >
< / div >
< p > < a href = "close_8c_source.html" > Go to the source code of this file.< / a > < / p >
< table class = "memberdecls" >
< tr class = "heading" > < td colspan = "2" > < h2 id = "header-func-members" class = "groupheader" > < a id = "func-members" name = "func-members" > < / a >
Functions< / h2 > < / td > < / tr >
2026-04-11 23:17:09 +01:00
< tr class = "memitem:a547f7cbebffad90d0a60d8fd2ee1185a" id = "r_a547f7cbebffad90d0a60d8fd2ee1185a" > < td class = "memItemLeft" > static void  < / td > < td class = "memItemRight" > < a class = "el" href = "#a547f7cbebffad90d0a60d8fd2ee1185a" > aaruf_set_close_error< / a > (const int error_code)< / td > < / tr >
< tr class = "memitem:a6823e139f81a9dfd08efcb0e9b213a49" id = "r_a6823e139f81a9dfd08efcb0e9b213a49" > < td class = "memItemLeft" > int  < / td > < td class = "memItemRight" > < a class = "el" href = "#a6823e139f81a9dfd08efcb0e9b213a49" > aaruf_close< / a > (void *context)< / td > < / tr >
2025-10-11 01:35:43 +01:00
< tr class = "memdesc:a6823e139f81a9dfd08efcb0e9b213a49" > < td class = "mdescLeft" >   < / td > < td class = "mdescRight" > Close an Aaru image context, flushing pending data structures and releasing resources. < br / > < / td > < / tr >
< / table >
< a name = "details" id = "details" > < / a > < h2 id = "header-details" class = "groupheader" > Detailed Description< / h2 >
2026-04-11 23:17:09 +01:00
< div class = "textblock" > < p > Resource cleanup and public < a class = "el" href = "#a6823e139f81a9dfd08efcb0e9b213a49" title = "Close an Aaru image context, flushing pending data structures and releasing resources." > aaruf_close()< / a > entry point for libaaruformat. < / p >
< p > Performs orderly teardown of dynamically allocated resources when closing an Aaru image context, regardless of read or write mode. For write-mode contexts the writer finalization hook (< a class = "el" href = "internal_8h.html#a750c966846027990bb0914760758c84c" title = "Finalize a write-mode image: flush all pending blocks, DDTs, and the index." > aaruf_finalize_write()< / a > , defined in < a class = "el" href = "close__write_8c.html" title = "Writer finalization for libaaruformat." > close_write.c< / a > ) is invoked via a function pointer before cleanup begins.< / p >
< dl class = "section see" > < dt > See also< / dt > < dd > < a class = "el" href = "close__write_8c.html" title = "Writer finalization for libaaruformat." > close_write.c< / a > < / dd > < / dl >
2025-10-11 01:35:43 +01:00
< p class = "definition" > Definition in file < a class = "el" href = "close_8c_source.html" > close.c< / a > .< / p >
< / div > < a name = "doc-func-members" id = "doc-func-members" > < / a > < h2 id = "header-doc-func-members" class = "groupheader" > Function Documentation< / h2 >
< a id = "a6823e139f81a9dfd08efcb0e9b213a49" name = "a6823e139f81a9dfd08efcb0e9b213a49" > < / a >
< h2 class = "memtitle" > < span class = "permalink" > < a href = "#a6823e139f81a9dfd08efcb0e9b213a49" > ◆   < / a > < / span > aaruf_close()< / h2 >
< div class = "memitem" >
< div class = "memproto" >
< table class = "memname" >
< tr >
< td class = "memname" > int aaruf_close < / td >
< td > (< / td >
< td class = "paramtype" > void *< / td > < td class = "paramname" > < span class = "paramname" > < em > context< / em > < / span > < / td > < td > )< / td >
< td > < / td >
< / tr >
< / table >
< / div > < div class = "memdoc" >
< p > Close an Aaru image context, flushing pending data structures and releasing resources. < / p >
2026-04-11 23:17:09 +01:00
< p > Public API entry point used to finalize an image being written or simply dispose of a context opened for reading. For write-mode contexts the finalize_write function pointer (set during < a class = "el" href = "decls_8h.html#a7065a9fefcaabfecc4184528f01ef013" title = "Creates a new AaruFormat image file." > aaruf_create()< / a > or resume-mode < a class = "el" href = "decls_8h.html#a5cea94dcb9c08a646f7f7160ec8418de" title = "Opens an existing AaruFormat image file." > aaruf_open()< / a > ) is invoked to flush all pending blocks, DDTs, and the global index before cleanup proceeds.< / p >
2025-10-11 01:35:43 +01:00
< p > Afterwards (or for read-mode contexts) all dynamically allocated buffers, arrays, hash tables and mapping structures are freed/unmapped. Media tags are removed from their hash table.< / p >
< p > Error Handling:< / p > < ul >
< li > Returns -1 with errno = EINVAL if the provided pointer is NULL or not a valid context.< / li >
2026-04-11 23:17:09 +01:00
< li > If the writer finalization hook returns an error status, that error value is propagated directly.< / li >
2025-10-11 01:35:43 +01:00
< / ul >
< dl class = "params" > < dt > Parameters< / dt > < dd >
< table class = "params" >
< tr > < td class = "paramname" > context< / td > < td > Opaque pointer returned by earlier open/create calls (must be an aaruformatContext). < / td > < / tr >
< / table >
< / dd >
< / dl >
< dl class = "section return" > < dt > Returns< / dt > < dd > 0 on success; -1 or negative libaaruformat error code on failure. < / dd > < / dl >
< dl class = "retval" > < dt > Return values< / dt > < dd >
< table class = "retval" >
< tr > < td class = "paramname" > 0< / td > < td > All pending data flushed (if writing) and resources released successfully. < / td > < / tr >
2026-04-11 23:17:09 +01:00
< tr > < td class = "paramname" > -1< / td > < td > Invalid context pointer (errno = EINVAL). < / td > < / tr >
< tr > < td class = "paramname" > < negative< / td > < td > libaaruformat code> Propagated from the writer finalization hook. < / td > < / tr >
2025-10-11 01:35:43 +01:00
< / table >
< / dd >
< / dl >
< dl class = "section note" > < dt > Note< / dt > < dd > On success the context memory itself is freed; the caller must not reuse the pointer. < / dd > < / dl >
2026-04-11 23:17:09 +01:00
< p class = "definition" > Definition at line < a class = "el" href = "close_8c_source.html#l00080" > 80< / a > of file < a class = "el" href = "close_8c_source.html" > close.c< / a > .< / p >
2025-10-11 01:35:43 +01:00
2026-04-11 23:17:09 +01:00
< p class = "reference" > References < a class = "el" href = "decls_8h_source.html#l00046" > AARU_CALL< / a > , < a class = "el" href = "decls_8h_source.html#l00055" > AARU_EXPORT< / a > , < a class = "el" href = "consts_8h_source.html#l00064" > AARU_MAGIC< / a > , < a class = "el" href = "ecc__cd_8c_source.html#l00099" > aaruf_ecc_cd_free()< / a > , < a class = "el" href = "close_8c_source.html#l00049" > aaruf_set_close_error()< / a > , < a class = "el" href = "errors_8h_source.html#l00081" > AARUF_STATUS_OK< / a > , < a class = "el" href = "context_8h_source.html#l00260" > aaruformat_context::block_cache< / a > , < a class = "el" href = "context_8h_source.html#l00259" > aaruformat_context::block_header_cache< / a > , < a class = "el" href = "context_8h_source.html#l00191" > aaruformat_context::cached_secondary_ddt2< / a > , < a class = "el" href = "context_8h_source.html#l00272" > aaruformat_context::checksums< / a > , < a class = "el" href = "context_8h_source.html#l00217" > aaruformat_context::cicm_block< / a > , < a class = "el" href = "context_8h_source.html#l00123" > mediaTagEntry::data< / a > , < a class = "el" href = "context_8h_source.html#l00246" > aaruformat_context::data_tracks< / a > , < a class = "el" href = "context_8h_source.html#l00215" > aaruformat_context::dump_hardware_entries_with_data< / a > , < a class = "el" href = "context_8h_source.html#l00235" > aaruformat_context::dump_hardware_header< / a > , < a class = "el" href = "erasure_8c_source.html#l00876" > ec_free()< / a > , < a class = "el" href = "context_8h_source.html#l00251" > aaruformat_context::ecc_cd_context< / a > , < a class = "el" href = "dump_8h_source.html#l00093" > DumpHardwareHeader::entries< / a > , < a class = "el" href = "context_8h_source.html#l00414" > DumpHardwareEntriesWithData::extents< / a > , < a class = "el" href = "log_8h_source.html#l00040" > FATAL< / a > , < a class = "el" href = "context_8h_source.html#l00299" > aaruformat_context::finalize_write< / a > , < a class = "el" href = "context_8h_source.html#l00418" > DumpHardwareEntriesWithData::firmware< / a > , < a class = "el" href = "lru_8c_source.html#l00082" > free_cache()< / a > , < a class = "el" href = "context_8h_source.html#l00179" > aaruformat_context::imageStream< / a > , < a class = "el" href = "context_8h_source.html#l00199" > aaruformat_context::in_memory_ddt< / a > , < a class = "el" href = "context_8h_source.html#l00255" > aaruformat_context::index_entries< / a > , < a class = "el" href = "context_8h_source.html#l00177" > aaruformat_context::magic< / a > , < a class = "el" href = "context_8h_source.html#l00415" > DumpHardwareEntriesWithData::manufacturer< / a > , < a class = "el" href = "context_8h_source.html#l00196" > aaruformat_context::mapped_memory_ddt_size< / a > , < a class = "el" href = "context_8h_source.html#l00267" > aaruformat_context::mediaTags< / a > , < a class = "el" href = "context_8h_source.html#l00216" > aaruformat_context::metadata_block< / a > , < a class = "el" href = "context_8h_source.html#l00207" > aaruformat_context::mode2_subheaders< / a > , < a class = "el" href = "context_8h_source.html#l00416" > DumpHardwareEntriesWithData::model< / a > , < a class = "el" href = "context_8h_source.html#l00364" > aaruformat_context::ngcw_junk_entries< / a > , < a class = "el" href = "context_8h_source.html#l00365" > aaruformat_context::ngcw_junk_entry_count< / a > , < a class = "el" href = "context_8h_source.html#l00367" > aaruformat_context::ngcw_junk_initialized< / a > , < a class = "el" href = "context_8h_source.html#l00366" > aaruformat_context::ngcw_junk_seed_size< / a > , < a class = "el" href = "context_8h_source.html#l00348" > aaruformat_context::ps3_disc_key< / a > , < a class = "el" href = "context_8h_source.html#l00351" > aaruformat_context::ps3_encryption_initialized< / a > , < a class = "el" href = "context_8h_source.html#l00350" > aaruformat_context::ps3_plaintext_region_count< / a > , < a class = "el" href = "context_8h_source.html#l00349" > aaruformat_context::ps3_plaintext_regions< / a > , < a class = "el" href = "context_8h_source.html#l00266" > aaruformat_context::readableSectorTags< / a > , < a class = "el" href = "context_8h_source.html#l00417" > DumpHardwareEntriesWithData::revision< / a > , < a class = "el" href = "context_8h_source.html#l00210" > aaruformat_context::sector_cpr_mai< / a > , < a class = "el" href = "context_8h_source.html#l00211" > aaruformat_context::sector_edc< / a > , < a class = "el" href = "context_8h_source.html#l00208" > aaruformat_context::sector_id< / a > , < a class = "el" href = "context_8h_source.ht
2025-10-11 01:35:43 +01:00
2026-04-11 23:17:09 +01:00
< p class = "reference" > Referenced by < a class = "el" href = "open_8c_source.html#l00236" > aaruf_open()< / a > .< / p >
2025-10-11 01:35:43 +01:00
< / div >
< / div >
2026-04-11 23:17:09 +01:00
< a id = "a547f7cbebffad90d0a60d8fd2ee1185a" name = "a547f7cbebffad90d0a60d8fd2ee1185a" > < / a >
< h2 class = "memtitle" > < span class = "permalink" > < a href = "#a547f7cbebffad90d0a60d8fd2ee1185a" > ◆   < / a > < / span > aaruf_set_close_error()< / h2 >
2025-10-11 01:35:43 +01:00
< div class = "memitem" >
< div class = "memproto" >
< table class = "mlabels" >
< tr >
< td class = "mlabels-left" >
< table class = "memname" >
< tr >
2026-04-11 23:17:09 +01:00
< td class = "memname" > void aaruf_set_close_error < / td >
2025-10-11 01:35:43 +01:00
< td > (< / td >
2026-04-11 23:17:09 +01:00
< td class = "paramtype" > const int< / td > < td class = "paramname" > < span class = "paramname" > < em > error_code< / em > < / span > < / td > < td > )< / td >
2025-10-11 01:35:43 +01:00
< td > < / td >
< / tr >
< / table >
< / td >
< td class = "mlabels-right" >
2026-04-11 23:17:09 +01:00
< span class = "mlabels" > < span class = "mlabel inline" > inline< / span > < span class = "mlabel static" > static< / span > < / span > < / td >
2025-10-11 01:35:43 +01:00
< / tr >
< / table >
< / div > < div class = "memdoc" >
2026-04-11 23:17:09 +01:00
< p class = "definition" > Definition at line < a class = "el" href = "close_8c_source.html#l00049" > 49< / a > of file < a class = "el" href = "close_8c_source.html" > close.c< / a > .< / p >
2025-10-11 01:35:43 +01:00
2026-04-11 23:17:09 +01:00
< p class = "reference" > Referenced by < a class = "el" href = "close_8c_source.html#l00080" > aaruf_close()< / a > .< / p >
2025-10-11 01:35:43 +01:00
< / div >
< / div >
< / div > <!-- contents -->
< / div > <!-- doc - content -->
< div id = "page-nav" class = "page-nav-panel" >
< div id = "page-nav-resize-handle" > < / div >
< div id = "page-nav-tree" >
< div id = "page-nav-contents" >
< / div > <!-- page - nav - contents -->
< / div > <!-- page - nav - tree -->
< / div > <!-- page - nav -->
< / div > <!-- container -->
<!-- start footer part -->
< div id = "nav-path" class = "navpath" > <!-- id is needed for treeview function! -->
< ul >
< li class = "navelem" > < a href = "dir_68267d1309a1af8e8297ef4c3efbcdba.html" > src< / a > < / li > < li class = "navelem" > < a href = "close_8c.html" > close.c< / a > < / li >
2026-04-11 23:17:09 +01:00
< li class = "footer" > Generated by < a href = "https://www.doxygen.org/index.html" > < img class = "footer" src = "doxygen.svg" width = "104" height = "31" alt = "doxygen" / > < / a > 1.16.1 < / li >
2025-10-11 01:35:43 +01:00
< / ul >
< / div >
< / body >
< / html >