![]() |
![]() |
|
|
Allocating a Typed Buffer
Initially, no buffers are associated with a client process. Before a message can be sent, a client process must allocate a buffer of a supported type to carry a message. A typed buffer is allocated using the tpalloc(3c) function, as follows.
char*
tpalloc(char *type, char *subtype, long size)
The following table describes the arguments to the tpalloc() function.
tpalloc() Function Arguments
The VIEW, VIEW32, X_C_TYPE, and X_COMMON typed buffers require the subtype argument, as shown in the following example.
Allocating a VIEW Typed Buffer
struct aud *audv; /* pointer to aud view structure */
. . .
audv = (struct aud *) tpalloc("VIEW", "aud", sizeof(struct aud));
. . .
The following example shows how to allocate an FML typed buffer. Note that a value of NULL is assigned to the subtype argument.
Allocating an FML Typed Buffer
FBFR *fbfr; /* pointer to an FML buffer structure */
. . .
fbfr = (FBFR *)tpalloc("FML", NULL, Fneeded(f, v))
. . .
The following example shows how to allocate a CARRAY typed buffer, which requires that a size value be specified.
Allocating a CARRAY Typed Buffer
char *cptr;
long casize;
. . .
casize = 1024;
cptr = tpalloc("CARRAY", NULL, casize);
. . .
Upon success, the tpalloc() function returns a pointer of type char. For types other than STRING and CARRAY, you should cast the pointer to the proper C structure or FML pointer.
If the tpalloc() function encounters an error, it returns the NULL pointer. The following list provides examples of error conditions:
For a complete list of error codes and explanations of them, refer to tpalloc(3c) in the BEA Tuxedo C Function Reference.
The following listing shows how to allocate a STRING typed buffer. In this example, the associated default size is used as the value of the size argument to tpalloc().
Allocating a STRING Buffer
char *cptr;
. . .
cptr = tpalloc("STRING", NULL, 0);
. . .
See Also
![]() |
![]() |
![]() |
|
Copyright © 2000 BEA Systems, Inc. All rights reserved.
|