'\"macro stdmacro
.if n .pH g3e.elf_end @(#)elf_end	40.11 of 10/27/89
.\" Copyright 1989 AT&T
.\"#ident	"@(#)ci5-doc:req/libelf/end.man	1.3"
.nr X
.if \nX=0 .ds x} elf_end 3E "ELF Library" "\&"
.if \nX=1 .ds x} elf_end 3E "ELF Library"
.if \nX=2 .ds x} elf_end 3E "" "\&"
.if \nX=3 .ds x} elf_end "" "" "\&"
.TH \*(x}
.SH NAME
\f4elf_end\f1 \- finish using an object file
.SH SYNOPSIS
\f4cc\f1
[\f2flag\fP \|.\|.\|.] \f2file\fP \|.\|.\|.
\f4\-lelf\f1
[\f2library\fP \|.\|.\|.]
.PP
.nf
.na
.ft 4
#include <libelf.h>
.sp 0.5
int elf_end(Elf \(**elf);
.ft 1
.ad
.fi
.SH DESCRIPTION
A program uses
\f4elf_end\fP
to terminate an
.SM ELF
descriptor,
.IR elf ,
and to deallocate data associated with the descriptor.
Until the program terminates a descriptor, the
data remain allocated.
.I elf
should be a value previously returned by
\f4elf_begin\fP;
a null pointer is allowed as an argument, to simplify error handling.
If the program wishes to write data associated with the
.SM ELF
descriptor to the file, it must use
\f4elf_update\fP
before calling
\f4elf_end\fP.
.P
As
\f4elf_begin\fP(3E)
explains, a descriptor can have more than one activation.
Calling
\f4elf_end\fP
removes one activation and returns the remaining activation count.
The library does not
terminate the descriptor until the activation count reaches zero.
Consequently, a zero return value indicates the
.SM ELF
descriptor is no longer valid.
.SH "SEE ALSO"
.na
\f4elf\fP(3E),
\f4elf_begin\fP(3E),
\f4elf_update\fP(3E).
