Fix a few bugs in our CompressionJobList's

This commit is contained in:
Pavel Krajcevski 2013-03-11 14:41:08 -04:00
parent ae2324153d
commit 7c3b3d8144
2 changed files with 14 additions and 7 deletions

View file

@ -126,9 +126,6 @@ struct CompressionJobList {
const CompressionJob *GetJob(uint32 idx) const;
uint32 *GetFinishedFlag(uint32 idx) const;
ALIGN(32) uint32 m_CurrentBlockIndex;
ALIGN(32) uint32 m_CurrentJobIndex;
private:
CompressionJob *m_Jobs;
uint32 m_NumJobs;
@ -137,6 +134,10 @@ struct CompressionJobList {
struct FinishedFlag{
ALIGN(32) uint32 m_flag;
} *m_FinishedFlags;
public:
ALIGN(32) uint32 m_CurrentJobIndex;
ALIGN(32) uint32 m_CurrentBlockIndex;
};
#endif // __COMPRESSION_JOBS_H__

View file

@ -53,6 +53,8 @@
CompressionJobList::CompressionJobList(const uint32 nJobs)
: m_NumJobs(0)
, m_TotalNumJobs(nJobs)
, m_CurrentJobIndex(0)
, m_CurrentBlockIndex(0)
{
m_FinishedFlags = new FinishedFlag[nJobs];
memset(m_FinishedFlags, 0, nJobs * sizeof(m_FinishedFlags[0]));
@ -69,6 +71,8 @@ CompressionJobList::~CompressionJobList() {
CompressionJobList::CompressionJobList(const CompressionJobList &other)
: m_NumJobs(other.m_NumJobs)
, m_TotalNumJobs(other.m_TotalNumJobs)
, m_CurrentJobIndex(other.m_CurrentJobIndex)
, m_CurrentBlockIndex(other.m_CurrentBlockIndex)
{
uint32 arraySz = m_TotalNumJobs * sizeof(m_Jobs[0]);
m_Jobs = (CompressionJob *)malloc(arraySz);
@ -82,6 +86,8 @@ CompressionJobList &CompressionJobList::operator =(const CompressionJobList &oth
assert(m_TotalNumJobs == other.m_TotalNumJobs);
m_NumJobs = other.m_NumJobs;
m_CurrentJobIndex = other.m_CurrentJobIndex;
m_CurrentBlockIndex = other.m_CurrentBlockIndex;
// Get rid of old variables...
free(m_Jobs);
@ -108,7 +114,7 @@ bool CompressionJobList::AddJob(const CompressionJob &cj) {
}
const CompressionJob *CompressionJobList::GetJob(uint32 idx) const {
if(idx <= m_NumJobs) {
if(idx >= m_NumJobs) {
return NULL;
}
@ -116,7 +122,7 @@ const CompressionJob *CompressionJobList::GetJob(uint32 idx) const {
}
uint32 *CompressionJobList::GetFinishedFlag(uint32 idx) const {
if(idx <= m_NumJobs) {
if(idx >= m_NumJobs) {
return NULL;
}