× 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.



Njål Fisketjøn wrote:

> Why use memory manipulation alone for complex structures, why not combine
it
> with (user) indexes? Wouldn't that make them easier to understand and
maintain?

User indexes are great, but not for everything. An example:

The QzmfCrtMailMsg API accepts --as it's 4th argument-- something called a
message descriptor array. This is an array of pointers to a collection of
variable length "message lists" which collectively make up the message data.
At least one of these (the Envelope List) is a compound structure - a list
of lists. Each envelope in the list contains a fixed header section, and a
list of attributes. The attributes are of varying data types and sizes. The
MSF framework itself does not impose any arbitrary limitations upon what
constitues an attribute - that's application specific.

The process for creating the Envelope List is simple:

allocate storage for envelope list
set envelope list header
for each envelope
    extend storage
    initialize header data
    for each envelope attribute
        extend storage
        initialize header data
        append attribute data
        update envelope header

The pointer to the envelope list storage area is then passed (via the
descriptor array) to the API. During message creation, or subsequent edits,
the attributes within the envelope may need to be changed. Some may be
added, others dropped, or even replaced.

I've created a service program for handling these lists within the MSF
messaging framework. Examples of the functions within the service program
include the following:

swMfGetEnvPtr() - return a pointer to a specific envelope within the list
swMfSetSubj()  - set the subject line attribute for the specified envelope

The function responsible for setting the subject line needs to be able
replace the attribute within the specified envelope, not just append it.
Since the subject line attribute is not a fixed size, the storage
requirements change dynamically. I decided to do this right in memory,
because it was easy to do, and much less code than the alternatives. To
support the swMfSetSubj() function, I created swMemShrink() to "delete" an
area of memory at a given offset, and swMemExpand() to add space at a given
offset. Those functions allow me to easily replace an attribute without
having to recreate the envelope list.

Both swMemShrink(), and swMemExpand() are only about 20 lines of code, so
they're small, very fast, and easy to use.


Regards,

John Taylor



As an Amazon Associate we earn from qualifying purchases.

This thread ...

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.