Something went wrong. Try again.
forked from cz-nic/bird
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445<!-- BIRD Programmer's Guide: Resources
(c) 2000 Martin Mares <mj@ucw.cz>-->
<chapt>Resources<label id="resources">
<sect>Introduction<label id="resources-introduction">
<p>Most large software projects implemented in classical proceduralprogramming languages usually end up with lots of code taking careof resource allocation and deallocation. Bugs in such code are oftenvery difficult to find, because they cause only `resource leakage',that is keeping a lot of memory and other resources which nobodyreferences to.
<p>We've tried to solve this problem by employing a resource trackingsystem which keeps track of all the resources allocated by all themodules of BIRD, deallocates everything automatically when a moduleshuts down and it is able to print out the list of resources andthe corresponding modules they are allocated by.
<p>Each allocated resource (from now we'll speak about allocatedresources only) is represented by a structure starting with a standardheader (struct <struct/resource/) consisting of a list node (resources areoften linked to various lists) and a pointer to <struct/resclass/ -- a resourceclass structure pointing to functions implementing generic resourceoperations (such as freeing of the resource) for the particular resourcetype.
<p>There exist the following types of resources:
<itemize><item><it/Resource pools/ (<struct/pool/)<item><it/Memory blocks/<item><it/Linear memory pools/ (<struct/linpool/)<item><it/Slabs/ (<struct/slab/)<item><it/Events/ (<struct/event/) <item><it/Timers/ (<struct/timer/) <item><it/Sockets/ (<struct/socket/) </itemize>