struct abufhead {
struct b_queue abq; /* Links on allocated queue */
unsigned ablen; /* Buffer length in bytes */
- char *abfname; /* File name pointer */
+ const char *abfname; /* File name pointer */
sm_ushort ablineno; /* Line number of allocation */
};
/* SMALLOC -- Allocate buffer, enqueing on the orphaned buffer
tracking list. */
-static void *smalloc(char *fname, int lineno, unsigned int nbytes)
+static void *smalloc(const char *fname, int lineno, unsigned int nbytes)
{
char *buf;
/* SM_NEW_OWNER -- Update the File and line number for a buffer
This is to accomodate mem_pool. */
-void sm_new_owner(char *fname, int lineno, char *buf)
+void sm_new_owner(const char *fname, int lineno, char *buf)
{
buf -= HEAD_SIZE; /* Decrement to header */
((struct abufhead *)buf)->abfname = bufimode ? NULL : fname;
free(x) is defined to generate a call to this
routine. */
-void sm_free(char *file, int line, void *fp)
+void sm_free(const char *file, int line, void *fp)
{
char *cp = (char *) fp;
struct b_queue *qp;
/* SM_MALLOC -- Allocate buffer. NULL is returned if no memory
was available. */
-void *sm_malloc(char *fname, int lineno, unsigned int nbytes)
+void *sm_malloc(const char *fname, int lineno, unsigned int nbytes)
{
void *buf;
/* SM_CALLOC -- Allocate an array and clear it to zero. */
-void *sm_calloc(char *fname, int lineno,
+void *sm_calloc(const char *fname, int lineno,
unsigned int nelem, unsigned int elsize)
{
void *buf;
This may result in programs which make heavy use of
realloc() running much slower than normally. */
-void *sm_realloc(char *fname, int lineno, void *ptr, unsigned int size)
+void *sm_realloc(const char *fname, int lineno, void *ptr, unsigned int size)
{
unsigned osize;
void *buf;
#undef sm_check
/* SM_CHECK -- Check the buffers and dump if any damage exists. */
-void sm_check(char *fname, int lineno, Boolean bufdump)
+void sm_check(const char *fname, int lineno, Boolean bufdump)
{
if (!sm_check_rtn(fname, lineno, bufdump)) {
Emsg2(M_ABORT, 0, "Damaged buffer found. Called from %s:%d\n",
#undef sm_check_rtn
/* SM_CHECK_RTN -- Check the buffers and return 1 if OK otherwise 0 */
-int sm_check_rtn(char *fname, int lineno, Boolean bufdump)
+int sm_check_rtn(const char *fname, int lineno, Boolean bufdump)
{
struct abufhead *ap;
int bad, badbuf = 0;
void * operator new(size_t size)
{
+// Dmsg1(000, "new called %d\n", size);
return sm_malloc(__FILE__, __LINE__, size);
}
void operator delete(void *buf)
{
+// Dmsg1(000, "free called 0x%x\n", buf);
sm_free(__FILE__, __LINE__, buf);
}