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

@ -746,24 +746,24 @@ static void des_cbc3_decrypt(unsigned char *dest, const unsigned char *src,
static void *des3_make_context(void)
{
return smalloc(3*sizeof(DESContext));
return snewn(3, DESContext);
}
static void *des3_ssh1_make_context(void)
{
/* Need 3 keys for each direction, in SSH1 */
return smalloc(6*sizeof(DESContext));
return snewn(6, DESContext);
}
static void *des_make_context(void)
{
return smalloc(sizeof(DESContext));
return snew(DESContext);
}
static void *des_ssh1_make_context(void)
{
/* Need one key for each direction, in SSH1 */
return smalloc(2*sizeof(DESContext));
return snewn(2, DESContext);
}
static void des3_free_context(void *handle) /* used for both 3DES and DES */