[Coco] question C++

Luis Fernández luis46coco at hotmail.com
Wed Mar 21 23:32:49 EDT 2012



Thanks, I hope to understand this format, which is extremely complex

---------------------------------------------------------------------------------
Making
CoCoDskUtilPack V 1.0.10.zip
http://cococoding.com/cocodskutil/ Thank Aaron Wolfe
My personal blog: http://www.luis45ccs.blogspot.com
---------------------------------------------------------------------------------


> Date: Thu, 22 Mar 2012 14:50:30 +1100

> From: jekent at optusnet.com.au

> To: coco at maltedmedia.com

> Subject: Re: [Coco] question C++

>

>

>

> On 22/03/2012 1:30 AM, Mark McDougall wrote:

> > On 22/03/2012 12:03 AM, Luis Fernández wrote:

> >

> >> ANYONE can tell me the meaning& here

> >> write_buf (h, 1,& val);

> >

> > The '&' is the 'address of' operator, so it passes the address of the

> > 'val' variable.

> >

> >> static void write_buf_const (dmk_handle h, int count, uint8_t val)

> >> {

> >> while (count--)

> >> write_buf (h, 1, &val);

> >> }

> >

> > This looks like it writes 'count' number of pad bytes of value 'val'.

> >

> > Regards,

> >

>

> val is passed on the stack to the write_buf_const procedure.

> I assume dmk_handle is a type definition for a structure pointer type

> for the buffer.

> "handle" I suspect refers to a pointer type.

>

> so you might have something like

>

> struct dmk_buff {

> unit8_t *inptr;

> unit8_t *outptr;

> int count;

> uint8_t buffer[MAX_BUF_SIZE]]

> };

>

> typdef struct dmk_buff *dmk_handle;

>

> although the _t in uint8_t indicates that it is a type definition, and

> dmk_handle does not indicate it's a type definition, but I assume it is.

>

> anyway .... what it seems to be doing is passing the address of val to

> the write_buf routine and the write_buf routine will access val via it's

> address passed as a pointer value . i.e.

>

> void write_buf( dmk_handle h, int fill_count, uint8_t *valptr )

> {

> int i;

>

> h->inptr = &h->buffer[h->count];

> for( i=0; i<fill_count; i++ )

> {

> *h->inptr++ = *valptr;

> h->count++;

> }

> }

>

>

> unit8_count will be 1.

> write_buf will fetch val, using it's address and write it to the buffer

> via the input pointer

>

> h->count mean that h is pointing to a structure contain a member

> variable "count".

>

> I hope that's right.

>

> John.

>

> --

> http://www.johnkent.com.au

> http://members.optusnet.com.au/jekent

>

>

> --

> Coco mailing list

> Coco at maltedmedia.com

> http://five.pairlist.net/mailman/listinfo/coco




More information about the Coco mailing list