diff options
Diffstat (limited to 'X11')
-rw-r--r-- | X11/xtrans/Xtrans.c | 87 | ||||
-rw-r--r-- | X11/xtrans/Xtranslcl.c | 55 | ||||
-rw-r--r-- | X11/xtrans/Xtranssock.c | 55 | ||||
-rw-r--r-- | X11/xtrans/Xtranstli.c | 38 | ||||
-rw-r--r-- | X11/xtrans/Xtransutil.c | 15 | ||||
-rw-r--r-- | X11/xtrans/transport.c | 4 |
6 files changed, 117 insertions, 137 deletions
diff --git a/X11/xtrans/Xtrans.c b/X11/xtrans/Xtrans.c index 522e543c4..54e3bdca7 100644 --- a/X11/xtrans/Xtrans.c +++ b/X11/xtrans/Xtrans.c @@ -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 (ciptr); } @@ -212,8 +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); - strcpy (mybuf, address); + tmpptr = mybuf = strdup (address); /* Parse the string to get each component */ @@ -229,7 +228,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 +278,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 +345,40 @@ TRANS(ParseAddress) (char *address, char **protocol, char **host, char **port) * string space for them. */ - if ((*protocol = (char *) xalloc(strlen (_protocol) + 1)) == NULL) + if ((*protocol = strdup (_protocol)) == 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 = strdup (_host)) == 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 = strdup (_port)) == 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 +423,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 +464,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,15 +516,13 @@ 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 = strdup (port)) == NULL) { prmsg (1,"Reopen: Unable to malloc port string\n"); return NULL; } - strcpy (save_port, port); - /* Get a new XtransConnInfo object */ switch (type) @@ -549,6 +540,7 @@ TRANS(Reopen) (int type, int trans_id, int fd, char *port) if (ciptr == NULL) { prmsg (1,"Reopen: transport open failed\n"); + free (save_port); return NULL; } @@ -652,13 +644,10 @@ TRANS(GetReopenInfo) (XtransConnInfo ciptr, *trans_id = Xtransports[i].transport_id; *fd = ciptr->fd; - if ((*port = (char *) xalloc (strlen (ciptr->port) + 1)) == NULL) + if ((*port = strdup (ciptr->port)) == NULL) return 0; else - { - strcpy (*port, ciptr->port); return 1; - } } return 0; @@ -843,16 +832,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; } @@ -950,7 +939,7 @@ TRANS(GetMyAddr) (XtransConnInfo ciptr, int *familyp, int *addrlenp, *familyp = ciptr->family; *addrlenp = ciptr->addrlen; - if ((*addrp = (Xtransaddr *) xalloc (ciptr->addrlen)) == NULL) + if ((*addrp = malloc (ciptr->addrlen)) == NULL) { prmsg (1,"GetMyAddr: malloc failed\n"); return -1; @@ -970,7 +959,7 @@ TRANS(GetPeerAddr) (XtransConnInfo ciptr, int *familyp, int *addrlenp, *familyp = ciptr->family; *addrlenp = ciptr->peeraddrlen; - if ((*addrp = (Xtransaddr *) xalloc (ciptr->peeraddrlen)) == NULL) + if ((*addrp = malloc (ciptr->peeraddrlen)) == NULL) { prmsg (1,"GetPeerAddr: malloc failed\n"); return -1; @@ -1139,7 +1128,7 @@ TRANS(MakeAllCOTSServerListeners) (char *port, int *partial, int *count_ret, if (*count_ret > 0) { - if ((*ciptrs_ret = (XtransConnInfo *) xalloc ( + if ((*ciptrs_ret = malloc ( *count_ret * sizeof (XtransConnInfo))) == NULL) { return -1; @@ -1237,7 +1226,7 @@ TRANS(MakeAllCLTSServerListeners) (char *port, int *partial, int *count_ret, if (*count_ret > 0) { - if ((*ciptrs_ret = (XtransConnInfo *) xalloc ( + if ((*ciptrs_ret = malloc ( *count_ret * sizeof (XtransConnInfo))) == NULL) { return -1; diff --git a/X11/xtrans/Xtranslcl.c b/X11/xtrans/Xtranslcl.c index 8466ddc4c..5beef7c98 100644 --- a/X11/xtrans/Xtranslcl.c +++ b/X11/xtrans/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 = 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,11 @@ TRANS(FillAddrInfo)(XtransConnInfo ciptr, char *sun_path, char *peer_sun_path) ciptr->peeraddrlen = sizeof (struct sockaddr_un); - if ((p_sunaddr = (struct sockaddr_un *) xalloc ( - ciptr->peeraddrlen)) == NULL) + if ((p_sunaddr = malloc (ciptr->peeraddrlen)) == NULL) { prmsg(1, "FillAddrInfo: failed to allocate memory for peer addr\n"); - xfree ((char *) sunaddr); + free (sunaddr); ciptr->addr = NULL; return 0; @@ -189,7 +188,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 +612,7 @@ TRANS(PTSAccept)(XtransConnInfo ciptr, XtransConnInfo newciptr, int *status) */ newciptr->addrlen=ciptr->addrlen; - if( (newciptr->addr=(char *)xalloc(newciptr->addrlen)) == NULL ) { + if( (newciptr->addr = malloc(newciptr->addrlen)) == NULL ) { prmsg(1,"PTSAccept: failed to allocate memory for peer addr\n"); close(newfd); *status = TRANS_ACCEPT_BAD_MALLOC; @@ -623,9 +622,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 = 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 +884,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 = malloc(newciptr->addrlen)) == NULL ) { prmsg(1, "NAMEDAccept: failed to allocate memory for pipe addr\n"); close(str.fd); @@ -896,10 +895,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 = 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 +1222,7 @@ TRANS(SCOAccept)(XtransConnInfo ciptr, XtransConnInfo newciptr, int *status) */ newciptr->addrlen=ciptr->addrlen; - if( (newciptr->addr=(char *)xalloc(newciptr->addrlen)) == NULL ) { + if( (newciptr->addr = malloc(newciptr->addrlen)) == NULL ) { prmsg(1, "SCOAccept: failed to allocate memory for peer addr\n"); close(fd); @@ -1237,10 +1236,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 = 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,17 +1670,13 @@ TRANS(LocalInitTransports)(const char *protocol) if( strcmp(protocol,"local") && strcmp(protocol,"LOCAL") ) { - workingXLOCAL=freeXLOCAL=(char *)xalloc (strlen (protocol) + 1); - if (workingXLOCAL) - strcpy (workingXLOCAL, protocol); + workingXLOCAL = freeXLOCAL = strdup (protocol); } else { XLOCAL=(char *)getenv("XLOCAL"); if(XLOCAL==NULL) XLOCAL=DEF_XLOCAL; - workingXLOCAL=freeXLOCAL=(char *)xalloc (strlen (XLOCAL) + 1); - if (workingXLOCAL) - strcpy (workingXLOCAL, XLOCAL); + workingXLOCAL = freeXLOCAL = strdup (XLOCAL); } } @@ -1690,7 +1685,7 @@ TRANS(LocalEndTransports)(void) { prmsg(3,"LocalEndTransports()\n"); - xfree(freeXLOCAL); + free(freeXLOCAL); } #define TYPEBUFSIZE 32 @@ -1815,7 +1810,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 = calloc(1,sizeof(struct _XtransConnInfo))) == NULL ) { prmsg(1,"LocalOpenClient: calloc(1,%lu) failed\n", sizeof(struct _XtransConnInfo)); @@ -1856,7 +1851,7 @@ TRANS(LocalOpenClient)(int type, char *protocol, char *host, char *port) if( ciptr->fd < 0 ) { - xfree(ciptr); + free(ciptr); return NULL; } @@ -1889,7 +1884,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 = calloc(1,sizeof(struct _XtransConnInfo))) == NULL ) { prmsg(1,"LocalOpenServer: calloc(1,%lu) failed\n", sizeof(struct _XtransConnInfo)); @@ -1925,7 +1920,7 @@ TRANS(LocalOpenServer)(int type, char *protocol, char *host _X_UNUSED, char *por } } - xfree(ciptr); + free(ciptr); return NULL; } @@ -1943,7 +1938,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 = calloc(1,sizeof(struct _XtransConnInfo))) == NULL ) { prmsg(1,"LocalReopenServer: calloc(1,%lu) failed\n", sizeof(struct _XtransConnInfo)); @@ -1972,7 +1967,7 @@ TRANS(LocalReopenServer)(int type, int index, int fd, char *port) return ciptr; } - xfree(ciptr); + free(ciptr); return NULL; } @@ -2175,7 +2170,7 @@ TRANS(LocalAccept)(XtransConnInfo ciptr, int *status) transptr=(LOCALtrans2dev *)ciptr->priv; - if( (newciptr=(XtransConnInfo)xcalloc(1,sizeof(struct _XtransConnInfo)))==NULL ) + if( (newciptr = calloc(1,sizeof(struct _XtransConnInfo)))==NULL ) { prmsg(1,"LocalAccept: calloc(1,%lu) failed\n", sizeof(struct _XtransConnInfo)); @@ -2187,7 +2182,7 @@ TRANS(LocalAccept)(XtransConnInfo ciptr, int *status) if( newciptr->fd < 0 ) { - xfree(newciptr); + free(newciptr); return NULL; } diff --git a/X11/xtrans/Xtranssock.c b/X11/xtrans/Xtranssock.c index 955516db3..66f9862b9 100644 --- a/X11/xtrans/Xtranssock.c +++ b/X11/xtrans/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 = 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 = malloc (namelen)) == NULL) { prmsg (1, "SocketINETGetPeerAddr: Can't allocate space for the addr\n"); @@ -404,8 +404,7 @@ TRANS(SocketOpen) (int i, int type) prmsg (3,"SocketOpen(%d,%d)\n", i, type); - if ((ciptr = (XtransConnInfo) xcalloc ( - 1, sizeof(struct _XtransConnInfo))) == NULL) + if ((ciptr = calloc (1, sizeof(struct _XtransConnInfo))) == NULL) { prmsg (1, "SocketOpen: malloc failed\n"); return NULL; @@ -425,7 +424,7 @@ TRANS(SocketOpen) (int i, int type) prmsg (2, "SocketOpen: socket() failed for %s\n", Sockettrans2devtab[i].transname); - xfree ((char *) ciptr); + free (ciptr); return NULL; } @@ -481,8 +480,7 @@ TRANS(SocketReopen) (int i _X_UNUSED, int type, int fd, char *port) } #endif /*SOCK_MAXADDRLEN*/ - if ((ciptr = (XtransConnInfo) xcalloc ( - 1, sizeof(struct _XtransConnInfo))) == NULL) + if ((ciptr = calloc (1, sizeof(struct _XtransConnInfo))) == NULL) { prmsg (1, "SocketReopen: malloc(ciptr) failed\n"); return NULL; @@ -490,15 +488,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 = calloc (1, portlen + 2)) == NULL) { prmsg (1, "SocketReopen: malloc(addr) failed\n"); + free (ciptr); return NULL; } ciptr->addr = (char *) addr; ciptr->addrlen = portlen + 2; - if ((ciptr->peeraddr = (char *) xcalloc (1, portlen + 2)) == NULL) { + if ((ciptr->peeraddr = calloc (1, portlen + 2)) == NULL) { prmsg (1, "SocketReopen: malloc(portaddr) failed\n"); + free (addr); + free (ciptr); return NULL; } ciptr->peeraddrlen = portlen + 2; @@ -1135,7 +1136,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 = malloc (namelen)) == NULL) { prmsg (1, "SocketUNIXCreateListener: Can't allocate space for the addr\n"); @@ -1249,8 +1250,7 @@ TRANS(SocketINETAccept) (XtransConnInfo ciptr, int *status) prmsg (2, "SocketINETAccept(%p,%d)\n", ciptr, ciptr->fd); - if ((newciptr = (XtransConnInfo) xcalloc ( - 1, sizeof(struct _XtransConnInfo))) == NULL) + if ((newciptr = calloc (1, sizeof(struct _XtransConnInfo))) == NULL) { prmsg (1, "SocketINETAccept: malloc failed\n"); *status = TRANS_ACCEPT_BAD_MALLOC; @@ -1264,7 +1264,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; } @@ -1291,7 +1291,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; } @@ -1301,8 +1301,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; } @@ -1326,8 +1326,7 @@ TRANS(SocketUNIXAccept) (XtransConnInfo ciptr, int *status) prmsg (2, "SocketUNIXAccept(%p,%d)\n", ciptr, ciptr->fd); - if ((newciptr = (XtransConnInfo) xcalloc ( - 1, sizeof(struct _XtransConnInfo))) == NULL) + if ((newciptr = calloc (1, sizeof(struct _XtransConnInfo))) == NULL) { prmsg (1, "SocketUNIXAccept: malloc() failed\n"); *status = TRANS_ACCEPT_BAD_MALLOC; @@ -1338,7 +1337,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; } @@ -1349,12 +1348,12 @@ TRANS(SocketUNIXAccept) (XtransConnInfo ciptr, int *status) * since this is unix domain. */ - if ((newciptr->addr = (char *) xalloc (ciptr->addrlen)) == NULL) + if ((newciptr->addr = 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; } @@ -1367,13 +1366,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 = 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; } @@ -1551,7 +1550,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"); @@ -1587,7 +1586,7 @@ TRANS(SocketINETConnect) (XtransConnInfo ciptr, char *host, char *port) "socket for IPv6 address\n"); } if (newciptr) - xfree(newciptr); + free(newciptr); } else { @@ -2050,8 +2049,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 = malloc(namelen)) == NULL || + (ciptr->peeraddr = malloc(namelen)) == NULL) { prmsg (1, "SocketUNIXCreateListener: Can't allocate space for the addr\n"); diff --git a/X11/xtrans/Xtranstli.c b/X11/xtrans/Xtranstli.c index 8601c137b..397c946df 100644 --- a/X11/xtrans/Xtranstli.c +++ b/X11/xtrans/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 = 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 = 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 = 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 = 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 = 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/X11/xtrans/Xtransutil.c b/X11/xtrans/Xtransutil.c index 5dd245307..52c937b04 100644 --- a/X11/xtrans/Xtransutil.c +++ b/X11/xtrans/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 (*addrp); *addrp = NULL; } if (!*addrp) - *addrp = (Xtransaddr *) xalloc (len + 1); + *addrp = 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 (*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 = 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 = malloc (3 + strlen (transName) + strlen (hostnamebuf) + strlen (portnumbuf)); sprintf (networkId, "%s/%s:%s", transName, hostnamebuf, portnumbuf); break; @@ -418,8 +418,7 @@ TRANS(GetPeerNetworkId) (XtransConnInfo ciptr) } - hostname = (char *) xalloc ( - strlen (ciptr->transptr->TransName) + strlen (addr) + 2); + hostname = malloc (strlen (ciptr->transptr->TransName) + strlen (addr) + 2); strcpy (hostname, ciptr->transptr->TransName); strcat (hostname, "/"); if (addr) @@ -586,6 +585,7 @@ trans_mkdir(const char *path, int mode) if (fstat(fd, &fbuf) == -1) { prmsg(1, "mkdir: ERROR: fstat failed for %s (%d)\n", path, errno); + close(fd); return -1; } /* @@ -597,6 +597,7 @@ trans_mkdir(const char *path, int mode) buf.st_ino != fbuf.st_ino) { prmsg(1, "mkdir: ERROR: inode for %s changed\n", path); + close(fd); return -1; } if (updateOwner && fchown(fd, 0, 0) == 0) diff --git a/X11/xtrans/transport.c b/X11/xtrans/transport.c index c14057dd3..2cb88825e 100644 --- a/X11/xtrans/transport.c +++ b/X11/xtrans/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 */ |