halloc_util.c File Reference

A hierarchical memory allocation system. More...

#include "config.h"
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include "fallback.h"
#include "util.h"
#include "common.h"
#include "halloc.h"

This graph shows which files directly or indirectly include this file:

Functions

void halloc_util_init ()
 Create the global_context halloc object.
void halloc_util_destroy ()
 Free the global_context halloc object.
array_list_tal_halloc (void *context)
 Allocate a array_list_t that will be automatically disposed of when the specified context is free'd.
string_buffer_tsb_halloc (void *context)
 Allocate a string_buffer_t that will be automatically disposed of when the specified context is free'd.
static void halloc_passthrough (void *f)
 A function that takes a single parameter, which is a function pointer, and calls it.
void halloc_register_function_void (void *context, void(*func)())
 Register the specified function to run when the specified context is free'd.
void * halloc_register (void *context, void *data)
 Free the memory pointed to by data when the memory pointed to by context is free:d.
wchar_t * halloc_wcsdup (void *context, const wchar_t *in)
 Make a copy of the specified string using memory allocated using halloc and the specified context.
wchar_t * halloc_wcsndup (void *context, const wchar_t *in, int c)
 Make a copy of the specified substring using memory allocated using halloc and the specified context.

Variables

void * global_context = 0
 This pointer is a valid halloc context that will be freed right before program shutdown.

Detailed Description

A hierarchical memory allocation system.

Works just like talloc used in Samba, except that an arbitrary block allocated with malloc() can be registered to be freed by halloc_free.


Function Documentation

void* halloc_register ( void *  context,
void *  data 
)

Free the memory pointed to by data when the memory pointed to by context is free:d.

Note that this will _not_ turn the specified memory area into a valid halloc context. Only memory areas created using a call to halloc( 0, size ) can be used as a context.

References halloc_register_function().

Referenced by builtin_block(), builtin_for(), exec(), expand_one(), expand_string(), is_potential_path(), parse_job(), parse_job_argument_list(), and path_get_cdpath().

void halloc_register_function_void ( void *  context,
void(*)()  func 
)

Register the specified function to run when the specified context is free'd.

This function is related to halloc_register_function, but the specified function dowes not take an argument.

References halloc_passthrough(), and halloc_register_function().

Referenced by complete_get_desc_suffix(), complete_init(), parse_util_load(), parser_push_block(), wgettext_init(), and writestr().


Variable Documentation

void* global_context = 0


Generated on Sun Mar 8 15:46:54 2009 for fish by  doxygen 1.5.6