YAZ
5.34.0
|
Header for Nibble Memory functions. More...
Go to the source code of this file.
Macros | |
#define | NMEM_64 1 |
Set to 1 if YAZ BER integer is 64-bit ; 0 otherwise. More... | |
#define | NMEM_INT_PRINTF "%lld" |
Typedefs | |
typedef struct nmem_control * | NMEM |
NMEM handle (an opaque pointer to memory) More... | |
typedef long long int | nmem_int_t |
typedef int | nmem_bool_t |
BER/utility boolean. More... | |
Functions | |
void | nmem_reset (NMEM n) |
releases memory associaged with an NMEM handle More... | |
size_t | nmem_total (NMEM n) |
returns size in bytes of memory for NMEM handle More... | |
char * | nmem_strdup (NMEM mem, const char *src) |
allocates string on NMEM handle (similar strdup) More... | |
char * | nmem_strdup_null (NMEM mem, const char *src) |
allocates string on NMEM handle - allows NULL ptr buffer More... | |
char * | nmem_strdupn (NMEM mem, const char *src, size_t n) |
allocates string of certain size on NMEM handle More... | |
void | nmem_strsplit (NMEM nmem, const char *delim, const char *dstr, char ***darray, int *num) |
allocates sub strings out of string using certain delimitors More... | |
void | nmem_strsplitx (NMEM nmem, const char *delim, const char *dstr, char ***darray, int *num, int collapse) |
allocates sub strings out of string using certain delimitors More... | |
void | nmem_strsplit_blank (NMEM nmem, const char *dstr, char ***darray, int *num) |
splits string into sub strings delimited by blanks More... | |
void | nmem_strsplit_escape (NMEM nmem, const char *delim, const char *dstr, char ***darray, int *num, int collapse, int escape_char) |
allocates sub strings out of string using certain delimitors More... | |
void | nmem_strsplit_escape2 (NMEM nmem, const char *delim, const char *dstr, char ***darray, int *num, int collapse, int escape_char, int subst_escape) |
allocates sub strings out of string using certain delimitors More... | |
nmem_int_t * | nmem_intdup (NMEM nmem, nmem_int_t v) |
allocates and sets integer for NMEM More... | |
nmem_bool_t * | nmem_booldup (NMEM nmem, nmem_bool_t v) |
allocates and sets boolean for NMEM More... | |
void | nmem_transfer (NMEM dst, NMEM src) |
transfers memory from one NMEM handle to another More... | |
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_malloc (NMEM n, size_t size) |
allocates memory block on NMEM handle More... | |
int | nmem_get_status (char *dst, size_t l) |
returns memory status for NMEM - as XML More... | |
Header for Nibble Memory functions.
This is a simple and fairly wasteful little module for nibble memory allocation. Eventually we'll put in something better.
Definition in file nmem.h.
#define NMEM_64 1 |
typedef struct nmem_control* NMEM |
typedef int nmem_bool_t |
typedef long long int nmem_int_t |
nmem_bool_t* nmem_booldup | ( | NMEM | nmem, |
nmem_bool_t | v | ||
) |
allocates and sets boolean for NMEM
nmem | NMEM handle |
v | value (0=false, != 0 true) |
Definition at line 48 of file nmemsdup.c.
References nmem_malloc().
Referenced by match_v_next(), and odr_booldup().
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().
nmem_int_t* nmem_intdup | ( | NMEM | nmem, |
nmem_int_t | v | ||
) |
allocates and sets integer for NMEM
nmem | NMEM handle |
v | integer value |
Definition at line 41 of file nmemsdup.c.
References nmem_malloc().
Referenced by cql_transform_parse_tok_line(), and odr_intdup().
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().
char* nmem_strdup | ( | NMEM | mem, |
const char * | src | ||
) |
allocates string on NMEM handle (similar strdup)
mem | HNEM handle |
src | string |
Definition at line 18 of file nmemsdup.c.
References nmem_malloc().
Referenced by add_entry(), append_removed_item(), conf_retrieval(), construct_marc(), construct_one_rdf_lookup(), construct_rdf_lookup(), construct_select(), cql_apply_prefix(), cql_node_dup(), cql_node_mk_boolean(), cql_node_mk_sc(), cql_node_mk_sort(), cql_transform_parse_tok_line(), element_attribute_value_extract(), extract_user_pass(), gfs_listen_new(), nmem_strdup_null(), odr_strdup(), yaz_get_proposal_charneg(), yaz_get_response_charneg(), yaz_marc_add_comment(), yaz_marc_add_controlfield(), yaz_marc_add_datafield(), yaz_marc_add_datafield_xml(), yaz_match_xsd_string_n_nmem(), yaz_set_esn(), and yyparse().
char* nmem_strdup_null | ( | NMEM | mem, |
const char * | src | ||
) |
allocates string on NMEM handle - allows NULL ptr buffer
mem | HNEM handle |
src | string |
Definition at line 25 of file nmemsdup.c.
References nmem_strdup().
Referenced by gfs_server_new(), and odr_strdup_null().
char* nmem_strdupn | ( | NMEM | mem, |
const char * | src, | ||
size_t | n | ||
) |
allocates string of certain size on NMEM handle
mem | NMEM handle |
src | string |
n | size of string |
Definition at line 33 of file nmemsdup.c.
References nmem_malloc().
Referenced by extract_user_pass(), nmem_strsplit_escape2(), odr_strdupn(), yaz_marc_add_controlfield(), yaz_marc_add_datafield(), yaz_marc_add_leader(), yaz_marc_add_subfield(), and yaz_record_render().
void nmem_strsplit | ( | NMEM | nmem, |
const char * | delim, | ||
const char * | dstr, | ||
char *** | darray, | ||
int * | num | ||
) |
allocates sub strings out of string using certain delimitors
nmem | NMEM handle |
delim | delimitor chars (splits on each char in there) |
dstr | string to be split |
darray | result string array for each sub string |
num | number of result strings |
Definition at line 61 of file nmemsdup.c.
References nmem_strsplitx().
Referenced by nmem_strsplit_blank(), xml_config_read(), yaz_pqf_parse_facet_list(), yaz_set_proposal_charneg_list(), yaz_solr_sortkeys_to_sort_spec(), and ZOOM_connection_get_databases().
void nmem_strsplit_blank | ( | NMEM | nmem, |
const char * | dstr, | ||
char *** | darray, | ||
int * | num | ||
) |
splits string into sub strings delimited by blanks
nmem | NMEM handle |
dstr | string to be split |
darray | result string array for each sub string |
num | number of result strings |
Definition at line 55 of file nmemsdup.c.
References nmem_strsplit().
Referenced by yaz_srw_sortkeys_to_sort_spec().
void nmem_strsplit_escape | ( | NMEM | nmem, |
const char * | delim, | ||
const char * | dstr, | ||
char *** | darray, | ||
int * | num, | ||
int | collapse, | ||
int | escape_char | ||
) |
allocates sub strings out of string using certain delimitors
nmem | NMEM handle |
delim | delimitor chars (splits on each char in there) |
dstr | string to be split |
darray | result string array for each sub string |
num | number of result strings |
collapse | 1=collapse multiple delims to one; 0=no collapse |
escape_char | != 0, an escape char (could be ) |
Definition at line 73 of file nmemsdup.c.
References nmem_strsplit_escape2().
Referenced by nmem_strsplitx().
void nmem_strsplit_escape2 | ( | NMEM | nmem, |
const char * | delim, | ||
const char * | dstr, | ||
char *** | darray, | ||
int * | num, | ||
int | collapse, | ||
int | escape_char, | ||
int | subst_escape | ||
) |
allocates sub strings out of string using certain delimitors
nmem | NMEM handle |
delim | delimitor chars (splits on each char in there) |
dstr | string to be split |
darray | result string array for each sub string |
num | number of result strings |
collapse | 1=collapse multiple delims to one; 0=no collapse |
escape_char | != 0, an escape char (could be ) |
subst_escape | 1=substitute escapes, 0 leave as is |
Definition at line 81 of file nmemsdup.c.
References nmem_malloc(), and nmem_strdupn().
Referenced by nmem_strsplit_escape().
void nmem_strsplitx | ( | NMEM | nmem, |
const char * | delim, | ||
const char * | dstr, | ||
char *** | darray, | ||
int * | num, | ||
int | collapse | ||
) |
allocates sub strings out of string using certain delimitors
nmem | NMEM handle |
delim | delimitor chars (splits on each char in there) |
dstr | string to be split |
darray | result string array for each sub string |
num | number of result strings |
collapse | 1=collapse multiple delims to one; 0=no collapse |
Definition at line 67 of file nmemsdup.c.
References nmem_strsplit_escape().
Referenced by nmem_strsplit(), yaz_solr_sortkeys_to_sort_spec(), and yaz_srw_sortkeys_to_sort_spec().
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().