Hi,
I saw your solution for mallocblksize and, as I am not a good programer, I am asking for your help, if you please.
The two files listed below contains calls to mallocblksize, as you can see.
I am running Red Hat 7.0 (w/ kernel 2.2.16), gcc, g77, libstdc++ from the original distribution, and libg++_2.8.1.3.
The two files belong to a SGI-designed program. The makefiles contains appropriate flags for the GNU compiler (I guess GNU for SGI).
My problem is: the compilation fails when the mallocblksize is encountered (is normal since mallocblksize is a characteristic function for IRIX).
Please, can you (or will you) tell me where should I introduce yours
>> size_t mallocblksize
>> {
>> return ((long*)ptr-[1]-1;
>> }
so the compilation process pass on?
Should these lines be introduced in a particular malloc.h, or perhaps, in a particulat stdlib.h?
Thanks for helping me,
Iulian
P.S. I found this topic searching with
www.metacrawler.com, and I've got only 10 (ten) refferences.
P.S.2 SORRY for the very long post.
// this particular file was saved in PC format
// ===========================================
// this is Memory.C file
// ===========================================
#include <malloc.h>
#include <stdio.h>
#include <sys/types.h>
#include <Utils.d/Memory.h>
long long currentSize = 0;
long long deletedSize = 0;
void * operator new( size_t size )
{
void *ptr = malloc( size );
size_t allocatedMemory = mallocblksize(ptr);
currentSize += allocatedMemory;
//fprintf(stderr,"Allocate %14d bytes %14d bytes\n",
// allocatedMemory,currentSize);
return ptr;
}
void operator delete(void *p)
{
size_t deletedMemory = mallocblksize(p);
deletedSize += deletedMemory;
currentSize -= deletedMemory;
//fprintf(stderr,"De-allocate %14d bytes %14d bytes\n",
// deletedMemory,currentSize);
free(p);
}
long long
memoryUsed()
{
return currentSize;
}
long long
memoryDeleted()
{
return deletedSize;
}
// end of Memory.C file
// ==========================================
// ==========================================
// this is Memory.h file
// ==========================================
#ifndef _MEMORY_H_
#define _MEMORY_H_
// function to return memory used
long long memoryUsed();
long long memoryDeleted();
#endif
// end of Memory.h file
// ===========================================