1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-07 00:04:31 +03:00

Indentation

This commit is contained in:
monty@narttu.mysql.fi
2003-06-12 16:25:26 +03:00
parent d640ff4a97
commit a79bdf2ee7

View File

@@ -1,4 +1,4 @@
/* Copyright (C) 2000 MySQL AB /* Copyright (C) 2000-2003 MySQL AB
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@@ -92,11 +92,11 @@ static int sf_malloc_tampered = 0;
static int check_ptr(const char *where, byte *ptr, const char *sFile, static int check_ptr(const char *where, byte *ptr, const char *sFile,
uint uLine); uint uLine);
static int _checkchunk(struct remember *pRec, const char *sFile, uint uLine); static int _checkchunk(struct irem *pRec, const char *sFile, uint uLine);
/* /*
Note: both these refer to the NEW'ed data only. They do not include Note: We only fill up the allocated block. This do not include
malloc() roundoff or the extra space required by the remember malloc() roundoff or the extra space required by the irem
structures. structures.
*/ */
@@ -133,7 +133,6 @@ gptr _mymalloc (uint uSize, const char *sFile, uint uLine, myf MyFlags)
DBUG_ENTER("_mymalloc"); DBUG_ENTER("_mymalloc");
DBUG_PRINT("enter",("Size: %u",uSize)); DBUG_PRINT("enter",("Size: %u",uSize));
if (!sf_malloc_quick) if (!sf_malloc_quick)
(void) _sanity (sFile, uLine); (void) _sanity (sFile, uLine);
@@ -142,12 +141,11 @@ gptr _mymalloc (uint uSize, const char *sFile, uint uLine, myf MyFlags)
else else
{ {
/* Allocate the physical memory */ /* Allocate the physical memory */
pTmp = (struct remember *) malloc ( pTmp= (struct remember *) malloc (ALIGN_SIZE(sizeof(struct irem)) +
ALIGN_SIZE(sizeof(struct irem)) /* remember data */ sf_malloc_prehunc +
+ sf_malloc_prehunc uSize + /* size requested */
+ uSize /* size requested */ 4 + /* overrun mark */
+ 4 /* overrun mark */ sf_malloc_endhunc
+ sf_malloc_endhunc
); );
} }
/* Check if there isn't anymore memory avaiable */ /* Check if there isn't anymore memory avaiable */
@@ -174,7 +172,7 @@ gptr _mymalloc (uint uSize, const char *sFile, uint uLine, myf MyFlags)
} }
/* Fill up the structure */ /* Fill up the structure */
*((long*) ((char*) &pTmp -> lSpecialValue+sf_malloc_prehunc)) = MAGICKEY; *((uint32*) ((char*) &pTmp->lSpecialValue+sf_malloc_prehunc))= MAGICKEY;
pTmp->aData[uSize + sf_malloc_prehunc+0]= MAGICEND0; pTmp->aData[uSize + sf_malloc_prehunc+0]= MAGICEND0;
pTmp->aData[uSize + sf_malloc_prehunc+1]= MAGICEND1; pTmp->aData[uSize + sf_malloc_prehunc+1]= MAGICEND1;
pTmp->aData[uSize + sf_malloc_prehunc+2]= MAGICEND2; pTmp->aData[uSize + sf_malloc_prehunc+2]= MAGICEND2;
@@ -187,16 +185,13 @@ gptr _mymalloc (uint uSize, const char *sFile, uint uLine, myf MyFlags)
/* Add this remember structure to the linked list */ /* Add this remember structure to the linked list */
pthread_mutex_lock(&THR_LOCK_malloc); pthread_mutex_lock(&THR_LOCK_malloc);
if ((pTmp->pNext= pRememberRoot)) if ((pTmp->pNext= pRememberRoot))
{
pRememberRoot->pPrev= pTmp; pRememberRoot->pPrev= pTmp;
}
pRememberRoot= pTmp; pRememberRoot= pTmp;
/* Keep the statistics */ /* Keep the statistics */
lCurMemory+= uSize; lCurMemory+= uSize;
if (lCurMemory > lMaxMemory) { if (lCurMemory > lMaxMemory)
lMaxMemory= lCurMemory; lMaxMemory= lCurMemory;
}
cNewCount++; cNewCount++;
pthread_mutex_unlock(&THR_LOCK_malloc); pthread_mutex_unlock(&THR_LOCK_malloc);
@@ -236,7 +231,7 @@ gptr _myrealloc (register gptr pPtr, register uint uSize,
pRec= (struct remember *) ((char*) pPtr - ALIGN_SIZE(sizeof(struct irem))- pRec= (struct remember *) ((char*) pPtr - ALIGN_SIZE(sizeof(struct irem))-
sf_malloc_prehunc); sf_malloc_prehunc);
if (*((long*) ((char*) &pRec -> lSpecialValue+sf_malloc_prehunc)) if (*((uint32*) ((char*) &pRec->lSpecialValue+sf_malloc_prehunc))
!= MAGICKEY) != MAGICKEY)
{ {
fprintf(stderr, "Error: Reallocating unallocated data at line %d, '%s'\n", fprintf(stderr, "Error: Reallocating unallocated data at line %d, '%s'\n",
@@ -292,7 +287,7 @@ void _myfree (gptr pPtr, const char *sFile, uint uLine, myf myflags)
(4) A stray pointer hit this location (4) A stray pointer hit this location
*/ */
if (*((long*) ((char*) &pRec -> lSpecialValue+sf_malloc_prehunc)) if (*((uint32*) ((char*) &pRec->lSpecialValue+sf_malloc_prehunc))
!= MAGICKEY) != MAGICKEY)
{ {
fprintf(stderr, "Error: Freeing unallocated data at line %d, '%s'\n", fprintf(stderr, "Error: Freeing unallocated data at line %d, '%s'\n",
@@ -304,14 +299,13 @@ void _myfree (gptr pPtr, const char *sFile, uint uLine, myf myflags)
/* Remove this structure from the linked list */ /* Remove this structure from the linked list */
pthread_mutex_lock(&THR_LOCK_malloc); pthread_mutex_lock(&THR_LOCK_malloc);
if (pRec -> pPrev) { if (pRec->pPrev)
pRec->pPrev->pNext= pRec->pNext; pRec->pPrev->pNext= pRec->pNext;
} else { else
pRememberRoot= pRec->pNext; pRememberRoot= pRec->pNext;
}
if (pRec -> pNext) { if (pRec->pNext)
pRec->pNext->pPrev= pRec->pPrev; pRec->pNext->pPrev= pRec->pPrev;
}
/* Handle the statistics */ /* Handle the statistics */
lCurMemory -= pRec->uDataSize; lCurMemory -= pRec->uDataSize;
cNewCount--; cNewCount--;
@@ -322,7 +316,7 @@ void _myfree (gptr pPtr, const char *sFile, uint uLine, myf myflags)
if (!sf_malloc_quick) if (!sf_malloc_quick)
bfill(&pRec->aData[sf_malloc_prehunc],pRec->uDataSize,(pchar) FREE_VAL); bfill(&pRec->aData[sf_malloc_prehunc],pRec->uDataSize,(pchar) FREE_VAL);
#endif #endif
*((long*) ((char*) &pRec -> lSpecialValue+sf_malloc_prehunc)) = ~MAGICKEY; *((uint32*) ((char*) &pRec->lSpecialValue+sf_malloc_prehunc))= ~MAGICKEY;
/* Actually free the memory */ /* Actually free the memory */
free ((my_string ) pRec); free ((my_string ) pRec);
@@ -403,7 +397,8 @@ void TERMINATE (FILE *file)
{ {
if (file) if (file)
{ {
fprintf(file, "Warning: Memory that was not free'ed (%ld bytes):\n",lCurMemory); fprintf(file, "Warning: Memory that was not free'ed (%ld bytes):\n",
lCurMemory);
(void) fflush(file); (void) fflush(file);
} }
DBUG_PRINT("safe",("Memory that was not free'ed (%ld bytes):",lCurMemory)); DBUG_PRINT("safe",("Memory that was not free'ed (%ld bytes):",lCurMemory));
@@ -450,7 +445,7 @@ static int _checkchunk (register struct remember *pRec, const char *sFile,
reg3 int flag=0; reg3 int flag=0;
/* Check for a possible underrun */ /* Check for a possible underrun */
if (*((long*) ((char*) &pRec -> lSpecialValue+sf_malloc_prehunc)) if (*((uint32*) ((char*) &pRec->lSpecialValue+sf_malloc_prehunc))
!= MAGICKEY) != MAGICKEY)
{ {
fprintf(stderr, "Error: Memory allocated at %s:%d was underrun,", fprintf(stderr, "Error: Memory allocated at %s:%d was underrun,",