mirror of
https://github.com/neovim/neovim.git
synced 2024-12-25 05:35:10 -07:00
Review: Remove long_u: memfile: Cleanup: Fix naming inconsistencies.
- Drop '_S' suffix for struct names. - Make struct names match corresponding type's name (just removing '_S' suffix). - Rename NR_TRANS type/struct (just ugly).
This commit is contained in:
parent
a69b2e3c40
commit
fce201e656
@ -804,7 +804,7 @@ static int mf_trans_add(memfile_T *mfp, bhdr_T *hp)
|
||||
if (hp->bh_bnum >= 0) // it's already positive
|
||||
return OK;
|
||||
|
||||
NR_TRANS *np = xmalloc(sizeof(NR_TRANS));
|
||||
mf_blocknr_trans_item_T *np = xmalloc(sizeof(mf_blocknr_trans_item_T));
|
||||
|
||||
// Get a new number for the block.
|
||||
// If the first item in the free list has sufficient pages, use its number.
|
||||
@ -847,7 +847,8 @@ static int mf_trans_add(memfile_T *mfp, bhdr_T *hp)
|
||||
/// The old number When not found.
|
||||
blocknr_T mf_trans_del(memfile_T *mfp, blocknr_T old_nr)
|
||||
{
|
||||
NR_TRANS *np = (NR_TRANS *)mf_hash_find(&mfp->mf_trans, old_nr);
|
||||
mf_blocknr_trans_item_T *np =
|
||||
(mf_blocknr_trans_item_T *)mf_hash_find(&mfp->mf_trans, old_nr);
|
||||
|
||||
if (np == NULL) // not found
|
||||
return old_nr;
|
||||
|
@ -17,9 +17,9 @@ typedef long blocknr_T;
|
||||
///
|
||||
/// Therefore, items can be arbitrary data structures beginning with pointers
|
||||
/// for the list and and a block number key.
|
||||
typedef struct mf_hashitem_S {
|
||||
struct mf_hashitem_S *mhi_next;
|
||||
struct mf_hashitem_S *mhi_prev;
|
||||
typedef struct mf_hashitem {
|
||||
struct mf_hashitem *mhi_next;
|
||||
struct mf_hashitem *mhi_prev;
|
||||
blocknr_T mhi_key;
|
||||
} mf_hashitem_T;
|
||||
|
||||
@ -32,7 +32,7 @@ typedef struct mf_hashitem_S {
|
||||
/// 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.
|
||||
typedef struct mf_hashtab_S {
|
||||
typedef struct mf_hashtab {
|
||||
long_u mht_mask; /// mask used to mod hash value to array index
|
||||
/// (nr of items in array is 'mht_mask + 1')
|
||||
long_u mht_count; /// number of items inserted
|
||||
@ -57,12 +57,12 @@ typedef struct mf_hashtab_S {
|
||||
/// 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 struct block_hdr {
|
||||
typedef struct bhdr {
|
||||
mf_hashitem_T bh_hashitem; /// header for hash table and key
|
||||
#define bh_bnum bh_hashitem.mhi_key /// block number, part of bh_hashitem
|
||||
|
||||
struct block_hdr *bh_next; /// next block_hdr in free or used list
|
||||
struct block_hdr *bh_prev; /// previous block_hdr in used list
|
||||
struct bhdr *bh_next; /// next block header in free or used list
|
||||
struct bhdr *bh_prev; /// previous block header in used list
|
||||
char_u *bh_data; /// pointer to memory (for used block)
|
||||
int bh_page_count; /// number of pages in this block
|
||||
|
||||
@ -77,20 +77,20 @@ typedef struct block_hdr {
|
||||
/// 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 nr_trans {
|
||||
typedef struct mf_blocknr_trans_item {
|
||||
mf_hashitem_T nt_hashitem; /// header for hash table and key
|
||||
#define nt_old_bnum nt_hashitem.mhi_key /// old, negative, number
|
||||
blocknr_T nt_new_bnum; /// new, positive, number
|
||||
} NR_TRANS;
|
||||
} mf_blocknr_trans_item_T;
|
||||
|
||||
/// A memory file.
|
||||
typedef struct memfile {
|
||||
char_u *mf_fname; /// name of the file
|
||||
char_u *mf_ffname; /// idem, full path
|
||||
int mf_fd; /// file descriptor
|
||||
bhdr_T *mf_free_first; /// first block_hdr in free list
|
||||
bhdr_T *mf_used_first; /// mru block_hdr in used list
|
||||
bhdr_T *mf_used_last; /// lru block_hdr in used list
|
||||
bhdr_T *mf_free_first; /// first block header in free list
|
||||
bhdr_T *mf_used_first; /// mru block header in used list
|
||||
bhdr_T *mf_used_last; /// lru block header in used list
|
||||
unsigned mf_used_count; /// number of pages in used list
|
||||
unsigned mf_used_count_max; /// maximum number of pages in memory
|
||||
mf_hashtab_T mf_hash; /// hash lists
|
||||
|
Loading…
Reference in New Issue
Block a user