[Info-vax] Whither VMS?

ChrisQ meru at devnull.com
Mon Oct 5 13:01:48 EDT 2009


Bob Koehler wrote:

> 
>    It's simple.  Avoid any call that passes an output parameter by
>    pointer but doesn't pass in input parameter provinding the allocated
>    length.
> 

You can get the equivalent of call by descriptor by declaring a structure:

typedef struct {
    U8 u8Length;		/* Could be U16 or U32 */
    U8 *pu8String;
    } STRING;

Then:

U8 u8String [] = {"Some string"};

STRING sString;

sString.u8Length = strlen (&u8String [0]);
sString.pu8String = &u8String [0];

Pass into function:

vSomeFunction (&sString);

This looks a lot more wordy than it would actually do in practice. For 
the sort of work done here, the above type of construct is used a lot, 
though usually with more structure elements.

In the end, it comes down to a systems engineering and design issue, If 
you have a pair of functions that you can be sure will never exceed 
buffer limits or if the range checking has already been done elsewhere, 
then it's safe to pass the pointer alone. For some types of work, the 
overhead involved in having to range check every last argument becomes 
self defeating and points more to a bad system design in the first place...

Regards,

Chris









More information about the Info-vax mailing list