The Daily Static
  The Daily Static
UF Archives
Register
UF Membership
Ad Free Site
Postcards
Community

Geekfinder
UFie Gear
Advertise on UF

Forum Rules
& FAQ


Username

Password


Create a New Account

 
 

Back to UserFriendly Strip Comments Index

Help UFies! (c++ woes) by tzulah2004-07-14 13:33:11
  ok, I tried this: by tzulah2004-07-14 14:00:23
    Uh... by williamashbless 2004-07-14 14:08:24
Right, so what is it that PerformMagic is meant to do with the buffer pointer you give it?

Until you know that, just passing it a pointer to some memory is plain silly.

Consider: If the behaviour of PerformMagic is to write 20 bytes of serial data to the address you gave it, which is the address of a 4 byte integer value, you've just smashed a bunch of memory you didn't mean to.

On the other hand, if PerformMagic is meant to pull a floating point value out of the memory to which the buffer points, you've allowed it to try to interpret a 4 byte integer as a floating point value. Which also doesn't make sense.

Void pointers are _dangerous_ because they point to arbitrary memory (assuming you point them somewhere).

No information _at_ _all_ is available to PerformMagic about what you pointed the pointer at, if anything. This means that PerformMagic can do no checking, and that it has to blindly assume that you've pointed it at whatever it really needs to do its work.

This means you must be _absolutely_ _clear_ on what the pointer is meant to point to, when passing it off to some function to do something.


[ Reply ]
      Like I said, I am expected an integer by tzulah2004-07-14 14:16:41
        Uh, true, as long as your... by williamashbless2004-07-14 14:59:52

 

[Todays Cartoon Discussion] [News Index]

Come get yer ARS (Account Registration System) Source Code here!
All images, characters, content and text are copyrighted and trademarks of J.D. Frazer except where other ownership applies. Don't do bad things, we have lawyers.
UserFriendly.Org and its operators are not liable for comments or content posted by its visitors, and will cheerfully assist the lawful authorities in hunting down script-kiddies, spammers and other net scum. And if you're really bad, we'll call your mom. (We're not kidding, we've done it before.)