mem.h File Reference

#include "nip_init.h"
#include "nip_error.h"

Include dependency graph for mem.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  nip_mem_block_t
 Header for block of dynamically managed memory. More...
struct  nip_mem_ptr_t
 Structure to handle pointers to managed or unmanaged memory. More...

Defines

#define NIP_MEM_NULL   0x00
 handle for undefined memory block
#define NIP_MEM_BLOCK_USED(b)   (b->flags & NIP_MEM_FLG_USED)
#define NIP_MEM_BLOCK_LOCKED(b)   (b->flags & NIP_MEM_FLG_LOCKED)
Flags for block of dynamically managed memory.
#define NIP_MEM_FLG_USED   0x01
 Block in use.
#define NIP_MEM_FLG_LOCKED   0x02
 Block locked and may not be moved/defragmented at this time.
#define NIP_MEM_FLG_DELREAD   0x04
 Data will be deleted automatically when read from block.
#define NIP_MEM_FLGS_UNUSED   0x00
 Flag configuration for unused block.

Typedefs

typedef uint16_t nip_mem_size_t
 Maximum number of memory blocks.
typedef uint16_t nip_mem_cnt_t
typedef uint8_t nip_mem_handle_t
 Handle for block of dynamically managed memory.
typedef uint8_t nip_mem_flags_t
 Type definition for memory block flags.

Enumerations

enum  nip_mem_alloc_stat_t {
  NIP_MEM_ALLOC_DEFRAG, NIP_MEM_ALLOC_SIZE, NIP_MEM_ALLOC_MIN_SIZE, NIP_MEM_ALLOC_BLOCK_SIZE,
  NIP_MEM_ALLOC_FAIL
}
 States of memory allocation function. More...

Functions

void nip_mem_init ()
nip_mem_handle_t nip_mem_alloc (nip_mem_size_t size, nip_mem_size_t min_length, nip_mem_flags_t flags, nip_mem_size_t *res_length)
void nip_mem_free (nip_mem_handle_t block_id)
nip_error_t nip_mem_set_min_length (nip_mem_handle_t block_id, nip_mem_size_t min_length)
nip_error_t nip_mem_write (nip_mem_handle_t block_id, void *buf, nip_mem_size_t size)
nip_mem_size_t nip_mem_read_at_pos (nip_mem_handle_t block_id, uint8_t *buf, nip_mem_size_t size, nip_mem_size_t pos)
nip_mem_size_t nip_mem_read (nip_mem_handle_t block_id, uint8_t *buf, nip_mem_size_t size)
void * nip_mem_obtain_ptr (nip_mem_handle_t block_id)
void nip_mem_release_block (nip_mem_handle_t block_id)
void * nip_mem_ptr (nip_mem_ptr_t *p)
void nip_mem_release_ptr (nip_mem_ptr_t *p)
nip_mem_size_t nip_mem_buf_used (nip_mem_handle_t block_id)
void nip_mem_set_used (nip_mem_handle_t block_id, nip_mem_size_t new_size)
nip_mem_size_t nip_mem_move (nip_mem_handle_t dst_block, nip_mem_handle_t src_block, nip_mem_size_t size)
nip_error_t nip_mem_insert (nip_mem_ptr_t *dst, nip_mem_ptr_t *src, nip_mem_size_t len)
nip_error_t nip_mem_cut (nip_mem_ptr_t *location, nip_mem_size_t len)


Define Documentation

#define NIP_MEM_BLOCK_LOCKED (  )     (b->flags & NIP_MEM_FLG_LOCKED)

Definition at line 158 of file mem.h.

#define NIP_MEM_BLOCK_USED (  )     (b->flags & NIP_MEM_FLG_USED)

Definition at line 157 of file mem.h.

#define NIP_MEM_FLG_DELREAD   0x04

Data will be deleted automatically when read from block.

Definition at line 108 of file mem.h.

Referenced by nip_udp_init_send().

#define NIP_MEM_FLG_LOCKED   0x02

Block locked and may not be moved/defragmented at this time.

Definition at line 107 of file mem.h.

#define NIP_MEM_FLG_USED   0x01

Block in use.

Definition at line 106 of file mem.h.

#define NIP_MEM_FLGS_UNUSED   0x00

Flag configuration for unused block.

Definition at line 110 of file mem.h.

#define NIP_MEM_NULL   0x00


Typedef Documentation

typedef uint16_t nip_mem_cnt_t

Definition at line 67 of file mem.h.

typedef uint8_t nip_mem_flags_t

Type definition for memory block flags.

Definition at line 100 of file mem.h.

typedef uint8_t nip_mem_handle_t

Handle for block of dynamically managed memory.

Definition at line 92 of file mem.h.

typedef uint16_t nip_mem_size_t

Maximum number of memory blocks.

Raising the number above 255 may lead to an increase of used program memory, due to larger identifiers. Look at the definition of nip_mem_handle_t for further explanation. Number of bytes reserved for dynamic buffer management. The default value is 600 Bytes which is assumed to be needed for the reception of datagrams with the standard maximum IP size of 576 Bytes.

Note:
Not all of the reservied memory will actually be available for allocation, as some of it will be spend on management information.

Definition at line 66 of file mem.h.


Enumeration Type Documentation

States of memory allocation function.

Enumerator:
NIP_MEM_ALLOC_DEFRAG 
NIP_MEM_ALLOC_SIZE 
NIP_MEM_ALLOC_MIN_SIZE 
NIP_MEM_ALLOC_BLOCK_SIZE 
NIP_MEM_ALLOC_FAIL 

Definition at line 75 of file mem.h.


Function Documentation

nip_mem_handle_t nip_mem_alloc ( nip_mem_size_t  size,
nip_mem_size_t  min_length,
nip_mem_flags_t  flags,
nip_mem_size_t res_length 
)

Referenced by nip_mdns_init(), nip_tcp_create_conn(), nip_tcp_disp_receive(), nip_tcp_disp_send(), and nip_udp_init_send().

Here is the caller graph for this function:

nip_mem_size_t nip_mem_buf_used ( nip_mem_handle_t  block_id  ) 

nip_error_t nip_mem_cut ( nip_mem_ptr_t location,
nip_mem_size_t  len 
)

Referenced by nip_mdns_disp_check_queries().

Here is the caller graph for this function:

void nip_mem_free ( nip_mem_handle_t  block_id  ) 

void nip_mem_init (  ) 

Referenced by nip_init().

Here is the caller graph for this function:

nip_error_t nip_mem_insert ( nip_mem_ptr_t dst,
nip_mem_ptr_t src,
nip_mem_size_t  len 
)

Referenced by nip_mdns_disp_check_queries(), nip_mdns_register_name(), and nip_mdns_tx_name().

Here is the caller graph for this function:

nip_mem_size_t nip_mem_move ( nip_mem_handle_t  dst_block,
nip_mem_handle_t  src_block,
nip_mem_size_t  size 
)

Referenced by nip_tcp_disp_receive().

Here is the caller graph for this function:

void* nip_mem_obtain_ptr ( nip_mem_handle_t  block_id  ) 

void* nip_mem_ptr ( nip_mem_ptr_t p  ) 

nip_mem_size_t nip_mem_read ( nip_mem_handle_t  block_id,
uint8_t *  buf,
nip_mem_size_t  size 
)

Referenced by nip_tcp_disp_receive(), nip_tcp_read(), and nip_udp_recvfrom().

Here is the caller graph for this function:

nip_mem_size_t nip_mem_read_at_pos ( nip_mem_handle_t  block_id,
uint8_t *  buf,
nip_mem_size_t  size,
nip_mem_size_t  pos 
)

Referenced by nip_tcp_disp_receive().

Here is the caller graph for this function:

void nip_mem_release_block ( nip_mem_handle_t  block_id  ) 

void nip_mem_release_ptr ( nip_mem_ptr_t p  ) 

Referenced by nip_mdns_disp_check_cache(), nip_mdns_disp_check_queries(), nip_mdns_parse_packet(), and nip_mdns_register_name().

Here is the caller graph for this function:

nip_error_t nip_mem_set_min_length ( nip_mem_handle_t  block_id,
nip_mem_size_t  min_length 
)

void nip_mem_set_used ( nip_mem_handle_t  block_id,
nip_mem_size_t  new_size 
)

nip_error_t nip_mem_write ( nip_mem_handle_t  block_id,
void *  buf,
nip_mem_size_t  size 
)


Generated on Thu Jul 10 01:09:44 2008 for NIP by  doxygen 1.5.5