mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-13 00:57:33 -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:
6
plink.c
6
plink.c
@ -410,13 +410,13 @@ int main(int argc, char **argv)
|
||||
while (*p) {
|
||||
if (cmdlen >= cmdsize) {
|
||||
cmdsize = cmdlen + 512;
|
||||
command = srealloc(command, cmdsize);
|
||||
command = sresize(command, cmdsize, char);
|
||||
}
|
||||
command[cmdlen++]=*p++;
|
||||
}
|
||||
if (cmdlen >= cmdsize) {
|
||||
cmdsize = cmdlen + 512;
|
||||
command = srealloc(command, cmdsize);
|
||||
command = sresize(command, cmdsize, char);
|
||||
}
|
||||
command[cmdlen++]=' '; /* always add trailing space */
|
||||
if (--argc) p = *++argv;
|
||||
@ -651,7 +651,7 @@ int main(int argc, char **argv)
|
||||
/* Expand the buffer if necessary. */
|
||||
if (i > sksize) {
|
||||
sksize = i + 16;
|
||||
sklist = srealloc(sklist, sksize * sizeof(*sklist));
|
||||
sklist = sresize(sklist, sksize, SOCKET);
|
||||
}
|
||||
|
||||
/* Retrieve the sockets into sklist. */
|
||||
|
Reference in New Issue
Block a user