Skip to content

Commit

Permalink
Bug #26781567: REMOVE C LEGACY [noclose]
Browse files Browse the repository at this point in the history
Rename most st_* structs with a typedef to just being that typedef;
there's no point in a struct having two names. There are still a few
remaining, which will be dealt with in a follow-up patch.

structs that are expected to be used from C code (e.g. mysql.h) have
been given a typedef to themselves, so that C code can continue to
write MYSQL *mysql instead of struct MYSQL *mysql.

Change-Id: Ic4bdd6cd9e2d9d1223c331ddd1ad89423742fba2
  • Loading branch information
Steinar H. Gunderson committed Sep 21, 2017
1 parent 05596f6 commit 146f124
Show file tree
Hide file tree
Showing 137 changed files with 717 additions and 656 deletions.
4 changes: 2 additions & 2 deletions client/my_readline.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "my_inttypes.h"
#include "my_io.h"

typedef struct st_line_buffer
struct LINE_BUFFER
{
File file;
char *buffer; /* The buffer itself, grown as needed. */
Expand All @@ -35,7 +35,7 @@ typedef struct st_line_buffer
ulong read_length; /* Length of last read string */
int error;
bool truncated;
} LINE_BUFFER;
};

extern LINE_BUFFER *batch_readline_init(ulong max_size,FILE *file);
extern LINE_BUFFER *batch_readline_command(LINE_BUFFER *buffer, char * str);
Expand Down
4 changes: 2 additions & 2 deletions client/mysql.cc
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,14 @@ static char *server_version= NULL;

#define MAX_BATCH_BUFFER_SIZE (1024L * 1024L * 1024L)

typedef struct st_status
struct STATUS
{
int exit_status;
ulong query_start_line;
char *file_name;
LINE_BUFFER *line_buff;
bool batch,add_to_history;
} STATUS;
};


static HashTable ht;
Expand Down
45 changes: 26 additions & 19 deletions client/mysqltest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -632,9 +632,9 @@ struct st_replace_regex

struct st_replace_regex *glob_replace_regex= 0;

struct st_replace;
struct st_replace *glob_replace= 0;
void replace_strings_append(struct st_replace *rep, DYNAMIC_STRING* ds,
struct REPLACE;
REPLACE *glob_replace= 0;
void replace_strings_append(REPLACE *rep, DYNAMIC_STRING* ds,
const char *from, size_t len);

static void cleanup_and_exit(int exit_code) MY_ATTRIBUTE((noreturn));
Expand Down Expand Up @@ -10650,14 +10650,15 @@ void replace_numeric_round_append(int round, DYNAMIC_STRING* result,

/* Definitions for replace result */

typedef struct st_pointer_array { /* when using array-strings */
struct POINTER_ARRAY
{ /* when using array-strings */
TYPELIB typelib; /* Pointer to strings */
uchar *str; /* Strings is here */
uint8 *flag; /* Flag about each var. */
uint array_allocs,max_count,length,max_length;
} POINTER_ARRAY;
};

struct st_replace *init_replace(char * *from, char * *to, uint count,
REPLACE *init_replace(char * *from, char * *to, uint count,
char * word_end_chars);
int insert_pointer_name(POINTER_ARRAY *pa,char * name);
void free_pointer_array(POINTER_ARRAY *pa);
Expand Down Expand Up @@ -10727,17 +10728,19 @@ void free_replace()
}


typedef struct st_replace {
struct REPLACE
{
int found;
struct st_replace *next[256];
} REPLACE;
REPLACE *next[256];
};

typedef struct st_replace_found {
struct REPLACE_STRING
{
int found;
char *replace_string;
uint to_offset;
int from_offset;
} REPLACE_STRING;
};


void replace_strings_append(REPLACE *rep, DYNAMIC_STRING* ds,
Expand Down Expand Up @@ -11226,34 +11229,38 @@ int reg_replace(char** buf_p, int* buf_len_p, char *pattern,
#define SET_MALLOC_HUNC 64
#define LAST_CHAR_CODE 259

typedef struct st_rep_set {
struct REP_SET
{
uint *bits; /* Pointer to used sets */
short next[LAST_CHAR_CODE]; /* Pointer to next sets */
uint found_len; /* Best match to date */
int found_offset;
uint table_offset;
uint size_of_bits; /* For convinience */
} REP_SET;
};

typedef struct st_rep_sets {
struct REP_SETS
{
uint count; /* Number of sets */
uint extra; /* Extra sets in buffer */
uint invisible; /* Sets not chown */
uint size_of_bits;
REP_SET *set,*set_buffer;
uint *bit_buffer;
} REP_SETS;
};

typedef struct st_found_set {
struct FOUND_SET
{
uint table_offset;
int found_offset;
} FOUND_SET;
};

typedef struct st_follow {
struct FOLLOWS
{
int chr;
uint table_offset;
uint len;
} FOLLOWS;
};


int init_sets(REP_SETS *sets,uint states);
Expand Down
34 changes: 17 additions & 17 deletions include/heap.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ typedef struct st_heapinfo /* Struct from heap_info */

/* Structs used by heap-database-handler */

typedef struct st_heap_ptrs
struct HP_PTRS
{
uchar *blocks[HP_PTRS_IN_NOD]; /* pointers to HP_PTRS or records */
} HP_PTRS;
};

struct st_level_info
{
Expand Down Expand Up @@ -106,17 +106,17 @@ struct st_level_info
See hp_get_new_block
*/

typedef struct st_heap_block
struct HP_BLOCK
{
HP_PTRS *root; /* Top-level block */
struct st_level_info level_info[HP_MAX_LEVELS+1];
uint levels; /* number of used levels */
uint records_in_block; /* Records in one heap-block */
uint recbuffer; /* Length of one saved record */
ulong last_allocated; /* number of records there is allocated space for */
} HP_BLOCK;
};

struct st_heap_info; /* For referense */
struct HP_INFO; /* For referense */

typedef struct st_hp_keydef /* Key definition with open */
{
Expand All @@ -132,14 +132,14 @@ typedef struct st_hp_keydef /* Key definition with open */
*/
ha_rows hash_buckets;
TREE rb_tree;
int (*write_key)(struct st_heap_info *info, struct st_hp_keydef *keyinfo,
int (*write_key)(HP_INFO *info, struct st_hp_keydef *keyinfo,
const uchar *record, uchar *recpos);
int (*delete_key)(struct st_heap_info *info, struct st_hp_keydef *keyinfo,
int (*delete_key)(HP_INFO *info, struct st_hp_keydef *keyinfo,
const uchar *record, uchar *recpos, int flag);
uint (*get_key_length)(struct st_hp_keydef *keydef, const uchar *key);
} HP_KEYDEF;

typedef struct st_heap_share
struct HP_SHARE
{
HP_BLOCK block;
HP_KEYDEF *keydef;
Expand All @@ -163,15 +163,15 @@ typedef struct st_heap_share
uint auto_key;
uint auto_key_type; /* real type of the auto key segment */
ulonglong auto_increment;
} HP_SHARE;
};

struct st_hp_hash_info;
struct HASH_INFO;

typedef struct st_heap_info
struct HP_INFO
{
HP_SHARE *s;
uchar *current_ptr;
struct st_hp_hash_info *current_hash_ptr;
HASH_INFO *current_hash_ptr;
ulong current_record,next_block;
int lastinx,errkey;
int mode; /* Mode of file (READONLY..) */
Expand All @@ -185,17 +185,17 @@ typedef struct st_heap_info
bool implicit_emptied;
THR_LOCK_DATA lock;
LIST open_list;
} HP_INFO;
};

typedef uchar *HEAP_PTR;

typedef struct st_heap_position
struct HP_HEAP_POSITION
{
HEAP_PTR ptr;
ulong record_no; /* Number of current record in table scan order (starting at 0) */
} HP_HEAP_POSITION;
};

typedef struct st_heap_create_info
struct HP_CREATE_INFO
{
HP_KEYDEF *keydef;
ulong max_records;
Expand All @@ -214,7 +214,7 @@ typedef struct st_heap_create_info
open_count to 1. Is only looked at if not internal_table.
*/
bool pin_share;
} HP_CREATE_INFO;
};

/* Prototypes for heap-functions */

Expand Down
10 changes: 5 additions & 5 deletions include/keycache.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

C_MODE_START

/* declare structures that is used by st_key_cache */
/* declare structures that is used by KEY_CACHE */

struct st_block_link;

Expand All @@ -51,10 +51,10 @@ typedef struct st_keycache_thread_var
} st_keycache_thread_var;

/* info about requests in a waiting queue */
typedef struct st_keycache_wqueue
struct KEYCACHE_WQUEUE
{
st_keycache_thread_var *last_thread; /* circular list of waiting threads */
} KEYCACHE_WQUEUE;
};

/* Typical key cash */
#define KEY_CACHE_SIZE (uint) (8*1024*1024)
Expand All @@ -68,7 +68,7 @@ typedef struct st_keycache_wqueue
It also contains read-only statistics parameters.
*/

typedef struct st_key_cache
struct KEY_CACHE
{
bool key_cache_inited;
bool in_resize; /* true during resize operation */
Expand Down Expand Up @@ -128,7 +128,7 @@ typedef struct st_key_cache

int blocks; /* max number of blocks in the cache */
bool in_init; /* Set to 1 in MySQL during init/resize */
} KEY_CACHE;
};

/* The default key cache */
extern KEY_CACHE dflt_key_cache_var, *dflt_key_cache;
Expand Down
19 changes: 11 additions & 8 deletions include/lf.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ typedef struct {
std::atomic<uint32> pins_in_array; /* number of elements in array */
} LF_PINBOX;

typedef struct st_lf_pins {
struct LF_PINS
{
std::atomic<void *> pin[LF_PINBOX_PINS];
LF_PINBOX *pinbox;
void *purgatory;
Expand All @@ -85,7 +86,7 @@ typedef struct st_lf_pins {
#if SIZEOF_INT*2+SIZEOF_CHARP*(LF_PINBOX_PINS+2) != 64
char pad[64-sizeof(uint32)*2-sizeof(void*)*(LF_PINBOX_PINS+2)];
#endif
} LF_PINS;
};

/*
compile-time assert, to require "no less than N" pins
Expand Down Expand Up @@ -130,14 +131,15 @@ void lf_pinbox_free(LF_PINS *pins, void *addr);
*/
typedef void lf_allocator_func(uchar *);

typedef struct st_lf_allocator {
struct LF_ALLOCATOR
{
LF_PINBOX pinbox;
std::atomic<uchar *> top;
uint element_size;
std::atomic<uint32> mallocs;
lf_allocator_func *constructor; /* called, when an object is malloc()'ed */
lf_allocator_func *destructor; /* called, when an object is free()'d */
} LF_ALLOCATOR;
};

#define lf_alloc_init(A, B, C) lf_alloc_init2(A, B, C, NULL, NULL)
void lf_alloc_init2(LF_ALLOCATOR *allocator, uint size, uint free_ptr_offset,
Expand All @@ -154,9 +156,9 @@ static inline void lf_alloc_direct_free(LF_ALLOCATOR *allocator, void *addr)

void *lf_alloc_new(LF_PINS *pins);

struct st_lf_hash;
struct LF_HASH;

typedef uint lf_hash_func(const struct st_lf_hash *, const uchar *, size_t);
typedef uint lf_hash_func(const LF_HASH *, const uchar *, size_t);
typedef void lf_hash_init_func(uchar *dst, const uchar* src);

#define LF_HASH_UNIQUE 1
Expand All @@ -177,7 +179,8 @@ extern const int LF_HASH_OVERHEAD;
*/
typedef const uchar *(*hash_get_key_function)(const uchar *arg, size_t *length);

typedef struct st_lf_hash {
struct LF_HASH
{
LF_DYNARRAY array; /* hash itself */
LF_ALLOCATOR alloc; /* allocator for elements */
hash_get_key_function get_key; /* see HASH */
Expand All @@ -199,7 +202,7 @@ typedef struct st_lf_hash {
lf_hash_insert.
*/
lf_hash_init_func *initialize;
} LF_HASH;
};

#define lf_hash_init(A, B, C, D, E, F, G) \
lf_hash_init2(A, B, C, D, E, F, G, NULL, NULL, NULL, NULL)
Expand Down
6 changes: 3 additions & 3 deletions include/my_alloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ extern void init_alloc_root(PSI_memory_key key,

}

typedef struct st_used_mem
struct USED_MEM
{ /* struct for once_alloc (block) */
struct st_used_mem *next; /* Next block in use */
USED_MEM *next; /* Next block in use */
unsigned int left; /* memory left in block */
unsigned int size; /* size of block */
} USED_MEM;
};


struct MEM_ROOT
Expand Down
4 changes: 2 additions & 2 deletions include/my_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -1114,13 +1114,13 @@ typedef struct st_key_range
enum ha_rkey_function flag;
} key_range;

typedef struct st_key_multi_range
struct KEY_MULTI_RANGE
{
key_range start_key;
key_range end_key;
char *ptr; /* Free to use by caller (ptr to row etc) */
uint range_flag; /* key range flags see above */
} KEY_MULTI_RANGE;
};


/* For number of records */
Expand Down
4 changes: 2 additions & 2 deletions include/my_bitmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

typedef uint32 my_bitmap_map;

typedef struct st_bitmap
struct MY_BITMAP
{
my_bitmap_map *bitmap;
uint n_bits; /* number of bits occupied by the above */
Expand All @@ -44,7 +44,7 @@ typedef struct st_bitmap
acquiring the mutex
*/
mysql_mutex_t *mutex;
} MY_BITMAP;
};

#ifdef __cplusplus
extern "C" {
Expand Down
Loading

0 comments on commit 146f124

Please sign in to comment.