void
    FreeListAllocator::printDebugInfo( std::ostream& out ) const
    {
        void * pend;
        out << "FreeListAllocator(" << this << "):\n";
        out << "\tBlock Start: " << getBlock() << "\n";
        out << "\tBlock Size: " << getSize() << " bytes\n";
        out << "\tBlock End:  " << (pend = (void*)(reinterpret_cast<uintptr_t>(getBlock())+getSize())) << "\n";
        out << "\tUsed Memory: " << usedMemory() << " bytes\n";
        out << "\tUnused Memory: " << unusedMemory() << " bytes\n";
        out << "\tNumber of Allocations: " << numAllocations() << "\n";
        out << "\tMax Used Memory: " << maxUsedMemory() << " bytes\n";
        out << "\tMax Number of Allocations: " << maxNumAllocations() << "\n";
        //out << "\tNumber of deallocLoops: " << deallocLoops << "\n";

        if(true)
        {
            out << "{\n";
            out << "\tfree:\n\t{\n";
            std::size_t numFreeBlocks = 0;
            _FreeBlock * curr_block = _free_blocks;
            while( curr_block != nullptr && (void*)curr_block >= _block_start && (void*)curr_block < pend)
            {

                out << "\t\taddr:" << curr_block << ",size:" << curr_block->size << ",end:" << (void*)(reinterpret_cast<uintptr_t>(curr_block)+curr_block->size) << ",next:" << curr_block->next << "\n";
                curr_block = curr_block->next;
                ++numFreeBlocks;
            }
            out << "\t}(freeBlocks:" << numFreeBlocks << ");\n";
            out << "};\n";
        }
    }
Beispiel #2
0
char *getData(){
    
    int totmem = totalMemory();
    char *TOTAL_MEMORY = formatInt(totmem);
    
    float freemem = freeMemory();
    float usedmem = usedMemory();
    char *FREE_MEMORY = formatFloat(freemem);
    char *USED_MEMORY = formatFloat(usedmem);
    
    double loadavg[1];
    getloadavg(loadavg, 1);
    char *CPU_LOAD_AVG = formatDouble(loadavg[0] * 10);
    
    double cpuLoad = getCpuReading();
    char *CPU_LOAD_CURR = formatDouble(cpuLoad);
    
    double cpuTemp = getCpuTemp();
    char *CPU_TEMP = formatDouble(cpuTemp);
    
    char host[40];//cuts username off if more than 40 characters.
    gethostname(host, sizeof(host));
    char HOSTNAME[40] ="|";
    strcat(HOSTNAME,host);
    
    int hostlen = strlen(HOSTNAME);
    for (int s = hostlen; s <40; s++){//fill excess space to prevent overflows.
        strcpy(&HOSTNAME[s], " ");
    }
    
    char *data = new char[75]; //original 35
    strcpy(data,HOSTNAME);
    strcat(data,TOTAL_MEMORY);
    strcat(data,FREE_MEMORY);
    strcat(data,USED_MEMORY);
    strcat(data,CPU_LOAD_AVG);
    strcat(data,CPU_LOAD_CURR);
    strcat(data,CPU_TEMP);
    return data;
}