Re: Okay to use DmWrite() on ordinary memory?

2003-08-14 Thread Alan Ingleby
Keith Rollin [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
   Is it possible to use DmWrite() on ordinary memory?  I have cases
where

 Try it and see.  My suspicion is that is will probably fail, as DmWrite
is

 Ugh, I can't believe that advice just crossed this forum!  Using that
 logic, if I rob a house and don't get caught, it must be OK.  :-)

Err... My point was that if Todd want's an answer to such a simple question,
it's usually not very hard to just go out and get the answer yourself.  I
was not trying to judge the merits of *why* you would want to do it.

 Why can't you just keep track of the type of memory yourself, then use
the
 appropriate DmWrite or MemMove calls? Even if DmWrite happens to work, it
is
 always going to be slower than MemMove...

 Now, *this* is advice I like!  To it, I should add Even if using
 DmWrite works on non-storage heap memory now, there's nothing that
 says it won't in the future.

Nice to see I'm not completely full of bad ideas Mind you, I'm surprised
Aaron hasn't chimed in with advise on replacing all calls with MemMove,
wrapped around a liberal sprinkling of Semaphore tinkering. :-)

Todd, as you can see, you're not heading down the right path.  If you're
going to find it difficult to keep track of the type of pointer you're
dealing with, the legal way of handling your requirement is:

#define SafeUlgyDmWrite(a,b,c,d)
{MemPtrDataStorage(a)?DmWrite(a,b,c,d):MemMove(a+b,c,d);} /*Note - Untested
code... Use at you're own risk!!!*/

You can now use the aptly named SafeUlgyDmWrite to replace all your
DmWrites, and not care whether they're into Dynamic or Storage Memory.


Let me know if this helps.

Alan



-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/


Re: Okay to use DmWrite() on ordinary memory?

2003-08-14 Thread Alan Ingleby

Todd Niec [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Is it possible to use DmWrite() on ordinary memory?  I have cases where
 buffers might be stored in ordinary memory (stack, heap, or static
 globals) or might be in a record in a file and I would like 1 method
 to write to both of them.

Try it and see.  My suspicion is that is will probably fail, as DmWrite is
designed to stop you from writing to the wrong place etc, but you never
know...

Why can't you just keep track of the type of memory yourself, then use the
appropriate DmWrite or MemMove calls? Even if DmWrite happens to work, it is
always going to be slower than MemMove...



-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/


Re: Okay to use DmWrite() on ordinary memory?

2003-08-14 Thread Alan Ingleby
Aaron Ardiri [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 hey, i responsed cause you mentioned me :) not to nit-pick you :) *g*

That's OK.  I was just having a bad morning.  I'm all better now I've got my
caffeine fix.

You do have to admit though, that many of the posts that go into this forum
consist of minor corrections to previous people's posts.  Not that there's
anything wrong with that.. I'm just insecure. :-)

Alan



-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/


RE: Okay to use DmWrite() on ordinary memory?

2003-08-14 Thread Eric Cloninger
 Is it just me being paranoid, or do many of the experts on
 this forum not respond to newbie requests for help, only to 
 wait so they can show their superiority by nitpicking the 
 responses given by others?  Sorry, but it really bugs me that 
 many of my responses seem to get shot down by others who 
 obviously have a greater mastery of the ANSI C standard, yet 
 didn't bother to post their own response in the first place.

Alan,

The way this forum operates is pretty much a direct correlation to daily
life.  It doesn't matter if it's the Army, Harvard, or Palm-dev-forum.
There will always be newbies and there will always be those who consider
themselves above newbies.  The only thing you can influence is the way
you choose to interact, regardless of whether you are a newbie or an
expert.

I wouldn't call myself an expert by any means, but I do have an amount
of useful knowledge.  If I have time to compose a reply on a subject
that I know about, I will do so.  Don't take it as an insult if I don't
answer a question--I have a full-time job, two kids, a house, rental
property, and a school board post to deal with.  I'm sure everyone else
has a similar story.  Frankly, I'm surprised that this forum has
maintained a high S/N ratio for so long.

My advice: Relax and don't worry about the tone of each and every post.
There is nothing you can do about it other than get in a pointless
argument.  Be thankful that there are guys out there like Ben, Keith,
Aaron, etc. who take time away from their family and their jobs to share
their knowledge.

Peace.

-E


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/


Re: Okay to use DmWrite() on ordinary memory?

2003-08-14 Thread Alan Ingleby
Keith Rollin [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Actually, http://www.m-w.com has nitpick, but not nit-pick.
 Even so, don't worry.  Even if nit-picking is considered correct by
 some, according to Knuth
 (http://sunburn.stanford.edu/~knuth/email.html), nit-picking will
 eventually become nitpicking.  :-)

Thanks for the laugh.  I needed that. :-)

Alan



-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/


Re: Okay to use DmWrite() on ordinary memory?

2003-08-14 Thread Alan Ingleby
Eric Cloninger [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 My advice: Relax and don't worry about the tone of each and every post.
 There is nothing you can do about it other than get in a pointless
 argument.  Be thankful that there are guys out there like Ben, Keith,
 Aaron, etc. who take time away from their family and their jobs to share
 their knowledge.

That's for the tip, but I'm normally a very relaxed person.

I too have a wife, *four* kids (all under 6), mortgage etc etc..

I always take time to help on this forum if I can spare a few minutes, but
it's discouraging to *me* that *my* posts get shot down more often than not.
Maybe I should take this as a compliment though Something like Tsk Tsk
Alan, we know you're not a noob, you should know better...

Oh hum.. Life goes on..  I won't stop posting.. I'll just make sure all
future posts have gone through an extensive QA process before posting.. Not.
:-)

Alan



-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/


Re: Okay to use DmWrite() on ordinary memory?

2003-08-14 Thread Aaron Ardiri
  Now, *this* is advice I like!  To it, I should add Even if using
  DmWrite works on non-storage heap memory now, there's nothing that
  says it won't in the future.
 
 Nice to see I'm not completely full of bad ideas Mind you, I'm surprised
 Aaron hasn't chimed in with advise on replacing all calls with MemMove,
 wrapped around a liberal sprinkling of Semaphore tinkering. :-)

i slept in today *g*

semaphore tinkering - yummy.. that was fun pre os 5 :) and, sometimes a
necessity *g* but, not anymore with the OS5 units *g*

 Todd, as you can see, you're not heading down the right path.  If you're
 going to find it difficult to keep track of the type of pointer you're
 dealing with, the legal way of handling your requirement is:
 
 #define SafeUlgyDmWrite(a,b,c,d)
 {MemPtrDataStorage(a)?DmWrite(a,b,c,d):MemMove(a+b,c,d);} 
 
 You can now use the aptly named SafeUlgyDmWrite to replace all your
 DmWrites, and not care whether they're into Dynamic or Storage Memory.

this is what i would recommend as well :) 

#define myMemMove(a,b,c,d) \
  MemPtrDataStorage((a)) ? DmWrite((a),(b),(c),(d)) : MemMove((a)+(b),(c),(d))

kill the { } and ; *g* not needed, and, always () around your arguments,
for safety :) you here it doesn't matter with a+b, but, with a*b, it would:

#define myMacro function(a*b)

and, calling

  myMacro(x + 10, y - 10);

ends up being:

  function(x+10 * y-10);

which, actually ends up being:

  function (x + (10 * y) - 10); 

due to precedence :) beware of macro's ;) put the () around them and
it will do exactly what is needed.

---
Aaron Ardiri[EMAIL PROTECTED]
CEO - CTO   +46 70 656 1143
Mobile Wizardry  http://www.mobilewizardry.com/


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/


Re: Okay to use DmWrite() on ordinary memory?

2003-08-14 Thread David Martin

 Is it just me being paranoid, or do many of the experts on this
 forum not
 respond to newbie requests for help, only to wait so they can show
 their
 superiority by nitpicking the responses given by others?

Hey, would that work?  Can we really pass ourselves off as experts by
nitpicking (hyphen suppressed! :oP ) on other people's replies? Cool!

hee hee.

David M

__
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/


Re: Okay to use DmWrite() on ordinary memory?

2003-08-14 Thread Keith Rollin
At 10:15 AM +1000 8/11/03, Alan Ingleby wrote:
Todd Niec [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Is it possible to use DmWrite() on ordinary memory?  I have cases where
 buffers might be stored in ordinary memory (stack, heap, or static
 globals) or might be in a record in a file and I would like 1 method
 to write to both of them.
Try it and see.  My suspicion is that is will probably fail, as DmWrite is
designed to stop you from writing to the wrong place etc, but you never
know...
Ugh, I can't believe that advice just crossed this forum!  Using that 
logic, if I rob a house and don't get caught, it must be OK.  :-)

See a posting I made to news://news.falch.net/pilot.programmer.gcc, 
2003-03-06, Re: Better ways to update a field (sadly, it doesn't 
show up on a Google search).  It's about DmStrCopy vs. StrCopy, but 
the same advice applies to DmWrite vs. MemMove.

Why can't you just keep track of the type of memory yourself, then use the
appropriate DmWrite or MemMove calls? Even if DmWrite happens to work, it is
always going to be slower than MemMove...
Now, *this* is advice I like!  To it, I should add Even if using 
DmWrite works on non-storage heap memory now, there's nothing that 
says it won't in the future.

-- Keith Rollin
-- Palm OS Emulator engineer
--
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/


Re: Okay to use DmWrite() on ordinary memory?

2003-08-14 Thread Alan Ingleby
James [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]
 Alan Ingleby wrote:
 As Aaron already pointed out, the braces are totally unnecessary.
Furthermore,
 the following would generate a syntax error:

sarcasm

Thanks for all the very accurate, valid and verbose corrections so my code.
One thing though, you neglected to quote the /*Note - Untested code... Use
at you're own risk!!!*/ which I put it there for a good reason.  I'm not in
the habit of actually trying to compile these code snippets before posting,
and they usually don't account for every conceivable usage context, so they
quite often have bugs.  So what.. The newbie still gets the point doesn't
he?  A step in the right direction?

Is it just me being paranoid, or do many of the experts on this forum not
respond to newbie requests for help, only to wait so they can show their
superiority by nitpicking the responses given by others?  Sorry, but it
really bugs me that many of my responses seem to get shot down by others
who obviously have a greater mastery of the ANSI C standard, yet didn't
bother to post their own response in the first place.

Alan

PS: Here's the response I'm already expecting to this message:


Alan Ingleby wrote:
 ...nitpicking the responses

That's all very well Alan, but as all good dictionaries state... nit-picking
should actually be hyphenated.  Furthermore... [SNIP]


/sarcasm



-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/


Re: Okay to use DmWrite() on ordinary memory?

2003-08-14 Thread Aaron Ardiri
  hey, i responsed cause you mentioned me :) not to nit-pick you :) *g*
 
 That's OK.  I was just having a bad morning.  I'm all better now I've 
 got my caffeine fix.

*g* - some idiot woke me up at 8:30am.. 

 You do have to admit though, that many of the posts that go into this 
 forum consist of minor corrections to previous people's posts.  Not
 that there's anything wrong with that.. I'm just insecure. :-)

yeah, it started getting bad in 2000 :) then, a few more forums spawned
up (experts etc) - to reduce the signal/noise ratio :) there is a lot
of information in those lists that should be made public, a lot of 
questions/reasons why things are the way they are could be answered
easily then :)

---
Aaron Ardiri[EMAIL PROTECTED]
CEO - CTO   +46 70 656 1143
Mobile Wizardry  http://www.mobilewizardry.com/


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/


Re: Okay to use DmWrite() on ordinary memory?

2003-08-14 Thread Aaron Ardiri
 Is it just me being paranoid, or do many of the experts on 
 this forum not respond to newbie requests for help, only to 
 wait so they can show their superiority by nitpicking the 
 responses given by others?  

hey, i responsed cause you mentioned me :) not to nit-pick you :) *g*

at least the concept is now pernamently documented, but, i am sure due
to the manner in which newbies work, the question will be popping 
up again soon :)

---
Aaron Ardiri[EMAIL PROTECTED]
CEO - CTO   +46 70 656 1143
Mobile Wizardry  http://www.mobilewizardry.com/




-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/


Re: Okay to use DmWrite() on ordinary memory?

2003-08-12 Thread Keith Rollin
At 1:16 PM +1000 8/12/03, Alan Ingleby wrote:

Alan Ingleby wrote:
  ...nitpicking the responses
That's all very well Alan, but as all good dictionaries state... nit-picking
should actually be hyphenated.  Furthermore... [SNIP]

Actually, http://www.m-w.com has nitpick, but not nit-pick. 
Even so, don't worry.  Even if nit-picking is considered correct by 
some, according to Knuth 
(http://sunburn.stanford.edu/~knuth/email.html), nit-picking will 
eventually become nitpicking.  :-)

-- Keith

--
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/


Re: Okay to use DmWrite() on ordinary memory?

2003-08-12 Thread James
Aaron Ardiri wrote:

 this is what i would recommend as well :) 

 #define myMemMove(a,b,c,d) \
   MemPtrDataStorage((a)) ? DmWrite((a),(b),(c),(d)) \
  : MemMove((a)+(b),(c),(d))
 
 kill the { } and ; *g* not needed, and, always () around your 
 arguments, for safety :) you here it doesn't matter with a+b, 
 but, with a*b, it would:

You neglected to enclose the ?: expression in parentheses.  For example,
consider:

#define FOO(a, b, c) \
(a) ? (b) : (c)

int x;
x = 4 * FOO(1, 2, 3);

The value of x is now 2, not 8 as one would expect.


Alan Ingleby wrote:

 #define SafeUlgyDmWrite(a,b,c,d)
 {MemPtrDataStorage(a)?DmWrite(a,b,c,d):MemMove(a+b,c,d);} 

As Aaron already pointed out, the braces are totally unnecessary.  Furthermore,
the following would generate a syntax error:

if (condition)
SafeUglyDmWrite(a, b, c, d);
else
/* ... */

If you do need to use braces in macros, you need to enclose them in a do-while
block:

#define BAR(x, y) \
do\
{ \
/* ... */ \
} while (0) /* semicolon intentionally omitted */


__
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/


Re: Okay to use DmWrite() on ordinary memory?

2003-08-12 Thread Paul Johnson
Care to name em please ?


Regards,
Paul Johnson
Applewood House
www.applewoodhouse.com


- Original Message -
From: Aaron Ardiri [EMAIL PROTECTED]
To: Palm Developer Forum [EMAIL PROTECTED]
Sent: Tuesday, August 12, 2003 8:12 AM
Subject: Re: Okay to use DmWrite() on ordinary memory?


   hey, i responsed cause you mentioned me :) not to nit-pick you :) *g*
 
  That's OK.  I was just having a bad morning.  I'm all better now I've
  got my caffeine fix.

 *g* - some idiot woke me up at 8:30am..

  You do have to admit though, that many of the posts that go into this
  forum consist of minor corrections to previous people's posts.  Not
  that there's anything wrong with that.. I'm just insecure. :-)

 yeah, it started getting bad in 2000 :) then, a few more forums spawned
 up (experts etc) - to reduce the signal/noise ratio :) there is a lot
 of information in those lists that should be made public, a lot of
 questions/reasons why things are the way they are could be answered
 easily then :)

 ---
 Aaron Ardiri[EMAIL PROTECTED]
 CEO - CTO   +46 70 656 1143
 Mobile Wizardry  http://www.mobilewizardry.com/


 --
 For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/



-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/