Commit dd2836c4 authored by unknown's avatar unknown

Changed safemalloc structure to not have to be 8 byte aligned. (Portability problem)



include/my_sys.h:
  Changed safe_malloc variables to start with sf_
mysys/default.c:
  Use safemalloc (as we use dynamic_arrays() that uses it inderectly anyway)
mysys/my_static.c:
  Changed safe_malloc variables to start with sf_
mysys/my_static.h:
  Changed safe_malloc variables to start with sf_
  Changed safemalloc structure to not have to be 8 byte aligned
mysys/safemalloc.c:
  Changed safemalloc structure to not have to be 8 byte aligned. (portability fix)
  BIG code cleanup
sql/mysqld.cc:
  Changed safe_malloc variables to start with sf_
sql/sql_parse.cc:
  Changed safe_malloc variables to start with sf_
parent 2a450f0c
...@@ -138,7 +138,7 @@ extern int NEAR my_errno; /* Last error in mysys */ ...@@ -138,7 +138,7 @@ extern int NEAR my_errno; /* Last error in mysys */
#define QUICK_SAFEMALLOC sf_malloc_quick=1 #define QUICK_SAFEMALLOC sf_malloc_quick=1
#define NORMAL_SAFEMALLOC sf_malloc_quick=0 #define NORMAL_SAFEMALLOC sf_malloc_quick=0
extern uint sf_malloc_prehunc,sf_malloc_endhunc,sf_malloc_quick; extern uint sf_malloc_prehunc,sf_malloc_endhunc,sf_malloc_quick;
extern ulonglong safemalloc_mem_limit; extern ulonglong sf_malloc_mem_limit;
#define CALLER_INFO_PROTO , const char *sFile, uint uLine #define CALLER_INFO_PROTO , const char *sFile, uint uLine
#define CALLER_INFO , __FILE__, __LINE__ #define CALLER_INFO , __FILE__, __LINE__
...@@ -239,7 +239,7 @@ extern int NEAR my_umask, /* Default creation mask */ ...@@ -239,7 +239,7 @@ extern int NEAR my_umask, /* Default creation mask */
NEAR my_safe_to_handle_signal, /* Set when allowed to SIGTSTP */ NEAR my_safe_to_handle_signal, /* Set when allowed to SIGTSTP */
NEAR my_dont_interrupt; /* call remember_intr when set */ NEAR my_dont_interrupt; /* call remember_intr when set */
extern my_bool NEAR mysys_uses_curses, my_use_symdir; extern my_bool NEAR mysys_uses_curses, my_use_symdir;
extern long lCurMemory,lMaxMemory; /* from safemalloc */ extern ulong sf_malloc_cur_memory, sf_malloc_max_memory;
extern ulong my_default_record_cache_size; extern ulong my_default_record_cache_size;
extern my_bool NEAR my_disable_locking,NEAR my_disable_async_io, extern my_bool NEAR my_disable_locking,NEAR my_disable_async_io,
......
...@@ -33,8 +33,6 @@ ...@@ -33,8 +33,6 @@
** --print-defaults ; Print the modified command line and exit ** --print-defaults ; Print the modified command line and exit
****************************************************************************/ ****************************************************************************/
#undef SAFEMALLOC /* safe_malloc is not yet initailized */
#include "mysys_priv.h" #include "mysys_priv.h"
#include "m_string.h" #include "m_string.h"
#include "m_ctype.h" #include "m_ctype.h"
......
...@@ -69,14 +69,13 @@ uint sf_malloc_prehunc=0, /* If you have problem with core- */ ...@@ -69,14 +69,13 @@ uint sf_malloc_prehunc=0, /* If you have problem with core- */
sf_malloc_endhunc=0, /* dump when malloc-message.... */ sf_malloc_endhunc=0, /* dump when malloc-message.... */
/* set theese to 64 or 128 */ /* set theese to 64 or 128 */
sf_malloc_quick=0; /* set if no calls to sanity */ sf_malloc_quick=0; /* set if no calls to sanity */
long lCurMemory = 0L; /* Current memory usage */ ulong sf_malloc_cur_memory= 0L; /* Current memory usage */
long lMaxMemory = 0L; /* Maximum memory usage */ ulong sf_malloc_max_memory= 0L; /* Maximum memory usage */
uint cNewCount = 0; /* Number of times NEW() was called */ uint sf_malloc_count= 0; /* Number of times NEW() was called */
byte *sf_min_adress= (byte*) ~(unsigned long) 0L, byte *sf_min_adress= (byte*) ~(unsigned long) 0L,
*sf_max_adress= (byte*) 0L; *sf_max_adress= (byte*) 0L;
/* Root of the linked list of struct st_irem */
/* Root of the linked list of remembers */ struct st_irem *sf_malloc_root = NULL;
struct remember *pRememberRoot = NULL;
/* from my_alarm */ /* from my_alarm */
int volatile my_have_got_alarm=0; /* declare variable to reset */ int volatile my_have_got_alarm=0; /* declare variable to reset */
......
...@@ -33,27 +33,23 @@ struct st_remember { ...@@ -33,27 +33,23 @@ struct st_remember {
}; };
/* /*
The size of the following structure MUST be dividable by 8 to not cause Structure that stores information of a allocated memory block
alignment problems on some cpu's The data is at &struct_adr+sizeof(ALIGN_SIZE(sizeof(struct irem)))
The lspecialvalue is at the previous 4 bytes from this, which may not
necessarily be in the struct if the struct size isn't aligned at a 8 byte
boundary.
*/ */
struct irem struct st_irem
{ {
struct remember *_pNext; /* Linked list of structures */ struct st_irem *next; /* Linked list of structures */
struct remember *_pPrev; /* Other link */ struct st_irem *prev; /* Other link */
char *_sFileName; /* File in which memory was new'ed */ char *filename; /* File in which memory was new'ed */
uint32 _uLineNum; /* Line number in above file */ uint32 linenum; /* Line number in above file */
uint32 _uDataSize; /* Size requested */ uint32 datasize; /* Size requested */
#if SIZEOF_CHARP == 8 uint32 SpecialValue; /* Underrun marker value */
long _filler; /* For alignment */
#endif
long _lSpecialValue; /* Underrun marker value */
}; };
struct remember {
struct irem tInt;
char aData[1];
};
extern char NEAR curr_dir[FN_REFLEN],NEAR home_dir_buff[FN_REFLEN]; extern char NEAR curr_dir[FN_REFLEN],NEAR home_dir_buff[FN_REFLEN];
...@@ -70,8 +66,8 @@ extern int _my_tempnam_used; ...@@ -70,8 +66,8 @@ extern int _my_tempnam_used;
#endif #endif
extern byte *sf_min_adress,*sf_max_adress; extern byte *sf_min_adress,*sf_max_adress;
extern uint cNewCount; extern uint sf_malloc_count;
extern struct remember *pRememberRoot; extern struct st_irem *sf_malloc_root;
#if defined(THREAD) && !defined(__WIN__) #if defined(THREAD) && !defined(__WIN__)
extern sigset_t my_signals; /* signals blocked by mf_brkhant */ extern sigset_t my_signals; /* signals blocked by mf_brkhant */
......
This diff is collapsed.
...@@ -4292,7 +4292,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), ...@@ -4292,7 +4292,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
break; break;
case OPT_SAFEMALLOC_MEM_LIMIT: case OPT_SAFEMALLOC_MEM_LIMIT:
#if !defined(DBUG_OFF) && defined(SAFEMALLOC) #if !defined(DBUG_OFF) && defined(SAFEMALLOC)
safemalloc_mem_limit = atoi(argument); sf_malloc_mem_limit = atoi(argument);
#endif #endif
break; break;
#ifdef EMBEDDED_LIBRARY #ifdef EMBEDDED_LIBRARY
......
...@@ -1208,9 +1208,10 @@ bool dispatch_command(enum enum_server_command command, THD *thd, ...@@ -1208,9 +1208,10 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
opened_tables,refresh_version, cached_tables(), opened_tables,refresh_version, cached_tables(),
uptime ? (float)thd->query_id/(float)uptime : 0); uptime ? (float)thd->query_id/(float)uptime : 0);
#ifdef SAFEMALLOC #ifdef SAFEMALLOC
if (lCurMemory) // Using SAFEMALLOC if (sf_malloc_cur_memory) // Using SAFEMALLOC
sprintf(strend(buff), " Memory in use: %ldK Max memory used: %ldK", sprintf(strend(buff), " Memory in use: %ldK Max memory used: %ldK",
(lCurMemory+1023L)/1024L,(lMaxMemory+1023L)/1024L); (sf_malloc_cur_memory+1023L)/1024L,
(sf_malloc_max_memory+1023L)/1024L);
#endif #endif
VOID(my_net_write(net, buff,(uint) strlen(buff))); VOID(my_net_write(net, buff,(uint) strlen(buff)));
VOID(net_flush(net)); VOID(net_flush(net));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment