Data Structures | Macros | Typedefs
memfile_defs.h File Reference
#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h>
#include "nvim/types.h"
#include "nvim/pos.h"

Go to the source code of this file.

Data Structures

struct  mf_hashitem
 
struct  mf_hashtab
 
struct  bhdr
 
struct  mf_blocknr_trans_item
 
struct  memfile
 A memory file. More...
 

Macros

#define MHT_INIT_SIZE   64
 Initial size for a hashtable. More...
 
#define bh_bnum   bh_hashitem.mhi_key
 header for hash table and key More...
 
#define BH_DIRTY   1U
 number of pages in this block More...
 
#define BH_LOCKED   2U
 
#define nt_old_bnum   nt_hashitem.mhi_key
 header for hash table and key More...
 

Typedefs

typedef int64_t blocknr_T
 
typedef struct mf_hashitem mf_hashitem_T
 
typedef struct mf_hashtab mf_hashtab_T
 
typedef struct bhdr bhdr_T
 
typedef struct mf_blocknr_trans_item mf_blocknr_trans_item_T
 
typedef struct memfile memfile_T
 A memory file. More...
 

Macro Definition Documentation

#define bh_bnum   bh_hashitem.mhi_key

header for hash table and key

#define BH_DIRTY   1U

number of pages in this block

#define BH_LOCKED   2U
#define MHT_INIT_SIZE   64

Initial size for a hashtable.

#define nt_old_bnum   nt_hashitem.mhi_key

header for hash table and key

Typedef Documentation

typedef struct bhdr bhdr_T

A block header.

There is a block header for each previously used block in the memfile.

The block may be linked in the used list OR in the free list. The used blocks are also kept in hash lists.

The used list is a doubly linked list, most recently used block first. The blocks in the used list have a block of memory allocated. The hash lists are used to quickly find a block in the used list. The free list is a single linked list, not sorted. The blocks in the free list have no block of memory allocated and the contents of the block in the file (if any) is irrelevant.

typedef int64_t blocknr_T

A block number.

Blocks numbered from 0 upwards have been assigned a place in the actual file. The block number is equal to the page number in the file. The blocks with negative numbers are currently in memory only.

typedef struct memfile memfile_T

A memory file.

A block number translation list item.

When a block with a negative number is flushed to the file, it gets a positive number. Because the reference to the block is still the negative number, we remember the translation to the new positive number in the double linked trans lists. The structure is the same as the hash lists.

typedef struct mf_hashitem mf_hashitem_T

A hash item.

Items' keys are block numbers. Items in the same bucket are organized into a doubly-linked list.

Therefore, items can be arbitrary data structures beginning with pointers for the list and and a block number key.

typedef struct mf_hashtab mf_hashtab_T

A chained hashtable with block numbers as keys and arbitrary data structures as items.

This is an intrusive data structure: we require that items begin with mf_hashitem_T which contains the key and linked list pointers. List of items in each bucket is doubly-linked.