YAZ
5.34.0
|
Implements Nibble Memory. More...
#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>
#include <yaz/snprintf.h>
Go to the source code of this file.
Data Structures | |
struct | nmem_block |
struct | nmem_control |
struct | align |
Macros | |
#define | NMEM_CHUNK (4*1024) |
#define | NMEM_ALIGN (offsetof(struct align, u)) |
Functions | |
static void | nmem_lock (void) |
static void | nmem_unlock (void) |
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 More... | |
void * | nmem_malloc (NMEM n, size_t size) |
allocates memory block on NMEM handle More... | |
size_t | nmem_total (NMEM n) |
returns size in bytes of memory for NMEM handle More... | |
void | nmem_init_globals (void) |
NMEM | nmem_create (void) |
returns new NMEM handle More... | |
void | nmem_destroy (NMEM n) |
destroys NMEM handle and memory associated with it More... | |
void | nmem_transfer (NMEM dst, NMEM src) |
transfers memory from one NMEM handle to another More... | |
int | nmem_get_status (char *dst, size_t l) |
returns memory status for NMEM - as XML More... | |
Variables | |
static size_t | no_nmem_handles = 0 |
static size_t | no_nmem_blocks = 0 |
static size_t | nmem_allocated = 0 |
static int | log_level = 0 |
static int | log_level_initialized = 0 |
Implements Nibble Memory.
This is a simple and fairly wasteful little module for nibble memory allocation.
Definition in file nmem.c.
|
static |
Definition at line 90 of file nmem.c.
References nmem_block::buf, log_level, nmem_allocated, nmem_lock(), nmem_unlock(), no_nmem_blocks, nmem_block::size, xfree, and yaz_log().
Referenced by nmem_reset().
|
static |
Definition at line 105 of file nmem.c.
References nmem_block::buf, log_level, nmem_allocated, NMEM_CHUNK, nmem_lock(), nmem_unlock(), no_nmem_blocks, 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 181 of file nmem.c.
References nmem_control::blocks, log_level, log_level_initialized, nmem_control::next, nmem_lock(), nmem_unlock(), no_nmem_handles, nmem_control::total, xmalloc, and yaz_log_module_level().
Referenced by ccl_stop_words_create(), construct_marc(), construct_rdf_lookup(), construct_select(), cql_parser_create(), cql_transform_create(), cql_transform_r(), odr_createmem(), odr_extract_mem(), xml_config_open(), yaz_file_glob2(), yaz_marc_create(), yaz_record_conv_create(), yaz_record_render(), yaz_solr_sortkeys_to_sort_spec(), yaz_srw_sortkeys_to_sort_spec(), and ZOOM_handle_Z3950_apdu().
void nmem_destroy | ( | NMEM | n | ) |
destroys NMEM handle and memory associated with it
n | NMEM handle |
Definition at line 204 of file nmem.c.
References nmem_lock(), nmem_reset(), nmem_unlock(), no_nmem_handles, and xfree.
Referenced by ccl_stop_words_destroy(), construct_marc(), construct_rdf_lookup(), construct_select(), cql_parser_destroy(), cql_transform_close(), cql_transform_r(), destroy_marc(), destroy_rdf_lookup(), destroy_select(), destroy_xslt(), handle_srw_response(), handle_srw_scan_response(), handle_Z3950_records(), handle_Z3950_scan_response(), odr_destroy(), request_release(), xml_config_close(), yaz_file_globfree(), yaz_marc_destroy(), yaz_record_conv_destroy(), yaz_record_render(), yaz_solr_sortkeys_to_sort_spec(), yaz_srw_sortkeys_to_sort_spec(), and ZOOM_handle_Z3950_apdu().
int nmem_get_status | ( | char * | dst, |
size_t | l | ||
) |
returns memory status for NMEM - as XML
dst | buffer for result |
l | size of buffer (200 should suffice) |
Definition at line 229 of file nmem.c.
References nmem_allocated, nmem_lock(), nmem_unlock(), no_nmem_blocks, no_nmem_handles, and yaz_snprintf().
void nmem_init_globals | ( | void | ) |
Definition at line 174 of file nmem.c.
References nmem_lock(), and nmem_unlock().
Referenced by yaz_init_globals().
|
static |
Definition at line 76 of file nmem.c.
Referenced by free_block(), get_block(), nmem_create(), nmem_destroy(), nmem_get_status(), and nmem_init_globals().
void* nmem_malloc | ( | NMEM | n, |
size_t | size | ||
) |
allocates memory block on NMEM handle
n | NMEM handle |
size | number of bytes to be allocated |
Definition at line 145 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_entry(), append_removed_item(), base64_render(), circulation(), circulations(), conf_retrieval(), construct_marc(), construct_one_rdf_lookup(), construct_rdf_lookup(), construct_select(), cql_node_mk_boolean(), cql_node_mk_sc(), cql_node_mk_sort(), cql_transform_parse_tok_line(), extract_user_pass(), gfs_listen_new(), gfs_server_new(), holdingsRecord(), nmem_booldup(), nmem_dup_xml_content(), nmem_intdup(), nmem_strdup(), nmem_strdupn(), nmem_strsplit_escape2(), nmem_text_node_cdata(), odr_getoidbystr_nmem(), odr_malloc(), odr_oiddup_nmem(), process_presentRequest(), process_searchRequest(), putb(), response_searchRequest(), sort_them(), volume(), volumes(), xml_config_read(), yaz_file_glob2(), yaz_get_proposal_charneg(), yaz_get_response_charneg(), yaz_marc_add_node(), yaz_marc_add_subfield(), yaz_marc_read_turbo_xml_fields(), yaz_marc_read_turbo_xml_subfields(), yaz_marc_read_xml_subfields(), yaz_record_conv_configure_t(), yaz_record_render(), yaz_set_esn(), yaz_xml_to_opac_ptr(), yylex(), and z_ext_record_oid_nmem().
void nmem_reset | ( | NMEM | n | ) |
releases memory associaged with an NMEM handle
n | NMEM handle |
Definition at line 129 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().
size_t nmem_total | ( | NMEM | n | ) |
returns size in bytes of memory for NMEM handle
Definition at line 169 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 216 of file nmem.c.
References nmem_control::blocks, nmem_block::next, and nmem_control::total.
Referenced by handle_srw_response(), handle_srw_scan_response(), handle_Z3950_records(), handle_Z3950_scan_response(), and process_searchRequest().
|
static |
Definition at line 83 of file nmem.c.
Referenced by free_block(), get_block(), nmem_create(), nmem_destroy(), nmem_get_status(), and nmem_init_globals().
|
static |
Definition at line 73 of file nmem.c.
Referenced by free_block(), get_block(), nmem_create(), and nmem_reset().
|
static |
Definition at line 74 of file nmem.c.
Referenced by nmem_create().
|
static |
Definition at line 37 of file nmem.c.
Referenced by free_block(), get_block(), and nmem_get_status().
|
static |
Definition at line 36 of file nmem.c.
Referenced by free_block(), get_block(), and nmem_get_status().
|
static |
Definition at line 35 of file nmem.c.
Referenced by nmem_create(), nmem_destroy(), and nmem_get_status().