It’s been a pretty exciting week on the Ubuntuforums. We’ve expanded the Forum Council adding 2 new long time forum staff members bodhi.zazen and bapoumba, we are glad to have you on board
In addition to expanding the Forum Council we’ve also brought on 4 new staff cariboo907, forestpixie, tinivole and Michael.Godawski who have all excelled within the forums and were glad they excepted the invitation.
Welcome everyone!
[...] know that ubuntu-geek has already posted about this (and probably jacob too – way to steal my [...]
Ubuntu Forums News « Joe Blog’s
7 Apr 09 at 5:56 pm
I thought that I was noticing some changes in user name colors and positions lately…
Congrats to all who were promoted!
JenkinBr
8 Apr 09 at 10:20 am
hello everybody,
i have a big problem, but i don’t know how to resolve it.
please help me.
my problem is this –>
i wrote a program in c++ that compiled with g++ about ring buffer ,
my code is this :
/////////////
buffer::~buffer()
{
if(Buffer!=NULL)
free(Buffer); //free buffer that allocated
};
// allocate memory and fill buffer with filltext that is input function
Uchar buffer::init(Word FillText)
{
Lword i;
if(Buffer==NULL)
{
// cout<<”buf element :”<<bufElem<<” sizeof : “<<sizeof(int)<<endl;
Buffer=(Uchar *)calloc(bufElem,bufSize);//calloc() calls malloc() then initializes the data to all 0s.
//equal :p = malloc(m * n); memset(p, 0, m * n);
}
if(Buffer==NULL) {
return 0;
}
else{
bufLen=(Lword)bufElem*bufSize;
cout<<”FillText :”<<FillText<<endl;
for(i=0 ;i<bufLen;i+=2 ){
Buffer[i]=FillText;
cout<<”Bufer["<<i<<"]:”<<(int)Buffer[i]<0)
{
bufSize=Size;
bufLen=(Lword)bufElem*bufSize;
return 1;
}
else
{
return 0;
}
};
// get lenght of buffer
Word buffer::getBufSize(void)
{
return bufSize;
};
//set size of buffer for allocate memory
Uchar buffer::setBufElem(Word Elem)
{
if(Elem>0)
{
bufElem=Elem;
bufLen=(Lword)bufElem*bufSize;
return 1;
}
else
{
return 0;
}
};
//get size of allocated buffer
Word buffer::getBufElem(void)
{
return bufElem;
};
//set offset
Uchar buffer::setOffset(Word Pos)
{
if(bufType==RINGBUF)
{
if(abs(Pos)<bufLen)
{
Offset=Pos;
return 1;
}
else
{
Offset=0;
return 0;
}
}
else
{
if(((Lword)readPtr+abs(Pos))bufLen)
return 0;
if(bufType==RINGBUF) //if buff is ringbuffer
{
readPtr+=Offset;
if(readPtr>=bufLen)
readPtr-=bufLen;
for(Ptr=0;Ptr=bufLen)
readPtr=0;
}
Offset=0;
return (Size*Num);
}
else //if(bufType==SIMPLEBUF
{
readPtr+=Offset;
if(readPtr>=bufLen || (readPtr+Size*Num)>bufLen)
return 0;
memcpy((Uchar *)Dest,(Uchar *)&Buffer[readPtr],Size*Num);
}
};
//method : buffwrite
//purpose: write Into buffer
//befor write into buffer you must call setoffset
//Return Value: 0 upon failed, otherwise success.
Word buffer::bufWrite(Uchar *Src,Word Size,Word Num)
{
Word Ptr=0,i=0;
if(((Lword)Size*Num)>bufLen)
return 0;
if(bufType==RINGBUF)
{
writePtr+=Offset;
if(writePtr>=bufLen)
writePtr-=bufLen;
for(Ptr=0;Ptr=bufLen)
writePtr=0;
// cout<buffer["<=bufLen || (writePtr+Size*Num)>bufLen)
return 0;
memcpy((Uchar *)&Buffer[writePtr],(Uchar *)Src,Size*Num);
}
};
////////////
i used the void * value for pointer to buffer but g++ give error ,
i know that must be of gcc and in g++ give me error but i want to find a way to resolve this problem and define a value that get all of type value.
please help me .
thanks and best regards.
farzaneh
13 Apr 09 at 7:30 am