nmem.h File Reference

Header for Nibble Memory functions. More...

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

Go to the source code of this file.

Typedefs

typedef struct nmem_controlNMEM
 NMEM handle (an opaque pointer to memory).

Functions

void nmem_reset (NMEM n)
 releases memory associaged with an NMEM handle
int nmem_total (NMEM n)
 returns size in bytes of memory for NMEM handle
char * nmem_strdup (NMEM mem, const char *src)
 allocates string on NMEM handle (similar strdup)
char * nmem_strdup_null (NMEM mem, const char *src)
 allocates string on NMEM handle - allows NULL ptr buffer
char * nmem_strdupn (NMEM mem, const char *src, size_t n)
 allocates string of certain size on NMEM handle
void nmem_strsplit (NMEM nmem, const char *delim, const char *dstr, char ***darray, int *num)
 allocates sub strings out of string using certain delimitors
void nmem_strsplit_blank (NMEM nmem, const char *dstr, char ***darray, int *num)
 splits string into sub strings delimited by blanks
int * nmem_intdup (NMEM nmem, int v)
 allocates integer for NMEM
void nmem_transfer (NMEM dst, NMEM src)
 transfers memory from one NMEM handle to another
NMEM nmem_create (void)
 returns new NMEM handle
void nmem_destroy (NMEM n)
 destroys NMEM handle and memory associated with it
void * nmem_malloc (NMEM n, int size)
 allocates memory block on NMEM handle
int yaz_errno (void)
void yaz_set_errno (int v)
void yaz_strerror (char *buf, int max)


Detailed Description

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.


Typedef Documentation

typedef struct nmem_control* NMEM

NMEM handle (an opaque pointer to memory).

Definition at line 44 of file nmem.h.


Function Documentation

NMEM nmem_create ( void   ) 

void nmem_destroy ( NMEM  n  ) 

destroys NMEM handle and memory associated with it

Parameters:
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(), ir_session(), odr_destroy(), yaz_marc_destroy(), and yaz_record_conv_destroy().

int* nmem_intdup ( NMEM  nmem,
int  v 
)

allocates integer for NMEM

Parameters:
nmem NMEM handle
v integer value
Returns:
pointer to created integer

Definition at line 41 of file nmemsdup.c.

References nmem_malloc().

Referenced by odr_intdup().

void* nmem_malloc ( NMEM  n,
int  size 
)

void nmem_reset ( NMEM  n  ) 

releases memory associaged with an NMEM handle

Parameters:
n NMEM handle

Definition at line 102 of file nmem.c.

References nmem_control::blocks, nmem_block::next, nmem_control::total, and yaz_log().

Referenced by ccl_stop_words_tree(), cql_parser_stream(), nmem_destroy(), odr_reset(), and yaz_marc_reset().

char* nmem_strdup ( NMEM  mem,
const char *  src 
)

allocates string on NMEM handle (similar strdup)

Parameters:
mem HNEM handle
src string
Returns:
duplicated string

Definition at line 18 of file nmemsdup.c.

References nmem_malloc().

Referenced by cql_apply_prefix(), cql_node_dup(), cql_node_mk_boolean(), cql_node_mk_sc(), 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_set_esn(), and yyparse().

char* nmem_strdup_null ( NMEM  mem,
const char *  src 
)

allocates string on NMEM handle - allows NULL ptr buffer

Parameters:
mem HNEM handle
src string
Returns:
duplicated string or NULL if src was NULL

Definition at line 25 of file nmemsdup.c.

References nmem_strdup().

Referenced by odr_strdup_null().

char* nmem_strdupn ( NMEM  mem,
const char *  src,
size_t  n 
)

allocates string of certain size on NMEM handle

Parameters:
mem NMEM handle
src string
n size of string
Returns:
duplicated string (0 terminated)

Definition at line 33 of file nmemsdup.c.

References nmem_malloc().

Referenced by nmem_strsplit(), odr_strdupn(), yaz_marc_add_controlfield(), yaz_marc_add_datafield(), yaz_marc_add_datafield_xml(), yaz_marc_add_leader(), and yaz_marc_add_subfield().

void nmem_strsplit ( NMEM  nmem,
const char *  delim,
const char *  dstr,
char ***  darray,
int *  num 
)

allocates sub strings out of string using certain delimitors

Parameters:
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 53 of file nmemsdup.c.

References nmem_malloc(), and nmem_strdupn().

Referenced by nmem_strsplit_blank(), and yaz_set_proposal_charneg_list().

void nmem_strsplit_blank ( NMEM  nmem,
const char *  dstr,
char ***  darray,
int *  num 
)

splits string into sub strings delimited by blanks

Parameters:
nmem NMEM handle
dstr string to be split
darray result string array for each sub string
num number of result strings

Definition at line 48 of file nmemsdup.c.

References nmem_strsplit().

int nmem_total ( NMEM  n  ) 

returns size in bytes of memory for NMEM handle

Returns:
number of bytes

Definition at line 142 of file nmem.c.

References nmem_control::total.

Referenced by odr_total().

void nmem_transfer ( NMEM  dst,
NMEM  src 
)

transfers memory from one NMEM handle to another

Parameters:
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 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(), tcpip_listen(), yaz_iconv(), and yaz_strerror().

void yaz_set_errno ( int  v  ) 

Definition at line 192 of file nmem.c.

void yaz_strerror ( char *  buf,
int  max 
)

Definition at line 197 of file nmem.c.

References yaz_errno(), and yaz_log_module_level().

Referenced by yaz_log().


Generated on Mon Nov 10 17:14:37 2008 for YAZ by  doxygen 1.5.6