memfile_defs.h
Go to the documentation of this file.
1 #ifndef NVIM_MEMFILE_DEFS_H
2 #define NVIM_MEMFILE_DEFS_H
3 
4 #include <stdint.h>
5 #include <stdbool.h>
6 #include <stdlib.h>
7 
8 #include "nvim/types.h"
9 #include "nvim/pos.h"
10 
16 typedef int64_t blocknr_T;
17 
25 typedef struct mf_hashitem {
30 
32 #define MHT_INIT_SIZE 64
33 
40 typedef struct mf_hashtab {
41  size_t mht_mask;
42  size_t mht_count;
45  mf_hashitem_T *mht_small_buckets[MHT_INIT_SIZE];
48 } mf_hashtab_T;
49 
63 typedef struct bhdr {
65 #define bh_bnum bh_hashitem.mhi_key
66 
67  struct bhdr *bh_next;
68  struct bhdr *bh_prev;
69  void *bh_data;
70  unsigned bh_page_count;
71 
72 #define BH_DIRTY 1U
73 #define BH_LOCKED 2U
74  unsigned bh_flags; // BH_DIRTY or BH_LOCKED
75 } bhdr_T;
76 
83 typedef struct mf_blocknr_trans_item {
85 #define nt_old_bnum nt_hashitem.mhi_key
86  blocknr_T nt_new_bnum;
87 } mf_blocknr_trans_item_T;
88 
90 typedef struct memfile {
93  int mf_fd;
103  unsigned mf_page_size;
104  bool mf_dirty;
105 } memfile_T;
106 
107 #endif // NVIM_MEMFILE_DEFS_H
bhdr_T * mf_used_last
mru block header in used list
Definition: memfile_defs.h:96
unsigned bh_flags
Definition: memfile_defs.h:74
struct mf_hashtab mf_hashtab_T
unsigned mf_page_size
number of pages in the file
Definition: memfile_defs.h:103
blocknr_T mf_blocknr_max
trans lists
Definition: memfile_defs.h:99
unsigned bh_page_count
pointer to memory (for used block)
Definition: memfile_defs.h:70
void * bh_data
previous block header in used list
Definition: memfile_defs.h:69
mf_hashitem_T bh_hashitem
Definition: memfile_defs.h:64
A memory file.
Definition: memfile_defs.h:90
struct mf_hashitem * mhi_next
Definition: memfile_defs.h:26
blocknr_T mf_infile_count
number of negative blocks numbers
Definition: memfile_defs.h:102
bhdr_T * mf_used_first
first block header in free list
Definition: memfile_defs.h:95
struct mf_hashitem * mhi_prev
Definition: memfile_defs.h:27
Definition: memfile_defs.h:25
mf_hashtab_T mf_trans
hash lists
Definition: memfile_defs.h:98
blocknr_T mf_blocknr_min
highest positive block number + 1
Definition: memfile_defs.h:100
int mf_fd
idem, full path
Definition: memfile_defs.h:93
struct bhdr * bh_next
Definition: memfile_defs.h:67
blocknr_T mf_neg_count
lowest negative block number - 1
Definition: memfile_defs.h:101
bhdr_T * mf_free_first
file descriptor
Definition: memfile_defs.h:94
blocknr_T mhi_key
Definition: memfile_defs.h:28
struct mf_hashitem mf_hashitem_T
Definition: memfile_defs.h:63
mf_hashitem_T ** mht_buckets
number of items inserted
Definition: memfile_defs.h:44
size_t mht_mask
Definition: memfile_defs.h:41
struct bhdr * bh_prev
next block header in free or used list
Definition: memfile_defs.h:68
mf_hashitem_T nt_hashitem
Definition: memfile_defs.h:84
int64_t blocknr_T
Definition: memfile_defs.h:16
unsigned char char_u
Definition: types.h:11
struct bhdr bhdr_T
Definition: memfile_defs.h:83
char_u * mf_fname
Definition: memfile_defs.h:91
#define MHT_INIT_SIZE
Initial size for a hashtable.
Definition: memfile_defs.h:32
bool mf_dirty
number of bytes in a page
Definition: memfile_defs.h:104
char_u * mf_ffname
name of the file
Definition: memfile_defs.h:92
mf_hashtab_T mf_hash
lru block header in used list
Definition: memfile_defs.h:97
struct memfile memfile_T
A memory file.
Definition: memfile_defs.h:40