Click here to Skip to main content
15,908,020 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Dangling pointers and incorrect data being written Pin
Stuart Dootson17-Dec-08 2:34
professionalStuart Dootson17-Dec-08 2:34 
GeneralRe: Dangling pointers and incorrect data being written Pin
Mustafa Ismail Mustafa17-Dec-08 4:47
Mustafa Ismail Mustafa17-Dec-08 4:47 
GeneralRe: Dangling pointers and incorrect data being written Pin
Stuart Dootson17-Dec-08 5:18
professionalStuart Dootson17-Dec-08 5:18 
GeneralRe: Dangling pointers and incorrect data being written [modified] Pin
Mustafa Ismail Mustafa17-Dec-08 5:52
Mustafa Ismail Mustafa17-Dec-08 5:52 
GeneralRe: Dangling pointers and incorrect data being written Pin
Stuart Dootson17-Dec-08 6:25
professionalStuart Dootson17-Dec-08 6:25 
GeneralRe: Dangling pointers and incorrect data being written Pin
Mustafa Ismail Mustafa17-Dec-08 6:35
Mustafa Ismail Mustafa17-Dec-08 6:35 
GeneralRe: Dangling pointers and incorrect data being written Pin
Mustafa Ismail Mustafa14-Dec-08 21:12
Mustafa Ismail Mustafa14-Dec-08 21:12 
GeneralRe: Dangling pointers and incorrect data being written Pin
Mustafa Ismail Mustafa14-Dec-08 21:26
Mustafa Ismail Mustafa14-Dec-08 21:26 
Here they are:

<br />
CacheBlock:<br />
<br />
/* <br />
 * File:   cacheblock.h<br />
 * Author: Steve<br />
 *<br />
 * Created on December 9, 2008, 2:44 PM<br />
 */<br />
<br />
#ifndef _CACHEBLOCK_H<br />
#define	_CACHEBLOCK_H<br />
<br />
#include <time.h><br />
#include "definitions.h"<br />
#include "settings.h"<br />
<br />
using namespace std;<br />
<br />
class CacheBlock<br />
{<br />
<br />
public:<br />
    CacheBlock();<br />
    CacheBlock(const CacheBlock& orig);<br />
    CacheBlock(int maxOffset, uint bTag, uint bIndex,<br />
               bool isValid, char* bData);<br />
    virtual ~CacheBlock();<br />
<br />
    //Block Offset<br />
    int getMaxBlockOffset() const;<br />
    void setMaxBlockOffset(int const &value);<br />
<br />
    //block tag<br />
    uint  getBlockTag() const;<br />
    void setBlockTag(uint &value);<br />
<br />
    //block index<br />
    uint getBlockIndex() const;<br />
    void setBlockIndex(uint & value);<br />
<br />
    //Is Valid<br />
    bool getIsValid() const;<br />
    void setIsValid(bool const &value);<br />
<br />
    //Block Data - Complete block (offsets 0 - max)<br />
    char* getBlockData() const;<br />
    void setBlockData(char* const &value);<br />
<br />
    //Block Data Item<br />
    char getBlockDataItem(int &offset) const;<br />
    void setBlockDataItem(int const &offset,char const &value);<br />
<br />
    //Time Stamp<br />
    time_t getTimeStamp() const;<br />
    void setTimeStamp(time_t const  &value);<br />
<br />
    //Initializaton<br />
    void Initialize(int maxOffset, uint bTag,<br />
                    uint bIndex, bool isValid, char* bData);<br />
<br />
    //block number<br />
    uint getBlockNumber() const;<br />
    void setBlockNumber(uint const &value);<br />
<br />
    //block Address<br />
    uint getBlockAddress() const;<br />
    void setBlockAddress(uint const &value);<br />
<br />
    /*Calculate the Block address from the memory address*/<br />
    uint CalculateBlockAddress(uint const &memoryAddress) const;<br />
<br />
    //Settings<br />
    Settings* getSettings() const;<br />
    void setSettings(Settings &value);<br />
private:<br />
<br />
    int m_MaxBlockOffset;<br />
    uint m_BlockTag;<br />
    uint m_BlockIndex;<br />
    char* m_BlockData;<br />
    time_t m_Timestamp;<br />
    bool m_IsValid;<br />
    uint m_BlockNumber;<br />
    uint m_BlockAddress;<br />
    Settings* m_Settings;<br />
};<br />
<br />
#endif	/* _CACHEBLOCK_H */<br />
<br />
/* <br />
 * File:   cacheblock.cpp<br />
 * Author: Steve<br />
 * <br />
 * Created on December 9, 2008, 2:44 PM<br />
 */<br />
<br />
#include "cacheblock.h"<br />
<br />
CacheBlock::CacheBlock()<br />
{}<br />
<br />
CacheBlock::CacheBlock(const CacheBlock& orig)<br />
{<br />
}<br />
<br />
CacheBlock::CacheBlock(int maxOffset, uint bTag,<br />
                       uint bIndex, bool isValid, char* bData)<br />
{<br />
    setMaxBlockOffset(maxOffset);<br />
    setBlockTag(bTag);<br />
    setBlockIndex(bIndex);<br />
    setIsValid(isValid);<br />
    setBlockData(bData);<br />
}<br />
<br />
CacheBlock::~CacheBlock()<br />
{}<br />
<br />
/* Block Index */<br />
uint CacheBlock::getBlockIndex() const<br />
{<br />
    return m_BlockIndex;<br />
}<br />
<br />
void CacheBlock::setBlockIndex(uint &value )<br />
{<br />
    m_BlockIndex = value;<br />
}<br />
<br />
/*Block Tag*/<br />
uint CacheBlock::getBlockTag() const<br />
{<br />
    return m_BlockTag;<br />
}<br />
<br />
void CacheBlock::setBlockTag(uint  &value)<br />
{<br />
    m_BlockTag = value;<br />
}<br />
<br />
/*Block Data*/<br />
char* CacheBlock::getBlockData() const<br />
{<br />
    return m_BlockData;<br />
}<br />
<br />
void CacheBlock::setBlockData(char* const &value)<br />
{<br />
    m_BlockData = value;<br />
}<br />
<br />
/*Is Valid*/<br />
bool CacheBlock::getIsValid() const<br />
{<br />
    return m_IsValid;<br />
}<br />
<br />
void CacheBlock::setIsValid(bool  const &value)<br />
{<br />
    m_IsValid = value;<br />
}<br />
<br />
/*Block Data Item*/<br />
char CacheBlock::getBlockDataItem(int &offset) const<br />
{<br />
    return getBlockData()[offset];<br />
}<br />
<br />
void CacheBlock::setBlockDataItem(int const &offset, char const &value)<br />
{<br />
    getBlockData()[offset] = value;<br />
}<br />
<br />
/*Max Block Offset (which is the length of the data array*/<br />
int CacheBlock::getMaxBlockOffset() const<br />
{<br />
    return m_MaxBlockOffset;<br />
}<br />
<br />
void CacheBlock::setMaxBlockOffset(int const &value)<br />
{<br />
    m_MaxBlockOffset = value;<br />
}<br />
<br />
<br />
/*Timestamp*/<br />
time_t CacheBlock::getTimeStamp() const<br />
{<br />
    return m_Timestamp;<br />
}<br />
<br />
void CacheBlock::setTimeStamp(time_t const &value)<br />
{<br />
    m_Timestamp = value;<br />
}<br />
<br />
/*Initialize*/<br />
void CacheBlock::Initialize(int maxOffset, uint bTag,<br />
                       uint bIndex, bool isValid, char* bData)<br />
{<br />
    setMaxBlockOffset(maxOffset);<br />
    setBlockTag(bTag);<br />
    setBlockIndex(bIndex);<br />
    setIsValid(isValid);<br />
    setBlockData(bData);<br />
    setTimeStamp(time(0));<br />
}<br />
<br />
/*Block Number*/<br />
uint CacheBlock::getBlockNumber() const<br />
{<br />
    return m_BlockNumber;<br />
}<br />
<br />
void CacheBlock::setBlockNumber(uint const &value)<br />
{<br />
    m_BlockNumber = value;<br />
}<br />
<br />
/*Block Address*/<br />
uint CacheBlock::getBlockAddress() const<br />
{<br />
    return m_BlockAddress;<br />
}<br />
<br />
void CacheBlock::setBlockAddress(uint const &value)<br />
{<br />
    m_BlockAddress = value;<br />
}<br />
<br />
uint  CacheBlock::CalculateBlockAddress(uint const &memoryAddress) const<br />
{<br />
    //the block address is the memory address, less the offset bits<br />
<br />
    uint ma = memoryAddress >> getSettings()->getOffsetParity();<br />
    return ma;<br />
}<br />
<br />
Settings* CacheBlock::getSettings() const<br />
{<br />
    return m_Settings;<br />
}<br />
<br />
void CacheBlock::setSettings(Settings &value)<br />
{<br />
    m_Settings = &value;<br />
}<br />
<br />
<br />
CacheSet:<br />
<br />
/* <br />
 * File:   cacheset.h<br />
 * Author: Steve<br />
 *<br />
 * Created on December 9, 2008, 3:28 PM<br />
 */<br />
<br />
#ifndef _CACHESET_H<br />
#define	_CACHESET_H<br />
<br />
#include "definitions.h"<br />
#include "settings.h"<br />
#include "cacheblock.h"<br />
<br />
class CacheSet<br />
{<br />
<br />
public:<br />
    CacheSet();<br />
    CacheSet(const CacheSet& orig);<br />
    CacheSet(int setIndex, int bCount, Settings const &settings);<br />
    virtual ~CacheSet();<br />
<br />
    /*Block Count*/<br />
    int getBlockCount() const;<br />
    void setBlockCount(int const &value);<br />
    <br />
    /*Set Index*/<br />
    int getSetIndex() const;<br />
    void setSetIndex(int const & value);<br />
    <br />
    /*Block Size*/<br />
    int getBlockSize() const ;<br />
    void setBlockSize(int const &value);<br />
    <br />
    /*CacheBlocks*/<br />
    vector<cacheblock> getCacheBlocks() const;<br />
    void setCacheBlocks(vector<CacheBlock> const &value);<br />
    <br />
    /*Settings*/<br />
    Settings getSettings() const;<br />
    void setSettings(Settings const &value);<br />
    <br />
private:<br />
    int m_BlockCount;<br />
    vector<CacheBlock> m_CacheBlocks;<br />
    int m_SetIndex;<br />
    int m_BlockSize;<br />
    Settings m_Settings;<br />
};<br />
<br />
#endif	/* _CACHESET_H */<br />
<br />
<br />
/* <br />
 * File:   cacheset.cpp<br />
 * Author: Steve<br />
 * <br />
 * Created on December 9, 2008, 3:28 PM<br />
 */<br />
<br />
#include "cacheset.h"<br />
<br />
CacheSet::CacheSet()<br />
{<br />
}<br />
<br />
CacheSet::CacheSet(const CacheSet& orig)<br />
{<br />
}<br />
<br />
CacheSet::CacheSet(int setIndex, int bCount, Settings const &settings)<br />
{<br />
    setBlockCount(bCount);<br />
    setSettings(settings);<br />
    setSetIndex(setIndex);<br />
<br />
    //initialize the CacheBlocks array<br />
    //setCacheBlocks() = new CacheBlock[bCount];<br />
    //setBlockSize(getSettings()->getBlocksSize());<br />
<br />
}<br />
<br />
CacheSet::~CacheSet()<br />
{<br />
}<br />
<br />
/*Block Size*/<br />
int CacheSet::getBlockSize() const<br />
{<br />
    return m_BlockSize;<br />
}<br />
<br />
void CacheSet::setBlockSize(int const & value)<br />
{<br />
    m_BlockSize = value;<br />
}<br />
<br />
/*Block Count*/<br />
int CacheSet::getBlockCount()const<br />
{<br />
    return m_BlockCount;<br />
}<br />
<br />
void CacheSet::setBlockCount(int const &value)<br />
{<br />
    m_BlockCount = value;<br />
}<br />
<br />
<br />
/*Cache Blocks*/<br />
vector<CacheBlock> CacheSet::getCacheBlocks() const<br />
{<br />
    return m_CacheBlocks;<br />
}<br />
<br />
void CacheSet::setCacheBlocks(vector<CacheBlock> const & value)<br />
{<br />
    m_CacheBlocks = value;<br />
}<br />
<br />
/*Settings*/<br />
Settings CacheSet::getSettings() const<br />
{<br />
    return m_Settings;<br />
}<br />
<br />
void CacheSet::setSettings(Settings const &value)<br />
{<br />
    m_Settings = value;<br />
}<br />
<br />
/*Set Index*/<br />
int CacheSet::getSetIndex() const<br />
{<br />
    return m_SetIndex;<br />
}<br />
<br />
void CacheSet::setSetIndex(int const &value)<br />
{<br />
    m_SetIndex = value;<br />
}<br />
<br />
</cacheblock>

I might have missed an angle bracket or two...

Don't forget to vote if the response was helpful


Sig history

"dad" Ishmail-Samuel Mustafa

Unix is a Four Letter Word, and Vi is a Two Letter Abbreviation

"There is no wealth like knowledge, no poverty like ignorance" Ali Ibn Abi Talib

QuestionDevelop CSP in XP Pin
izyani14-Dec-08 19:48
izyani14-Dec-08 19:48 
QuestionUsing Queue Timers...... Pin
shaina223114-Dec-08 19:22
shaina223114-Dec-08 19:22 
AnswerRe: Using Queue Timers...... Pin
Sarath C15-Dec-08 2:16
Sarath C15-Dec-08 2:16 
AnswerRe: Using Queue Timers...... Pin
Mark Salsbery15-Dec-08 11:27
Mark Salsbery15-Dec-08 11:27 
QuestionUpdating window data from other window Pin
kiranin14-Dec-08 19:16
kiranin14-Dec-08 19:16 
AnswerRe: Updating window data from other window Pin
Franck Paquier14-Dec-08 23:23
Franck Paquier14-Dec-08 23:23 
AnswerRe: Updating window data from other window Pin
ThatsAlok15-Dec-08 0:07
ThatsAlok15-Dec-08 0:07 
Questionhow to enumerate all the subwindows in a specified process? Pin
kcynic14-Dec-08 16:43
kcynic14-Dec-08 16:43 
AnswerRe: how to enumerate all the subwindows in a specified process? Pin
Sarath C14-Dec-08 18:34
Sarath C14-Dec-08 18:34 
AnswerRe: how to enumerate all the subwindows in a specified process? [modified] Pin
kcynic14-Dec-08 19:31
kcynic14-Dec-08 19:31 
QuestionHello can somebody explain me how many 0x90 can i add into BYTE / WORD / DWORD Pin
nah133714-Dec-08 11:05
nah133714-Dec-08 11:05 
AnswerRe: Hello can somebody explain me how many 0x90 can i add into BYTE / WORD / DWORD Pin
Mark Salsbery14-Dec-08 11:55
Mark Salsbery14-Dec-08 11:55 
GeneralRe: Hello can somebody explain me how many 0x90 can i add into BYTE / WORD / DWORD Pin
nah133714-Dec-08 19:11
nah133714-Dec-08 19:11 
AnswerRe: Hello can somebody explain me how many 0x90 can i add into BYTE / WORD / DWORD Pin
tmcgarr15-Dec-08 7:49
tmcgarr15-Dec-08 7:49 
QuestionSpeech-based Video Control Pin
llp00na14-Dec-08 9:03
llp00na14-Dec-08 9:03 
AnswerRe: Speech-based Video Control [modified] Pin
Jijo.Raj14-Dec-08 9:40
Jijo.Raj14-Dec-08 9:40 
GeneralRe: Speech-based Video Control Pin
llp00na15-Dec-08 1:23
llp00na15-Dec-08 1:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.