#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <stddef.h>
#include <yaz/xmalloc.h>
#include <yaz/nmem.h>
#include <yaz/log.h>
Go to the source code of this file.
Data Structures | |
| struct | nmem_block |
| struct | nmem_control |
| struct | align |
Defines | |
| #define | NMEM_CHUNK (4*1024) |
| #define | NMEM_ALIGN (offsetof(struct align, u)) |
Functions | |
| static void | free_block (struct nmem_block *p) |
| static struct nmem_block * | get_block (size_t size) |
| void | nmem_reset (NMEM n) |
| releases memory associaged with an NMEM handle | |
| void * | nmem_malloc (NMEM n, int size) |
| allocates memory block on NMEM handle | |
| int | nmem_total (NMEM n) |
| returns size in bytes of memory for NMEM handle | |
| NMEM | nmem_create (void) |
| returns new NMEM handle | |
| void | nmem_destroy (NMEM n) |
| destroys NMEM handle and memory associated with it | |
| void | nmem_transfer (NMEM dst, NMEM src) |
| transfers memory from one NMEM handle to another | |
| int | yaz_errno (void) |
| void | yaz_set_errno (int v) |
| void | yaz_strerror (char *buf, int max) |
Variables | |
| static int | log_level = 0 |
| static int | log_level_initialized = 0 |
This is a simple and fairly wasteful little module for nibble memory allocation. Evemtually we'll put in something better.
FIXME - it also has some semaphore stuff, and stuff to handle errno. These should be moved to some other place!
Definition in file nmem.c.
| #define NMEM_ALIGN (offsetof(struct align, u)) |
| #define NMEM_CHUNK (4*1024) |
| static void free_block | ( | struct nmem_block * | p | ) | [static] |
Definition at line 70 of file nmem.c.
References nmem_block::buf, log_level, xfree, and yaz_log().
Referenced by nmem_reset().
| static struct nmem_block* get_block | ( | size_t | size | ) | [static, read] |
Definition at line 81 of file nmem.c.
References nmem_block::buf, log_level, NMEM_CHUNK, nmem_block::size, nmem_block::top, xmalloc, and yaz_log().
Referenced by nmem_malloc().
| NMEM nmem_create | ( | void | ) |
returns new NMEM handle
Definition at line 147 of file nmem.c.
References nmem_control::blocks, log_level, log_level_initialized, nmem_control::next, nmem_control::total, xmalloc, and yaz_log_module_level().
Referenced by bend_request_mk(), ccl_stop_words_create(), cql_parser_create(), cql_transform(), cql_transform_create(), odr_createmem(), odr_extract_mem(), recv_apdu(), xml_config_open(), yaz_marc_create(), and yaz_record_conv_create().
| void nmem_destroy | ( | NMEM | n | ) |
destroys NMEM handle and memory associated with it
| n | NMEM handle |
Definition at line 165 of file nmem.c.
References nmem_reset(), and xfree.
Referenced by bend_request_destroy(), ccl_stop_words_destroy(), cql_parser_destroy(), cql_transform(), cql_transform_close(), handle_records(), handle_srw_response(), handle_srw_scan_response(), ir_session(), odr_destroy(), recv_apdu(), scan_response(), xml_config_close(), yaz_marc_destroy(), and yaz_record_conv_destroy().
| void* nmem_malloc | ( | NMEM | n, | |
| int | size | |||
| ) |
allocates memory block on NMEM handle
| n | NMEM handle | |
| size | number of bytes to be allocated |
Definition at line 118 of file nmem.c.
References nmem_control::blocks, nmem_block::buf, get_block(), nmem_block::next, NMEM_ALIGN, nmem_block::size, nmem_block::top, nmem_control::total, yaz_log(), and YLOG_FATAL.
Referenced by add_rule(), append_removed_item(), conf_retrieval(), cql_node_mk_boolean(), cql_node_mk_sc(), cql_transform_parse_tok_line(), gfs_listen_new(), gfs_server_new(), nmem_dup_xml_content(), nmem_intdup(), nmem_strdup(), nmem_strdupn(), nmem_strsplit(), nmem_text_node_cdata(), odr_getoidbystr_nmem(), odr_malloc(), odr_oiddup_nmem(), process_presentRequest(), process_searchRequest(), putb(), response_searchRequest(), save_referenceId(), xml_config_read(), yaz_get_proposal_charneg(), yaz_get_response_charneg(), yaz_marc_add_node(), yaz_marc_add_subfield(), yaz_marc_read_xml_subfields(), yaz_set_esn(), and yylex().
| void nmem_reset | ( | NMEM | n | ) |
releases memory associaged with an NMEM handle
| n | NMEM handle |
Definition at line 102 of file nmem.c.
References nmem_control::blocks, free_block(), log_level, nmem_block::next, nmem_control::total, and yaz_log().
Referenced by ccl_stop_words_tree(), cql_parser_stream(), nmem_destroy(), odr_reset(), yaz_marc_reset(), and yaz_record_conv_reset().
| int nmem_total | ( | NMEM | n | ) |
returns size in bytes of memory for NMEM handle
Definition at line 142 of file nmem.c.
References nmem_control::total.
Referenced by odr_total().
transfers memory from one NMEM handle to another
| src | source NMEM handle | |
| dst | destination NMEM handle |
Definition at line 174 of file nmem.c.
References nmem_control::blocks, nmem_block::next, and nmem_control::total.
Referenced by handle_records(), handle_srw_response(), handle_srw_scan_response(), process_searchRequest(), scan_response(), yaz_copy_Z_Query(), and yaz_copy_z_RPNQuery().
| int yaz_errno | ( | void | ) |
Definition at line 187 of file nmem.c.
Referenced by iochan_event_loop(), statserv_sc_main(), tcpip_connect(), tcpip_get(), tcpip_listen(), tcpip_put(), unix_bind(), unix_connect(), unix_get(), unix_listen(), unix_put(), yaz_iconv(), and yaz_strerror().
| void yaz_set_errno | ( | int | v | ) |
| void yaz_strerror | ( | char * | buf, | |
| int | max | |||
| ) |
Definition at line 197 of file nmem.c.
References log_level, log_level_initialized, yaz_errno(), and yaz_log_module_level().
Referenced by yaz_log().
int log_level_initialized = 0 [static] |
1.5.6