Prev | Current Page 2147 | Next

Bryan Costales, Claus Assmann, George Jansen, Gregory Shapiro

"sendmail, 4th Edition"

The smfi_setpriv() routine is used like this:
ret = smfi_setpriv(ctx, datap);
Here, ctx is the common context pointer that was passed to your xxfi_eom() function. The
datap is a pointer that contains the address of your data. The smfi_setpriv() routine
expects a datap that is of type void *, so you may need to cast your call, depending on how
picky your compiler is:
ret = smfi_setpriv(ctx, (void *)datap);
The data to which datap points must not be automatic or local because it must survive calls
to multiple xxfi_ functions. Instead, you should allocate the space and free it when done.
Consider, for example, the following:
typedef struct {
char **rheads;
int nheads;
} MY_DATUM;
MY_DATUM *mdp = calloc(1, sizeof(MY_DATUM));
ret = smfi_setpriv(ctx, mdp);
Eachcontext (ctx) may have only one private data pointer. If you call smfi_setpriv() twice
withth e same ctx, the first pointer will be discarded and replaced with the second, possibly
resulting in a memory leak.
This is the Title of the Book, eMatter Edition
Copyright ?© 2007 O??™Reilly & Associates, Inc. All rights reserved.
1200 | Chapter 26: The X (Milters) Configuration Command
The return value (ret) will be MI_FAILURE only if the context pointer ctx is invalid; otherwise,
it is always MI_SUCCESS.
Be aware that when you allocate your private data it is up to you to free that memory
before it is lost.


Pages:
2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159
katalog stron szambo betonowe wierszyki dieta light katalog stron