Purpose
Frees data allocated by the Remote Procedure Call/eXternal Data Representation (RPC/XDR) system.
Library
C Library (libc.a)
Syntax
Description
The svc_freeargs macro frees data allocated by the RPC/XDR system. This data is allocated when the RPC/XDR system decodes the arguments to a service procedure with the svc_getargs macro.
Parameters
| Item | Description | 
|---|---|
| xprt | Points to the RPC service transport handle. | 
| inproc | Specifies the XDR routine that decodes the arguments. | 
| in | Specifies the address where the procedure arguments are placed. | 
Purpose
Frees data allocated by the Remote Procedure Call/eXternal Data Representation (RPC/XDR) system.
Library
Network Services Library (libnsl.a)
Syntax
Description
The svc_freeargs macro frees data allocated by the RPC/XDR system. This data is allocated when the RPC/XDR system decodes the arguments to a service procedure with the svc_getargs macro.
Parameters
| Item | Description | 
|---|---|
| xprt | Points to the RPC service transport handle. | 
| inproc | Specifies the XDR routine that decodes the arguments. | 
| in | Specifies the address where the procedure arguments are placed. | 
Examples
#include <stdlib.h>
#include <rpc/rpc.h>
#define PROG 0x3fffffffL
#define VERS 0x1L
static void sample_dispatch();
    
main()
{
    char *nettype = "tcp";
    int no_of_handles;
    /* Create RPC service handle and register with RPCBIND service */
    if((no_of_handles = svc_create(sample_dispatch, PROG, VERS,nettype)) == 0)
    {
         fprintf(stdout,"Error in svc_create!");
         exit(EXIT_FAILURE);
    }
  
    svc_run();
    return 0;
} 
/* following is the sample dispatch routine*/
static void sample_dispatch(struct svc_req *request, SVCXPRT *xprt)
{
    int args,result;
      
    /* decode argument from client using xdr_int() */
    if (svc_getargs(xprt, (xdrproc_t)xdr_int,(caddr_t)&args) == FALSE) 
    {  
        svcerr_decode(xprt);
        fprintf(stdout,"Error in svc_getargs!");
        return;
    }
        
    /* call service procedure */
 
    /* free allocated  data */
    if (svc_freeargs(xprt, (xdrproc_t)xdr_int,(caddr_t)&args) == FALSE) 
    {  
        fprintf(stdout,"Error in svc_freeargs!");
        return;
    }
    /* send reply to client */ 
    if(!svc_sendreply(xprt,(xdrproc_t)xdr_int,(caddr_t)&result))
    {
        fprintf(stdout,"Error in svc_sendreply!");
        svcerr_systemerr(xprt);
    }
}