× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



On Thu, 2008-10-30 at 12:49 -0400, Barbara Morris wrote:
rob@xxxxxxxxx wrote:
...
Regarding API's, especially list APIs. I seem to recall a Barbara tip
from a couple years ago that when using list apis a common error like
you're having occurs on a loop to process each entry. Something people
often did, which mostly worked, but occasionally bombed like you're
getting. To fix it you just set your looping up differently. Sort of
like the debate on whether to use a priming read. Getting kind of busy
and a quick scan of some source files for Barbara wasn't turning it up.

Rob, that list-API coding error usually shows up as MCH0602, pointer
offset not valid.

It's not really relevant to this thread any more, but here's the way of
coding the list-API loop that could lead to the offset error:

pEntry = address of first list item; // this is bad code
for i = 1 to number of list items; // this is bad code
process the entry based on pEntry; // this is bad code
pEntry += size of each list entry; // here is the badness
endfor; // this is bad code

By incrementing the pointer at the end of the loop, there's a
possibility of trying to point past the end of the physical storage
after processing the last entry. Even if it falls out of the loop right
after setting pEntry, and never actually tries to access the storage
based on pEntry, it could get MCH0602 just from trying to set the pointer.

Here's a safe way to code it:

offset = 0;
for i = 1 to number of list items;
pEntry = address of first list item
+ offset;
process the entry based on pEntry;
offset += size of each list entry;
endfor;


So, in addition to not deferencing a bad pointer, we should take care
not even to assign a bad address to a pointer. Right?

Cheers,
Terry.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.