mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-02 03:52:49 -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:
@ -43,9 +43,8 @@ static void cmdline_save_param(char *p, char *value, int pri)
|
||||
{
|
||||
if (saves[pri].nsaved >= saves[pri].savesize) {
|
||||
saves[pri].savesize = saves[pri].nsaved + 32;
|
||||
saves[pri].params =
|
||||
srealloc(saves[pri].params,
|
||||
saves[pri].savesize*sizeof(*saves[pri].params));
|
||||
saves[pri].params = sresize(saves[pri].params, saves[pri].savesize,
|
||||
struct cmdline_saved_param);
|
||||
}
|
||||
saves[pri].params[saves[pri].nsaved].p = p;
|
||||
saves[pri].params[saves[pri].nsaved].value = value;
|
||||
@ -234,7 +233,7 @@ int cmdline_process_param(char *p, char *value, int need_save, Config *cfg)
|
||||
d = 0;
|
||||
if (cmdlen >= cmdsize) {
|
||||
cmdsize = cmdlen + 512;
|
||||
command = srealloc(command, cmdsize);
|
||||
command = sresize(command, cmdsize, char);
|
||||
}
|
||||
command[cmdlen++] = d;
|
||||
} while (c != EOF);
|
||||
|
Reference in New Issue
Block a user