diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2011-11-30 18:05:05 -0800 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2011-12-05 20:34:28 -0800 |
commit | b89e1b45198c48996750b5da3d715c10f974243f (patch) | |
tree | 7091bd01c843ccaffbff8b06afe91dea4fd8986f | |
parent | ff992be7b05483f9a0586a27ee0edb6d99580b84 (diff) |
Finish conversion to standard C allocation functions
Commit 4ac40cd5451 started this, by no longer special casing the
xserver to include it's former custom allocation functions, this
just takes the remaining #defines and pre-substitutes them into
the code.
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r-- | Xtrans.c | 74 | ||||
-rw-r--r-- | Xtranslcl.c | 50 | ||||
-rw-r--r-- | Xtranssock.c | 54 | ||||
-rw-r--r-- | Xtranstli.c | 38 | ||||
-rw-r--r-- | Xtransutil.c | 12 | ||||
-rw-r--r-- | transport.c | 4 |
6 files changed, 114 insertions, 118 deletions
@@ -135,15 +135,15 @@ TRANS(FreeConnInfo) (XtransConnInfo ciptr) prmsg (3,"FreeConnInfo(%p)\n", ciptr); if (ciptr->addr) - xfree (ciptr->addr); + free (ciptr->addr); if (ciptr->peeraddr) - xfree (ciptr->peeraddr); + free (ciptr->peeraddr); if (ciptr->port) - xfree (ciptr->port); + free (ciptr->port); - xfree ((char *) ciptr); + free ((char *) ciptr); } @@ -212,7 +212,7 @@ TRANS(ParseAddress) (char *address, char **protocol, char **host, char **port) /* Copy the string so it can be changed */ - tmpptr = mybuf = (char *) xalloc (strlen (address) + 1); + tmpptr = mybuf = (char *) malloc (strlen (address) + 1); strcpy (mybuf, address); /* Parse the string to get each component */ @@ -229,7 +229,7 @@ TRANS(ParseAddress) (char *address, char **protocol, char **host, char **port) *protocol = NULL; *host = NULL; *port = NULL; - xfree (tmpptr); + free (tmpptr); return 0; } @@ -279,7 +279,7 @@ TRANS(ParseAddress) (char *address, char **protocol, char **host, char **port) *protocol = NULL; *host = NULL; *port = NULL; - xfree (tmpptr); + free (tmpptr); return 0; } @@ -346,46 +346,46 @@ TRANS(ParseAddress) (char *address, char **protocol, char **host, char **port) * string space for them. */ - if ((*protocol = (char *) xalloc(strlen (_protocol) + 1)) == NULL) + if ((*protocol = (char *) malloc(strlen (_protocol) + 1)) == NULL) { /* Malloc failed */ *port = NULL; *host = NULL; *protocol = NULL; - xfree (tmpptr); + free (tmpptr); return 0; } else strcpy (*protocol, _protocol); - if ((*host = (char *) xalloc (strlen (_host) + 1)) == NULL) + if ((*host = (char *) malloc (strlen (_host) + 1)) == NULL) { /* Malloc failed */ *port = NULL; *host = NULL; - xfree (*protocol); + free (*protocol); *protocol = NULL; - xfree (tmpptr); + free (tmpptr); return 0; } else strcpy (*host, _host); - if ((*port = (char *) xalloc (strlen (_port) + 1)) == NULL) + if ((*port = (char *) malloc (strlen (_port) + 1)) == NULL) { /* Malloc failed */ *port = NULL; - xfree (*host); + free (*host); *host = NULL; - xfree (*protocol); + free (*protocol); *protocol = NULL; - xfree (tmpptr); + free (tmpptr); return 0; } else strcpy (*port, _port); - xfree (tmpptr); + free (tmpptr); return 1; } @@ -430,9 +430,9 @@ TRANS(Open) (int type, char *address) prmsg (1,"Open: Unable to find transport for %s\n", protocol); - xfree (protocol); - xfree (host); - xfree (port); + free (protocol); + free (host); + free (port); return NULL; } @@ -471,17 +471,17 @@ TRANS(Open) (int type, char *address) prmsg (1,"Open: transport open failed for %s/%s:%s\n", protocol, host, port); } - xfree (protocol); - xfree (host); - xfree (port); + free (protocol); + free (host); + free (port); return NULL; } ciptr->transptr = thistrans; ciptr->port = port; /* We need this for TRANS(Reopen) */ - xfree (protocol); - xfree (host); + free (protocol); + free (host); return ciptr; } @@ -523,7 +523,7 @@ TRANS(Reopen) (int type, int trans_id, int fd, char *port) return NULL; } - if ((save_port = (char *) xalloc (strlen (port) + 1)) == NULL) + if ((save_port = (char *) malloc (strlen (port) + 1)) == NULL) { prmsg (1,"Reopen: Unable to malloc port string\n"); @@ -549,7 +549,7 @@ TRANS(Reopen) (int type, int trans_id, int fd, char *port) if (ciptr == NULL) { prmsg (1,"Reopen: transport open failed\n"); - xfree(save_port); + free (save_port); return NULL; } @@ -653,7 +653,7 @@ TRANS(GetReopenInfo) (XtransConnInfo ciptr, *trans_id = Xtransports[i].transport_id; *fd = ciptr->fd; - if ((*port = (char *) xalloc (strlen (ciptr->port) + 1)) == NULL) + if ((*port = (char *) malloc (strlen (ciptr->port) + 1)) == NULL) return 0; else { @@ -844,16 +844,16 @@ TRANS(Connect) (XtransConnInfo ciptr, char *address) { prmsg (1,"Connect: Missing port specification in %s\n", address); - if (protocol) xfree (protocol); - if (host) xfree (host); + if (protocol) free (protocol); + if (host) free (host); return -1; } ret = ciptr->transptr->Connect (ciptr, host, port); - if (protocol) xfree (protocol); - if (host) xfree (host); - if (port) xfree (port); + if (protocol) free (protocol); + if (host) free (host); + if (port) free (port); return ret; } @@ -951,7 +951,7 @@ TRANS(GetMyAddr) (XtransConnInfo ciptr, int *familyp, int *addrlenp, *familyp = ciptr->family; *addrlenp = ciptr->addrlen; - if ((*addrp = (Xtransaddr *) xalloc (ciptr->addrlen)) == NULL) + if ((*addrp = (Xtransaddr *) malloc (ciptr->addrlen)) == NULL) { prmsg (1,"GetMyAddr: malloc failed\n"); return -1; @@ -971,7 +971,7 @@ TRANS(GetPeerAddr) (XtransConnInfo ciptr, int *familyp, int *addrlenp, *familyp = ciptr->family; *addrlenp = ciptr->peeraddrlen; - if ((*addrp = (Xtransaddr *) xalloc (ciptr->peeraddrlen)) == NULL) + if ((*addrp = (Xtransaddr *) malloc (ciptr->peeraddrlen)) == NULL) { prmsg (1,"GetPeerAddr: malloc failed\n"); return -1; @@ -1140,7 +1140,7 @@ TRANS(MakeAllCOTSServerListeners) (char *port, int *partial, int *count_ret, if (*count_ret > 0) { - if ((*ciptrs_ret = (XtransConnInfo *) xalloc ( + if ((*ciptrs_ret = (XtransConnInfo *) malloc ( *count_ret * sizeof (XtransConnInfo))) == NULL) { return -1; @@ -1238,7 +1238,7 @@ TRANS(MakeAllCLTSServerListeners) (char *port, int *partial, int *count_ret, if (*count_ret > 0) { - if ((*ciptrs_ret = (XtransConnInfo *) xalloc ( + if ((*ciptrs_ret = (XtransConnInfo *) malloc ( *count_ret * sizeof (XtransConnInfo))) == NULL) { return -1; diff --git a/Xtranslcl.c b/Xtranslcl.c index 8466ddc..8a5e718 100644 --- a/Xtranslcl.c +++ b/Xtranslcl.c @@ -152,7 +152,7 @@ TRANS(FillAddrInfo)(XtransConnInfo ciptr, char *sun_path, char *peer_sun_path) ciptr->family = AF_UNIX; ciptr->addrlen = sizeof (struct sockaddr_un); - if ((sunaddr = (struct sockaddr_un *) xalloc (ciptr->addrlen)) == NULL) + if ((sunaddr = (struct sockaddr_un *) malloc (ciptr->addrlen)) == NULL) { prmsg(1,"FillAddrInfo: failed to allocate memory for addr\n"); return 0; @@ -162,7 +162,7 @@ TRANS(FillAddrInfo)(XtransConnInfo ciptr, char *sun_path, char *peer_sun_path) if (strlen(sun_path) > sizeof(sunaddr->sun_path) - 1) { prmsg(1, "FillAddrInfo: path too long\n"); - xfree((char *) sunaddr); + free((char *) sunaddr); return 0; } strcpy (sunaddr->sun_path, sun_path); @@ -174,12 +174,12 @@ TRANS(FillAddrInfo)(XtransConnInfo ciptr, char *sun_path, char *peer_sun_path) ciptr->peeraddrlen = sizeof (struct sockaddr_un); - if ((p_sunaddr = (struct sockaddr_un *) xalloc ( + if ((p_sunaddr = (struct sockaddr_un *) malloc ( ciptr->peeraddrlen)) == NULL) { prmsg(1, "FillAddrInfo: failed to allocate memory for peer addr\n"); - xfree ((char *) sunaddr); + free ((char *) sunaddr); ciptr->addr = NULL; return 0; @@ -189,7 +189,7 @@ TRANS(FillAddrInfo)(XtransConnInfo ciptr, char *sun_path, char *peer_sun_path) if (strlen(peer_sun_path) > sizeof(p_sunaddr->sun_path) - 1) { prmsg(1, "FillAddrInfo: peer path too long\n"); - xfree((char *) p_sunaddr); + free((char *) p_sunaddr); return 0; } strcpy (p_sunaddr->sun_path, peer_sun_path); @@ -613,7 +613,7 @@ TRANS(PTSAccept)(XtransConnInfo ciptr, XtransConnInfo newciptr, int *status) */ newciptr->addrlen=ciptr->addrlen; - if( (newciptr->addr=(char *)xalloc(newciptr->addrlen)) == NULL ) { + if( (newciptr->addr=(char *)malloc(newciptr->addrlen)) == NULL ) { prmsg(1,"PTSAccept: failed to allocate memory for peer addr\n"); close(newfd); *status = TRANS_ACCEPT_BAD_MALLOC; @@ -623,9 +623,9 @@ TRANS(PTSAccept)(XtransConnInfo ciptr, XtransConnInfo newciptr, int *status) memcpy(newciptr->addr,ciptr->addr,newciptr->addrlen); newciptr->peeraddrlen=sizeof(struct sockaddr_un); - if( (sunaddr=(struct sockaddr_un *)xalloc(newciptr->peeraddrlen)) == NULL ) { + if( (sunaddr=(struct sockaddr_un *)malloc(newciptr->peeraddrlen)) == NULL ) { prmsg(1,"PTSAccept: failed to allocate memory for peer addr\n"); - xfree(newciptr->addr); + free(newciptr->addr); close(newfd); *status = TRANS_ACCEPT_BAD_MALLOC; return -1; @@ -885,7 +885,7 @@ TRANS(NAMEDAccept)(XtransConnInfo ciptr, XtransConnInfo newciptr, int *status) */ newciptr->family=ciptr->family; newciptr->addrlen=ciptr->addrlen; - if( (newciptr->addr=(char *)xalloc(newciptr->addrlen)) == NULL ) { + if( (newciptr->addr=(char *)malloc(newciptr->addrlen)) == NULL ) { prmsg(1, "NAMEDAccept: failed to allocate memory for pipe addr\n"); close(str.fd); @@ -896,10 +896,10 @@ TRANS(NAMEDAccept)(XtransConnInfo ciptr, XtransConnInfo newciptr, int *status) memcpy(newciptr->addr,ciptr->addr,newciptr->addrlen); newciptr->peeraddrlen=newciptr->addrlen; - if( (newciptr->peeraddr=(char *)xalloc(newciptr->peeraddrlen)) == NULL ) { + if( (newciptr->peeraddr=(char *)malloc(newciptr->peeraddrlen)) == NULL ) { prmsg(1, "NAMEDAccept: failed to allocate memory for peer addr\n"); - xfree(newciptr->addr); + free(newciptr->addr); close(str.fd); *status = TRANS_ACCEPT_BAD_MALLOC; return -1; @@ -1223,7 +1223,7 @@ TRANS(SCOAccept)(XtransConnInfo ciptr, XtransConnInfo newciptr, int *status) */ newciptr->addrlen=ciptr->addrlen; - if( (newciptr->addr=(char *)xalloc(newciptr->addrlen)) == NULL ) { + if( (newciptr->addr=(char *)malloc(newciptr->addrlen)) == NULL ) { prmsg(1, "SCOAccept: failed to allocate memory for peer addr\n"); close(fd); @@ -1237,10 +1237,10 @@ TRANS(SCOAccept)(XtransConnInfo ciptr, XtransConnInfo newciptr, int *status) #endif newciptr->peeraddrlen=newciptr->addrlen; - if( (newciptr->peeraddr=(char *)xalloc(newciptr->peeraddrlen)) == NULL ) { + if( (newciptr->peeraddr=(char *)malloc(newciptr->peeraddrlen)) == NULL ) { prmsg(1, "SCOAccept: failed to allocate memory for peer addr\n"); - xfree(newciptr->addr); + free(newciptr->addr); close(fd); *status = TRANS_ACCEPT_BAD_MALLOC; return -1; @@ -1671,7 +1671,7 @@ TRANS(LocalInitTransports)(const char *protocol) if( strcmp(protocol,"local") && strcmp(protocol,"LOCAL") ) { - workingXLOCAL=freeXLOCAL=(char *)xalloc (strlen (protocol) + 1); + workingXLOCAL=freeXLOCAL=(char *)malloc (strlen (protocol) + 1); if (workingXLOCAL) strcpy (workingXLOCAL, protocol); } @@ -1679,7 +1679,7 @@ TRANS(LocalInitTransports)(const char *protocol) XLOCAL=(char *)getenv("XLOCAL"); if(XLOCAL==NULL) XLOCAL=DEF_XLOCAL; - workingXLOCAL=freeXLOCAL=(char *)xalloc (strlen (XLOCAL) + 1); + workingXLOCAL=freeXLOCAL=(char *)malloc (strlen (XLOCAL) + 1); if (workingXLOCAL) strcpy (workingXLOCAL, XLOCAL); } @@ -1690,7 +1690,7 @@ TRANS(LocalEndTransports)(void) { prmsg(3,"LocalEndTransports()\n"); - xfree(freeXLOCAL); + free(freeXLOCAL); } #define TYPEBUFSIZE 32 @@ -1815,7 +1815,7 @@ TRANS(LocalOpenClient)(int type, char *protocol, char *host, char *port) */ #endif /* X11_t */ - if( (ciptr=(XtransConnInfo)xcalloc(1,sizeof(struct _XtransConnInfo))) == NULL ) + if( (ciptr=(XtransConnInfo)calloc(1,sizeof(struct _XtransConnInfo))) == NULL ) { prmsg(1,"LocalOpenClient: calloc(1,%lu) failed\n", sizeof(struct _XtransConnInfo)); @@ -1856,7 +1856,7 @@ TRANS(LocalOpenClient)(int type, char *protocol, char *host, char *port) if( ciptr->fd < 0 ) { - xfree(ciptr); + free(ciptr); return NULL; } @@ -1889,7 +1889,7 @@ TRANS(LocalOpenServer)(int type, char *protocol, char *host _X_UNUSED, char *por */ #endif /* X11_t */ - if( (ciptr=(XtransConnInfo)xcalloc(1,sizeof(struct _XtransConnInfo))) == NULL ) + if( (ciptr=(XtransConnInfo)calloc(1,sizeof(struct _XtransConnInfo))) == NULL ) { prmsg(1,"LocalOpenServer: calloc(1,%lu) failed\n", sizeof(struct _XtransConnInfo)); @@ -1925,7 +1925,7 @@ TRANS(LocalOpenServer)(int type, char *protocol, char *host _X_UNUSED, char *por } } - xfree(ciptr); + free(ciptr); return NULL; } @@ -1943,7 +1943,7 @@ TRANS(LocalReopenServer)(int type, int index, int fd, char *port) prmsg(2,"LocalReopenServer(%d,%d,%d)\n", type, index, fd); - if( (ciptr=(XtransConnInfo)xcalloc(1,sizeof(struct _XtransConnInfo))) == NULL ) + if( (ciptr=(XtransConnInfo)calloc(1,sizeof(struct _XtransConnInfo))) == NULL ) { prmsg(1,"LocalReopenServer: calloc(1,%lu) failed\n", sizeof(struct _XtransConnInfo)); @@ -1972,7 +1972,7 @@ TRANS(LocalReopenServer)(int type, int index, int fd, char *port) return ciptr; } - xfree(ciptr); + free(ciptr); return NULL; } @@ -2175,7 +2175,7 @@ TRANS(LocalAccept)(XtransConnInfo ciptr, int *status) transptr=(LOCALtrans2dev *)ciptr->priv; - if( (newciptr=(XtransConnInfo)xcalloc(1,sizeof(struct _XtransConnInfo)))==NULL ) + if( (newciptr=(XtransConnInfo)calloc(1,sizeof(struct _XtransConnInfo)))==NULL ) { prmsg(1,"LocalAccept: calloc(1,%lu) failed\n", sizeof(struct _XtransConnInfo)); @@ -2187,7 +2187,7 @@ TRANS(LocalAccept)(XtransConnInfo ciptr, int *status) if( newciptr->fd < 0 ) { - xfree(newciptr); + free(newciptr); return NULL; } diff --git a/Xtranssock.c b/Xtranssock.c index 901d721..bda2bcc 100644 --- a/Xtranssock.c +++ b/Xtranssock.c @@ -315,7 +315,7 @@ TRANS(SocketINETGetAddr) (XtransConnInfo ciptr) * Everything looks good: fill in the XtransConnInfo structure. */ - if ((ciptr->addr = (char *) xalloc (namelen)) == NULL) + if ((ciptr->addr = (char *) malloc (namelen)) == NULL) { prmsg (1, "SocketINETGetAddr: Can't allocate space for the addr\n"); @@ -382,7 +382,7 @@ TRANS(SocketINETGetPeerAddr) (XtransConnInfo ciptr) * Everything looks good: fill in the XtransConnInfo structure. */ - if ((ciptr->peeraddr = (char *) xalloc (namelen)) == NULL) + if ((ciptr->peeraddr = (char *) malloc (namelen)) == NULL) { prmsg (1, "SocketINETGetPeerAddr: Can't allocate space for the addr\n"); @@ -404,7 +404,7 @@ TRANS(SocketOpen) (int i, int type) prmsg (3,"SocketOpen(%d,%d)\n", i, type); - if ((ciptr = (XtransConnInfo) xcalloc ( + if ((ciptr = (XtransConnInfo) calloc ( 1, sizeof(struct _XtransConnInfo))) == NULL) { prmsg (1, "SocketOpen: malloc failed\n"); @@ -425,7 +425,7 @@ TRANS(SocketOpen) (int i, int type) prmsg (2, "SocketOpen: socket() failed for %s\n", Sockettrans2devtab[i].transname); - xfree ((char *) ciptr); + free ((char *) ciptr); return NULL; } @@ -481,7 +481,7 @@ TRANS(SocketReopen) (int i _X_UNUSED, int type, int fd, char *port) } #endif /*SOCK_MAXADDRLEN*/ - if ((ciptr = (XtransConnInfo) xcalloc ( + if ((ciptr = (XtransConnInfo) calloc ( 1, sizeof(struct _XtransConnInfo))) == NULL) { prmsg (1, "SocketReopen: malloc(ciptr) failed\n"); @@ -490,18 +490,18 @@ TRANS(SocketReopen) (int i _X_UNUSED, int type, int fd, char *port) ciptr->fd = fd; - if ((addr = (struct sockaddr *) xcalloc (1, portlen + 2)) == NULL) { + if ((addr = (struct sockaddr *) calloc (1, portlen + 2)) == NULL) { prmsg (1, "SocketReopen: malloc(addr) failed\n"); - xfree (ciptr); + free (ciptr); return NULL; } ciptr->addr = (char *) addr; ciptr->addrlen = portlen + 2; - if ((ciptr->peeraddr = (char *) xcalloc (1, portlen + 2)) == NULL) { + if ((ciptr->peeraddr = (char *) calloc (1, portlen + 2)) == NULL) { prmsg (1, "SocketReopen: malloc(portaddr) failed\n"); - xfree (addr); - xfree (ciptr); + free (addr); + free (ciptr); return NULL; } ciptr->peeraddrlen = portlen + 2; @@ -1138,7 +1138,7 @@ TRANS(SocketUNIXCreateListener) (XtransConnInfo ciptr, char *port, namelen = sizeof (sockname); /* this will always make it the same size */ - if ((ciptr->addr = (char *) xalloc (namelen)) == NULL) + if ((ciptr->addr = (char *) malloc (namelen)) == NULL) { prmsg (1, "SocketUNIXCreateListener: Can't allocate space for the addr\n"); @@ -1252,7 +1252,7 @@ TRANS(SocketINETAccept) (XtransConnInfo ciptr, int *status) prmsg (2, "SocketINETAccept(%p,%d)\n", ciptr, ciptr->fd); - if ((newciptr = (XtransConnInfo) xcalloc ( + if ((newciptr = (XtransConnInfo) calloc ( 1, sizeof(struct _XtransConnInfo))) == NULL) { prmsg (1, "SocketINETAccept: malloc failed\n"); @@ -1267,7 +1267,7 @@ TRANS(SocketINETAccept) (XtransConnInfo ciptr, int *status) errno = WSAGetLastError(); #endif prmsg (1, "SocketINETAccept: accept() failed\n"); - xfree (newciptr); + free (newciptr); *status = TRANS_ACCEPT_FAILED; return NULL; } @@ -1294,7 +1294,7 @@ TRANS(SocketINETAccept) (XtransConnInfo ciptr, int *status) prmsg (1, "SocketINETAccept: ...SocketINETGetAddr() failed:\n"); close (newciptr->fd); - xfree (newciptr); + free (newciptr); *status = TRANS_ACCEPT_MISC_ERROR; return NULL; } @@ -1304,8 +1304,8 @@ TRANS(SocketINETAccept) (XtransConnInfo ciptr, int *status) prmsg (1, "SocketINETAccept: ...SocketINETGetPeerAddr() failed:\n"); close (newciptr->fd); - if (newciptr->addr) xfree (newciptr->addr); - xfree (newciptr); + if (newciptr->addr) free (newciptr->addr); + free (newciptr); *status = TRANS_ACCEPT_MISC_ERROR; return NULL; } @@ -1329,7 +1329,7 @@ TRANS(SocketUNIXAccept) (XtransConnInfo ciptr, int *status) prmsg (2, "SocketUNIXAccept(%p,%d)\n", ciptr, ciptr->fd); - if ((newciptr = (XtransConnInfo) xcalloc ( + if ((newciptr = (XtransConnInfo) calloc ( 1, sizeof(struct _XtransConnInfo))) == NULL) { prmsg (1, "SocketUNIXAccept: malloc() failed\n"); @@ -1341,7 +1341,7 @@ TRANS(SocketUNIXAccept) (XtransConnInfo ciptr, int *status) (struct sockaddr *) &sockname, (void *)&namelen)) < 0) { prmsg (1, "SocketUNIXAccept: accept() failed\n"); - xfree (newciptr); + free (newciptr); *status = TRANS_ACCEPT_FAILED; return NULL; } @@ -1352,12 +1352,12 @@ TRANS(SocketUNIXAccept) (XtransConnInfo ciptr, int *status) * since this is unix domain. */ - if ((newciptr->addr = (char *) xalloc (ciptr->addrlen)) == NULL) + if ((newciptr->addr = (char *) malloc (ciptr->addrlen)) == NULL) { prmsg (1, "SocketUNIXAccept: Can't allocate space for the addr\n"); close (newciptr->fd); - xfree (newciptr); + free (newciptr); *status = TRANS_ACCEPT_BAD_MALLOC; return NULL; } @@ -1370,13 +1370,13 @@ TRANS(SocketUNIXAccept) (XtransConnInfo ciptr, int *status) newciptr->addrlen = ciptr->addrlen; memcpy (newciptr->addr, ciptr->addr, newciptr->addrlen); - if ((newciptr->peeraddr = (char *) xalloc (ciptr->addrlen)) == NULL) + if ((newciptr->peeraddr = (char *) malloc (ciptr->addrlen)) == NULL) { prmsg (1, "SocketUNIXAccept: Can't allocate space for the addr\n"); close (newciptr->fd); - if (newciptr->addr) xfree (newciptr->addr); - xfree (newciptr); + if (newciptr->addr) free (newciptr->addr); + free (newciptr); *status = TRANS_ACCEPT_BAD_MALLOC; return NULL; } @@ -1554,7 +1554,7 @@ TRANS(SocketINETConnect) (XtransConnInfo ciptr, char *host, char *port) " socketfor IPv4 address\n"); } if (newciptr) - xfree(newciptr); + free(newciptr); } else { socketaddr = NULL; prmsg (4,"SocketINETConnect Skipping IPv4 address\n"); @@ -1590,7 +1590,7 @@ TRANS(SocketINETConnect) (XtransConnInfo ciptr, char *host, char *port) "socket for IPv6 address\n"); } if (newciptr) - xfree(newciptr); + free(newciptr); } else { @@ -2053,8 +2053,8 @@ TRANS(SocketUNIXConnect) (XtransConnInfo ciptr, char *host, char *port) * since this is unix domain. */ - if ((ciptr->addr = (char *) xalloc(namelen)) == NULL || - (ciptr->peeraddr = (char *) xalloc(namelen)) == NULL) + if ((ciptr->addr = (char *) malloc(namelen)) == NULL || + (ciptr->peeraddr = (char *) malloc(namelen)) == NULL) { prmsg (1, "SocketUNIXCreateListener: Can't allocate space for the addr\n"); diff --git a/Xtranstli.c b/Xtranstli.c index 8601c13..cbb7d4b 100644 --- a/Xtranstli.c +++ b/Xtranstli.c @@ -167,9 +167,9 @@ TRANS(TLIGetAddr)(XtransConnInfo ciptr) */ if( ciptr->addr ) - xfree(ciptr->addr); + free(ciptr->addr); - if( (ciptr->addr=(char *)xalloc(netbuf.len)) == NULL ) + if( (ciptr->addr=(char *)malloc(netbuf.len)) == NULL ) { prmsg(1, "TLIGetAddr: Can't allocate space for the addr\n"); return -1; @@ -216,9 +216,9 @@ TRANS(TLIGetPeerAddr)(XtransConnInfo ciptr) */ if( ciptr->peeraddr ) - xfree(ciptr->peeraddr); + free(ciptr->peeraddr); - if( (ciptr->peeraddr=(char *)xalloc(netbuf.len)) == NULL ) + if( (ciptr->peeraddr=(char *)malloc(netbuf.len)) == NULL ) { prmsg(1, "TLIGetPeerAddr: Can't allocate space for the addr\n"); @@ -312,7 +312,7 @@ TRANS(TLIOpen)(char *device) prmsg(3,"TLIOpen(%s)\n", device); - if( (ciptr=(XtransConnInfo)xcalloc(1,sizeof(struct _XtransConnInfo))) == NULL ) + if( (ciptr=(XtransConnInfo)calloc(1,sizeof(struct _XtransConnInfo))) == NULL ) { prmsg(1, "TLIOpen: calloc failed\n"); return NULL; @@ -345,7 +345,7 @@ TRANS(TLIReopen)(char *device, int fd, char *port) return NULL; } - if( (ciptr=(XtransConnInfo)xcalloc(1,sizeof(struct _XtransConnInfo))) == NULL ) + if( (ciptr=(XtransConnInfo)calloc(1,sizeof(struct _XtransConnInfo))) == NULL ) { prmsg(1, "TLIReopen: calloc failed\n"); return NULL; @@ -448,7 +448,7 @@ TRANS(TLIOpenCOTSClient)(Xtransport *thistrans, char *protocol, "TLIOpenCOTSClient: ...TLITLIBindLocal() failed: %d\n", errno); t_close(ciptr->fd); - xfree(ciptr); + free(ciptr); return NULL; } @@ -458,7 +458,7 @@ TRANS(TLIOpenCOTSClient)(Xtransport *thistrans, char *protocol, "TLIOpenCOTSClient: ...TLIGetAddr() failed: %d\n", errno); t_close(ciptr->fd); - xfree(ciptr); + free(ciptr); return NULL; } @@ -548,7 +548,7 @@ TRANS(TLIOpenCLTSClient)(Xtransport *thistrans, char *protocol, "TLIOpenCLTSClient: ...TLITLIBindLocal() failed: %d\n", errno); t_close(ciptr->fd); - xfree(ciptr); + free(ciptr); return NULL; } @@ -558,7 +558,7 @@ TRANS(TLIOpenCLTSClient)(Xtransport *thistrans, char *protocol, "TLIOpenCLTSClient: ...TLIGetPeerAddr() failed: %d\n", errno); t_close(ciptr->fd); - xfree(ciptr); + free(ciptr); return NULL; } @@ -720,7 +720,7 @@ TRANS(TLICreateListener)(XtransConnInfo ciptr, struct t_bind *req) * Everything looks good: fill in the XtransConnInfo structure. */ - if( (ciptr->addr=(char *)xalloc(ret->addr.len)) == NULL ) + if( (ciptr->addr=(char *)malloc(ret->addr.len)) == NULL ) { prmsg(1, "TLICreateListener: Unable to allocate space for the address\n"); @@ -903,7 +903,7 @@ TRANS(TLIAccept)(XtransConnInfo ciptr, int *status) errno); t_free((char *)call,T_CALL); t_close(newciptr->fd); - xfree(newciptr); + free(newciptr); *status = TRANS_ACCEPT_MISC_ERROR; return NULL; } @@ -947,7 +947,7 @@ TRANS(TLIAccept)(XtransConnInfo ciptr, int *status) "TLIAccept: TRANS(TLIGetPeerAddr)() failed: %d\n", errno); t_close(newciptr->fd); - xfree(newciptr); + free(newciptr); *status = TRANS_ACCEPT_MISC_ERROR; return NULL; } @@ -958,8 +958,8 @@ TRANS(TLIAccept)(XtransConnInfo ciptr, int *status) "TLIAccept: TRANS(TLIGetPeerAddr)() failed: %d\n", errno); t_close(newciptr->fd); - xfree(newciptr->addr); - xfree(newciptr); + free(newciptr->addr); + free(newciptr); *status = TRANS_ACCEPT_MISC_ERROR; return NULL; } @@ -969,8 +969,8 @@ TRANS(TLIAccept)(XtransConnInfo ciptr, int *status) prmsg(1, "TLIAccept() ioctl(I_POP, \"timod\") failed %d\n", errno); t_close(newciptr->fd); - xfree(newciptr->addr); - xfree(newciptr); + free(newciptr->addr); + free(newciptr); *status = TRANS_ACCEPT_MISC_ERROR; return NULL; } @@ -980,8 +980,8 @@ TRANS(TLIAccept)(XtransConnInfo ciptr, int *status) prmsg(1, "TLIAccept() ioctl(I_PUSH,\"tirdwr\") failed %d\n", errno); t_close(newciptr->fd); - xfree(newciptr->addr); - xfree(newciptr); + free(newciptr->addr); + free(newciptr); *status = TRANS_ACCEPT_MISC_ERROR; return NULL; } diff --git a/Xtransutil.c b/Xtransutil.c index dd36cae..4128990 100644 --- a/Xtransutil.c +++ b/Xtransutil.c @@ -197,11 +197,11 @@ TRANS(ConvertAddress)(int *familyp, int *addrlenp, Xtransaddr **addrp) if (len > 0) { if (*addrp && *addrlenp < (len + 1)) { - xfree ((char *) *addrp); + free ((char *) *addrp); *addrp = NULL; } if (!*addrp) - *addrp = (Xtransaddr *) xalloc (len + 1); + *addrp = (Xtransaddr *) malloc (len + 1); if (*addrp) { strcpy ((char *) *addrp, hostnamebuf); *addrlenp = len; @@ -212,7 +212,7 @@ TRANS(ConvertAddress)(int *familyp, int *addrlenp, Xtransaddr **addrp) else { if (*addrp) - xfree ((char *) *addrp); + free ((char *) *addrp); *addrp = NULL; *addrlenp = 0; } @@ -255,7 +255,7 @@ TRANS(GetMyNetworkId) (XtransConnInfo ciptr) case AF_UNIX: { struct sockaddr_un *saddr = (struct sockaddr_un *) addr; - networkId = (char *) xalloc (3 + strlen (transName) + + networkId = (char *) malloc (3 + strlen (transName) + strlen (hostnamebuf) + strlen (saddr->sun_path)); sprintf (networkId, "%s/%s:%s", transName, hostnamebuf, saddr->sun_path); @@ -285,7 +285,7 @@ TRANS(GetMyNetworkId) (XtransConnInfo ciptr) portnum = ntohs (saddr->sin_port); snprintf (portnumbuf, sizeof(portnumbuf), "%d", portnum); - networkId = (char *) xalloc (3 + strlen (transName) + + networkId = (char *) malloc (3 + strlen (transName) + strlen (hostnamebuf) + strlen (portnumbuf)); sprintf (networkId, "%s/%s:%s", transName, hostnamebuf, portnumbuf); break; @@ -418,7 +418,7 @@ TRANS(GetPeerNetworkId) (XtransConnInfo ciptr) } - hostname = (char *) xalloc ( + hostname = (char *) malloc ( strlen (ciptr->transptr->TransName) + strlen (addr) + 2); strcpy (hostname, ciptr->transptr->TransName); strcat (hostname, "/"); diff --git a/transport.c b/transport.c index c14057d..2cb8882 100644 --- a/transport.c +++ b/transport.c @@ -48,10 +48,6 @@ from The Open Group. */ #include <stdlib.h> -#define xalloc(_size) malloc(_size) -#define xcalloc(_num,_size) calloc(_num,_size) -#define xrealloc(_ptr,_size) realloc(_ptr,_size) -#define xfree(_ptr) free(_ptr) #define XTRANS_TRANSPORT_C /* used to flag Xtransint.h that it's being used here, not just #included in another file */ |