1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-06-30 19:12:48 -05:00

Introduced wrapper macros snew(), snewn() and sresize() for the

malloc functions, which automatically cast to the same type they're
allocating the size of. Should prevent any future errors involving
mallocing the size of the wrong structure type, and will also make
life easier if we ever need to turn the PuTTY core code from real C
into C++-friendly C. I haven't touched the Mac frontend in this
checkin because I couldn't compile or test it.

[originally from svn r3014]
This commit is contained in:
Simon Tatham
2003-03-29 16:14:26 +00:00
parent 70729da988
commit d36a4c3685
60 changed files with 385 additions and 389 deletions

View File

@ -611,18 +611,11 @@ static void do_telnet_read(Telnet telnet, char *buf, int len)
else {
subneg_addchar:
if (telnet->sb_len >= telnet->sb_size) {
unsigned char *newbuf;
telnet->sb_size += SB_DELTA;
newbuf = (telnet->sb_buf ?
srealloc(telnet->sb_buf, telnet->sb_size) :
smalloc(telnet->sb_size));
if (newbuf)
telnet->sb_buf = newbuf;
else
telnet->sb_size -= SB_DELTA;
telnet->sb_buf = sresize(telnet->sb_buf, telnet->sb_size,
unsigned char);
}
if (telnet->sb_len < telnet->sb_size)
telnet->sb_buf[telnet->sb_len++] = c;
telnet->sb_buf[telnet->sb_len++] = c;
telnet->state = SUBNEGOT; /* in case we came here by goto */
}
break;
@ -691,7 +684,7 @@ static char *telnet_init(void *frontend_handle, void **backend_handle,
char *err;
Telnet telnet;
telnet = smalloc(sizeof(*telnet));
telnet = snew(struct telnet_tag);
telnet->fn = &fn_table;
telnet->cfg = *cfg; /* STRUCTURE COPY */
telnet->s = NULL;