YAZ  5.23.1
Macros | Functions
xmalloc.h File Reference

Header for memory handling functions. More...

#include <stddef.h>
#include <yaz/yconfig.h>

Go to the source code of this file.

Macros

#define xrealloc(o, x)   xrealloc_f(o, x, __FILE__, __LINE__)
 utility macro which calls xrealloc_f More...
 
#define xmalloc(x)   xmalloc_f(x, __FILE__, __LINE__)
 utility macro which calls malloc_f More...
 
#define xcalloc(x, y)   xcalloc_f(x,y, __FILE__, __LINE__)
 utility macro which calls xcalloc_f More...
 
#define xfree(x)   xfree_f(x, __FILE__, __LINE__)
 utility macro which calls xfree_f More...
 
#define xstrdup(s)   xstrdup_f(s, __FILE__, __LINE__)
 utility macro which calls xstrdup_f More...
 
#define xstrndup(s, n)   xstrndup_f(s, n, __FILE__, __LINE__)
 utility macro which calls xstrndup_f More...
 
#define xmalloc_trav(s)   xmalloc_trav_f(s, __FILE__, __LINE__)
 utility macro which calls malloc_trav_f More...
 

Functions

void * xrealloc_f (void *o, size_t size, const char *file, int line)
 realloc More...
 
void * xmalloc_f (size_t size, const char *file, int line)
 malloc More...
 
void * xcalloc_f (size_t nmemb, size_t size, const char *file, int line)
 calloc More...
 
char * xstrdup_f (const char *p, const char *file, int line)
 strdup More...
 
char * xstrndup_f (const char *p, size_t n, const char *file, int line)
 strndup More...
 
void xfree_f (void *p, const char *file, int line)
 free More...
 
void xmalloc_trav_f (const char *s, const char *file, int line)
 logs all xmalloc buffers More...
 

Detailed Description

Header for memory handling functions.

This is a set of wrapper functions for the memory allocation routines from stdlib.h.. Such as malloc, free, realloc etc. These functions calls exit if memory allocation fails.

Definition in file xmalloc.h.

Macro Definition Documentation

#define xcalloc (   x,
  y 
)    xcalloc_f(x,y, __FILE__, __LINE__)

utility macro which calls xcalloc_f

Definition at line 51 of file xmalloc.h.

#define xfree (   x)    xfree_f(x, __FILE__, __LINE__)

utility macro which calls xfree_f

Definition at line 53 of file xmalloc.h.

Referenced by assoc_init_reset(), bend_close(), ccl_parser_destroy(), ccl_qual_add_special_ar(), ccl_qual_field2(), ccl_qual_rm(), ccl_rpn_delete(), ccl_set_attr_numeric(), ccl_stop_words_destroy(), ccl_token_del(), control_association(), cql_parser_destroy(), cql_transform_close(), cql_transform_open_FILE(), cs_create_host2(), cs_parse_host(), destroy_ar(), destroy_association(), destroy_danmarc(), destroy_iso5426(), destroy_iso_8859_1(), destroy_marc8(), free_block(), get_cert(), handle_http(), iochan_event_loop(), json_parser_destroy(), json_remove_node(), my_close(), nmem_destroy(), odr_destroy(), qualifier_list(), rdf_lookup_node(), remove_sets(), request_delq(), response_default_diag(), resultset_destroy(), search_term_split_list(), send_HTTP_redirect(), tcpip_accept(), tcpip_close(), tcpip_rcvconnect(), tcpip_straddr(), unix_accept(), unix_close(), unix_straddr(), wrbuf_destroy(), yaz_cookies_destroy(), yaz_cookies_reset(), yaz_cookies_response(), yaz_iconv_close(), yaz_marc_destroy(), yaz_marc_leader_spec(), yaz_mime_types_destroy(), yaz_oid_db_destroy(), yaz_poll_select(), yaz_pqf_destroy(), yaz_record_conv_destroy(), yaz_record_conv_set_path(), yaz_retrieval_destroy(), yaz_retrieval_set_path(), yaz_sc_destroy(), yaz_spipe_create(), yaz_spipe_destroy(), yaz_thread_create(), yaz_thread_detach(), yaz_thread_join(), yaz_timing_destroy(), yaz_tok_cfg_destroy(), yaz_tok_cfg_single_tokens(), yaz_tok_parse_destroy(), yaz_url_destroy(), yaz_url_exec(), yaz_url_set_proxy(), yaz_xml_get_prop(), ZOOM_connection_connect(), ZOOM_connection_destroy(), ZOOM_connection_remove_task(), ZOOM_Event_destroy(), ZOOM_event_sys_yaz_poll(), ZOOM_handle_Z3950_apdu(), ZOOM_options_destroy(), ZOOM_options_setl(), ZOOM_package_destroy(), ZOOM_package_send(), ZOOM_query_cql(), ZOOM_query_cql2rpn(), ZOOM_query_destroy(), ZOOM_query_prefix(), ZOOM_record_destroy(), ZOOM_scanset_destroy(), ZOOM_set_dset_error(), and ztest_search().

#define xmalloc (   x)    xmalloc_f(x, __FILE__, __LINE__)

utility macro which calls malloc_f

Definition at line 49 of file xmalloc.h.

Referenced by add_attr_node(), append_entry(), assoc_init_reset(), bend_init(), ccl_parser_create(), ccl_parser_tokenize(), ccl_qual_add_combi(), ccl_qual_add_set(), ccl_qual_add_special(), ccl_qual_add_special_ar(), ccl_qual_dup(), ccl_qual_mk(), ccl_qual_new(), ccl_rpn_node_create(), ccl_stop_words_create(), ccl_term_one_use(), ccl_token_add(), connect_and_bind(), copy_token_name(), cql_parser_create(), cql_transform_create(), cql_transform_parse_tok_line(), create_ar(), create_association(), cs_parse_host(), get_block(), iochan_create(), iochan_event_loop(), json_new_node(), json_parse_string(), json_parser_create(), json_parser_subst(), my_init(), nmem_create(), odr_createmem(), odr_grow_block(), qualifier_list(), rdf_lookup_node(), request_get(), search_term_split_list(), search_terms(), set_value(), tcpip_accept(), tcpip_get(), tcpip_state_create(), tcpip_type(), unix_accept(), unix_get(), unix_type(), wrbuf_alloc(), yaz_cookies_create(), yaz_cookies_response(), yaz_danmarc_decoder(), yaz_iconv_open(), yaz_iso5426_decoder(), yaz_iso_8859_1_encoder(), yaz_marc8_decoder(), yaz_marc8_encoder(), yaz_marc_create(), yaz_mime_types_add(), yaz_mime_types_create(), yaz_oid_add(), yaz_oid_db_new(), yaz_poll_select(), yaz_pqf_create(), yaz_record_conv_create(), yaz_retrieval_create(), yaz_sc_create(), yaz_spipe_create(), yaz_tcpip_create(), yaz_thread_create(), yaz_timing_create(), yaz_tok_cfg_create(), yaz_tok_parse_create(), yaz_url_create(), yaz_xml_get_prop(), ZOOM_connection_add_task(), ZOOM_connection_connect(), ZOOM_connection_create(), ZOOM_connection_insert_task(), ZOOM_connection_package(), ZOOM_connection_scan1(), ZOOM_Event_create(), ZOOM_event_sys_yaz_poll(), ZOOM_options_create_with_parent2(), ZOOM_package_send(), ZOOM_query_create(), ZOOM_record_clone(), ZOOM_resultset_create(), ZOOM_set_dset_error(), and ztest_search().

#define xmalloc_trav (   s)    xmalloc_trav_f(s, __FILE__, __LINE__)

utility macro which calls malloc_trav_f

Definition at line 59 of file xmalloc.h.

Referenced by destroy_association().

#define xrealloc (   o,
 
)    xrealloc_f(o, x, __FILE__, __LINE__)

utility macro which calls xrealloc_f

Definition at line 47 of file xmalloc.h.

Referenced by ccl_qual_add_special(), odr_grow_block(), tcpip_get(), unix_get(), and wrbuf_grow().

#define xstrdup (   s)    xstrdup_f(s, __FILE__, __LINE__)
#define xstrndup (   s,
 
)    xstrndup_f(s, n, __FILE__, __LINE__)

utility macro which calls xstrndup_f

Definition at line 57 of file xmalloc.h.

Referenced by yaz_cookies_response().

Function Documentation

void* xcalloc_f ( size_t  nmemb,
size_t  size,
const char *  file,
int  line 
)

calloc

Parameters
nmembnumber of members
sizesize of member
filefname location of use
lineline location of use
Returns
buffer

This function is invoked via macro xcalloc in which file and line are set automatically.

Definition at line 302 of file xmalloc.c.

References log_level, log_level_initialized, xcalloc_d, xmalloc_fatal(), yaz_log(), yaz_log_module_level(), and YLOG_FATAL.

void xfree_f ( void *  p,
const char *  file,
int  line 
)

free

Parameters
pstring to be freed (might be NULL)
filefname location of use
lineline location of use

This function is invoked via macro xfree in which file and line are set automatically.

Definition at line 341 of file xmalloc.c.

References log_level, xfree_d, and yaz_log().

void* xmalloc_f ( size_t  size,
const char *  file,
int  line 
)

malloc

Parameters
sizesize of buffer to be allocated
filefname location of use
lineline location of use
Returns
buffer

This function is invoked via macro xmalloc in which file and line are set automatically.

Definition at line 279 of file xmalloc.c.

References log_level, log_level_initialized, xmalloc_d, xmalloc_fatal(), yaz_log(), yaz_log_module_level(), and YLOG_FATAL.

Referenced by xstrndup_f().

void xmalloc_trav_f ( const char *  s,
const char *  file,
int  line 
)

logs all xmalloc buffers

Parameters
snot used
filefname location of use
lineline location of use

This function is invoked via macro xmalloc_trav in which file and line are set automatically. Only if TRACE_XMALLOC > 1 this function does any real work!

Definition at line 240 of file xmalloc.c.

References log_level, log_level_initialized, xmalloc_trav_d, and yaz_log_module_level().

void* xrealloc_f ( void *  o,
size_t  size,
const char *  file,
int  line 
)

realloc

Parameters
obuffer to be reallocated
sizesize of buffer to be allocated
filefname location of use
lineline location of use
Returns
buffer

This function is invoked via macro xrealloc in which file and line are set automatically.

Definition at line 257 of file xmalloc.c.

References log_level, log_level_initialized, xmalloc_fatal(), xrealloc_d, yaz_log(), yaz_log_module_level(), and YLOG_FATAL.

char* xstrdup_f ( const char *  p,
const char *  file,
int  line 
)

strdup

Parameters
pstring to be cloned
filefname location of use
lineline location of use
Returns
resulting string

This function is invoked via macro xstrdup in which file and line are set automatically.

Definition at line 324 of file xmalloc.c.

References log_level, log_level_initialized, xmalloc_d, yaz_log(), and yaz_log_module_level().

Referenced by xstrndup_f().

char* xstrndup_f ( const char *  p,
size_t  n,
const char *  file,
int  line 
)

strndup

Parameters
pstring to be cloned
nmax size of resulting string (excluding 0)
filefname location of use
lineline location of use
Returns
resulting string

This function is invoked via macro xstrndup in which file and line are set automatically.

Definition at line 350 of file xmalloc.c.

References xmalloc_f(), and xstrdup_f().