@@ -495,42 +495,64 @@ extern my_error_reporter my_charset_error_reporter;
495
495
extern PSI_file_key key_file_io_cache;
496
496
497
497
/* Test if buffer is inited */
498
- #define my_b_clear (info ) (info)->buffer = 0
499
- #define my_b_inited (info ) (info)->buffer
500
- #define my_b_EOF INT_MIN
501
-
502
- #define my_b_read (info, Buffer, Count ) \
503
- ((info)->read_pos + (Count) <= (info)->read_end \
504
- ? (memcpy(Buffer, (info)->read_pos, (size_t )(Count)), \
505
- ((info)->read_pos += (Count)), 0 ) \
506
- : (*(info)->read_function)((info), Buffer, Count))
507
-
508
- #define my_b_write (info, Buffer, Count ) \
509
- ((info)->write_pos + (Count) <= (info)->write_end \
510
- ? (memcpy((info)->write_pos, (Buffer), (size_t )(Count)), \
511
- ((info)->write_pos += (Count)), 0 ) \
512
- : (*(info)->write_function)((info), (uchar *)(Buffer), (Count)))
513
-
514
- #define my_b_get (info ) \
515
- ((info)->read_pos != (info)->read_end \
516
- ? ((info)->read_pos++, (int )(uchar)(info)->read_pos[-1 ]) \
517
- : _my_b_get(info))
518
-
519
- #define my_b_tell (info ) \
520
- ((info)->pos_in_file + (size_t )(*(info)->current_pos - (info)->request_pos))
521
-
522
- #define my_b_get_buffer_start (info ) (info)->request_pos
523
- #define my_b_get_bytes_in_buffer (info ) \
524
- (char *)(info)->read_end - (char *)my_b_get_buffer_start(info)
525
- #define my_b_get_pos_in_file (info ) (info)->pos_in_file
498
+ inline void my_b_clear (IO_CACHE *info) { info->buffer = nullptr ; }
499
+
500
+ inline bool my_b_inited (const IO_CACHE *info) {
501
+ return info->buffer != nullptr ;
502
+ }
503
+
504
+ constexpr int my_b_EOF = INT_MIN;
505
+
506
+ inline int my_b_read (IO_CACHE *info, uchar *buffer, size_t count) {
507
+ if (info->read_pos + count <= info->read_end ) {
508
+ memcpy (buffer, info->read_pos , count);
509
+ info->read_pos += count;
510
+ return 0 ;
511
+ }
512
+ return (*info->read_function )(info, buffer, count);
513
+ }
514
+
515
+ inline int my_b_write (IO_CACHE *info, const uchar *buffer, size_t count) {
516
+ if (info->write_pos + count <= info->write_end ) {
517
+ memcpy (info->write_pos , buffer, count);
518
+ info->write_pos += count;
519
+ return 0 ;
520
+ }
521
+ return (*info->write_function )(info, buffer, count);
522
+ }
523
+
524
+ extern int _my_b_get (IO_CACHE *info);
525
+
526
+ inline int my_b_get (IO_CACHE *info) {
527
+ if (info->read_pos != info->read_end ) {
528
+ info->read_pos ++;
529
+ return info->read_pos [-1 ];
530
+ }
531
+ return _my_b_get (info);
532
+ }
533
+
534
+ inline my_off_t my_b_tell (const IO_CACHE *info) {
535
+ return info->pos_in_file + *info->current_pos - info->request_pos ;
536
+ }
537
+
538
+ inline uchar *my_b_get_buffer_start (const IO_CACHE *info) {
539
+ return info->request_pos ;
540
+ }
541
+
542
+ inline size_t my_b_get_bytes_in_buffer (const IO_CACHE *info) {
543
+ return info->read_end - my_b_get_buffer_start (info);
544
+ }
545
+
546
+ inline my_off_t my_b_get_pos_in_file (const IO_CACHE *info) {
547
+ return info->pos_in_file ;
548
+ }
526
549
527
550
/* tell write offset in the SEQ_APPEND cache */
528
551
int my_b_copy_to_file (IO_CACHE *cache, FILE *file);
529
- my_off_t my_b_append_tell (IO_CACHE *info);
530
- my_off_t my_b_safe_tell (IO_CACHE *info); /* picks the correct tell() */
531
552
532
- #define my_b_bytes_in_cache (info ) \
533
- (size_t )(*(info)->current_end - *(info)->current_pos)
553
+ inline size_t my_b_bytes_in_cache (const IO_CACHE *info) {
554
+ return *info->current_end - *info->current_pos ;
555
+ }
534
556
535
557
typedef uint32 ha_checksum;
536
558
@@ -669,7 +691,7 @@ void my_message_local_stderr(enum loglevel, uint ecode, va_list args);
669
691
extern void my_message_local (enum loglevel ll, uint ecode, ...);
670
692
extern bool my_init (void );
671
693
extern void my_end (int infoflag);
672
- extern char *my_filename (File fd);
694
+ extern const char *my_filename (File fd);
673
695
extern MY_MODE get_file_perm (ulong perm_flags);
674
696
extern bool my_chmod (const char *filename, ulong perm_flags, myf my_flags);
675
697
@@ -690,7 +712,8 @@ extern int test_if_hard_path(const char *dir_name);
690
712
extern bool has_path (const char *name);
691
713
extern char *convert_dirname (char *to, const char *from, const char *from_end);
692
714
extern void to_unix_path (char *name);
693
- extern char *fn_ext (const char *name);
715
+ extern char *fn_ext (char *name);
716
+ extern const char *fn_ext (const char *name);
694
717
extern char *fn_same (char *toname, const char *name, int flag);
695
718
extern char *fn_format (char *to, const char *name, const char *dir,
696
719
const char *form, uint flag);
@@ -729,7 +752,6 @@ extern void init_io_cache_share(IO_CACHE *read_cache, IO_CACHE_SHARE *cshare,
729
752
extern void remove_io_thread (IO_CACHE *info);
730
753
extern int _my_b_seq_read (IO_CACHE *info, uchar *Buffer, size_t Count);
731
754
extern int _my_b_net_read (IO_CACHE *info, uchar *Buffer, size_t Count);
732
- extern int _my_b_get (IO_CACHE *info);
733
755
extern int _my_b_write (IO_CACHE *info, const uchar *Buffer, size_t Count);
734
756
extern int my_b_append (IO_CACHE *info, const uchar *Buffer, size_t Count);
735
757
extern int my_b_safe_write (IO_CACHE *info, const uchar *Buffer, size_t Count);
0 commit comments