Salut Patrick,

I see 3 problems :

1) what you want to do is sizeof(MdmInfoType) and not sizeof(MdmInfoPtr).
2) you should cast the return value from MemPtrNew to (MdmInfoPtr).
3) you shoud check that return value before using id.

(2) and (3) are optional, but recommended.
(1) is the cause of your error message, since you allocate space for a
pointer (sizeof(MdmInfoPtr) = 4 bytes) and not for the whole structure
(sizeof(MdmInfoType) = slightly more). Thus, the first attempt to write
(bytes 0 and 1) works, but not the second (bytes 2, 3, 4 and 5), as it is
out of the bounds of the allocated 4 bytes of memory...

Cordialement,

-- Denis Faivre - [EMAIL PROTECTED]
-- Ablivio - http://www.ablivio.com


----- Message d'origine -----
De : "Patrick Ouellet" <[EMAIL PROTECTED]>
Groupes de discussion : palm-dev-forum
À : "Palm Developer Forum" <[email protected]>
Envoyé : vendredi 8 septembre 2000 15:20
Objet : Writing directly to memory...


> POSE is telling me that Im doing a
> direct memory write and that I shouldn't.
>
> Ok I know I shouldn't but...
> here's the code
>
>   UInt SerNum = 0;
>   FormPtr frmP;
>  MdmInfoPtr modemP;
>  CharPtr okDialP;
>  CharPtr setupP;
>  Err ModemErr;
>
>  frmP = FrmGetActiveForm();
>
>  modemP = MemPtrNew(sizeof(MdmInfoPtr));
>  okDialP = MemPtrNew(sizeof(CharPtr));
>
>  modemP->serRefNum = SerNum;
>  modemP->initialBaud = 14400L;            **
>  modemP->dtWaitSec = -1;
>  modemP->dcdWaitSec = -1;
>  modemP->volume = 3;
>  modemP->hwHShake = true;
>  modemP->autoBaud = false;
>
> The error happen at the line: modemP->initialBaud = 14400L;
> what Am I doing wrong ????
>
>
>
> --
> For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/tech/support/forums/
>



-- 
For information on using the ACCESS Developer Forums, or to unsubscribe, please 
see http://www.access-company.com/developers/forums/

Reply via email to