|
|
Back to UserFriendly Strip Comments Index
|
Help UFies! (c++ woes) | by tzulah | 2004-07-14 13:33:11 |
|
ok, I tried this: | by tzulah | 2004-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 tzulah | 2004-07-14 14:16:41 |
|
Uh, true, as long as your... | by williamashbless | 2004-07-14 14:59:52 |
|
|
[Todays Cartoon Discussion]
[News Index]
|
|