2006-02-10 01:50:20 +10:00
/**
\ file halloc_util . h
Various halloc - related utility functions .
*/
# ifndef FISH_HALLOC_UTIL_H
# define FISH_HALLOC_UTIL_H
2006-02-19 11:54:38 +10:00
/**
This pointer is a valid halloc context that will be freed right
before program shutdown . It may be used to allocate memory that
should be freed when the program shuts down .
*/
2006-02-10 01:50:20 +10:00
extern void * global_context ;
2006-02-19 11:54:38 +10:00
/**
Create the global_context halloc object
*/
2006-02-10 01:50:20 +10:00
void halloc_util_init ( ) ;
2006-02-19 11:54:38 +10:00
/**
Free the global_context halloc object
*/
2006-02-10 01:50:20 +10:00
void halloc_util_destroy ( ) ;
2006-02-19 11:54:38 +10:00
/**
Allocate a array_list_t that will be automatically disposed of when
the specified context is free ' d
*/
2006-02-10 01:50:20 +10:00
array_list_t * al_halloc ( void * context ) ;
2006-02-19 11:54:38 +10:00
/**
Allocate a string_buffer_t that will be automatically disposed of
when the specified context is free ' d
*/
2006-02-10 01:50:20 +10:00
string_buffer_t * sb_halloc ( void * context ) ;
2006-02-19 11:54:38 +10:00
/**
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 .
*/
2006-02-10 01:50:20 +10:00
void halloc_register_function_void ( void * context , void ( * func ) ( ) ) ;
2006-02-19 11:54:38 +10:00
2006-02-10 01:50:20 +10:00
/**
Free the memory pointed to by \ c data when the memory pointed to by
\ c context is free : d . Note that this will _not_ turn the specified
memory area into a valid halloc context . Only memory areas created
2006-02-19 11:54:38 +10:00
using a call to halloc ( 0 , size ) can be used as a context .
2006-02-10 01:50:20 +10:00
*/
void * halloc_register ( void * context , void * data ) ;
2006-02-11 10:13:17 +10:00
2006-02-19 11:54:38 +10:00
/**
Make a copy of the specified string using memory allocated using
halloc and the specified context
*/
2006-06-13 00:12:33 +10:00
wchar_t * halloc_wcsdup ( void * context , const wchar_t * str ) ;
2006-02-11 10:13:17 +10:00
2006-02-19 11:54:38 +10:00
/**
Make a copy of the specified substring using memory allocated using
halloc and the specified context
*/
wchar_t * halloc_wcsndup ( void * context , const wchar_t * in , int c ) ;
2006-02-11 10:13:17 +10:00
2006-02-10 01:50:20 +10:00
# endif