Commit c3ff3457 authored by Niels Möller's avatar Niels Möller
Browse files

Use NEW() macro.

Rev: src/connection.c:1.13
Rev: src/crypto.c:1.9
Rev: src/debug.c:1.14
Rev: src/disconnect.c:1.7
Rev: src/encrypt.c:1.13
parent cee1c3b4
......@@ -90,7 +90,9 @@ static int do_fail(struct packet_handler *closure,
struct packet_handler *make_fail_handler(void)
{
struct packet_handler *res = xalloc(sizeof(struct packet_handler));
struct packet_handler *res;
NEW(res);
res->handler = do_fail;
return res;
......@@ -117,7 +119,9 @@ static int do_unimplemented(struct packet_handler *closure,
struct packet_handler *make_unimplemented_handler(void)
{
struct packet_handler *res = xalloc(sizeof(struct packet_handler));
struct packet_handler *res;
NEW(res);
res->handler = do_unimplemented;
return res;
......@@ -126,9 +130,10 @@ struct packet_handler *make_unimplemented_handler(void)
struct ssh_connection *make_ssh_connection(struct packet_handler *kex_handler)
{
struct ssh_connection *connection = xalloc(sizeof(struct ssh_connection));
struct ssh_connection *connection;
int i;
NEW(connection);
connection->super.write = handle_connection;
/* Initialize instance variables */
......
......@@ -72,7 +72,9 @@ static void do_crypt_rc4(struct crypto_instance *s,
static struct crypto_instance *
make_rc4_instance(struct crypto_algorithm *ignored, int mode, UINT8 *key)
{
struct rc4_instance *self = xalloc(sizeof(struct rc4_instance));
struct rc4_instance *self;
NEW(self);
self->super.block_size = 8;
self->super.crypt = do_crypt_rc4;
......@@ -118,17 +120,21 @@ static void do_sha_digest(struct hash_instance *s,
static struct hash_instance *do_sha_copy(struct hash_instance *s)
{
struct sha_instance *self = (struct sha_instance *) s;
struct sha_instance *new = xalloc(sizeof(struct sha_instance));
struct sha_instance *new;
MDEBUG(self);
NEW(new);
memcpy(new, self, sizeof(*self));
return &new->super;
}
static struct hash_instance *make_sha_instance(struct hash_algorithm *ignored)
{
struct sha_instance *res = xalloc(sizeof(struct sha_instance));
struct sha_instance *res;
NEW(res);
res->super.hash_size = 20;
res->super.update = do_sha_update;
......@@ -194,10 +200,12 @@ static void do_hmac_digest(struct mac_instance *s,
static struct mac_instance *do_hmac_copy(struct mac_instance *s)
{
struct hmac_instance *self = (struct hmac_instance *) s;
struct hmac_instance *new = xalloc(sizeof(struct hmac_instance));
struct hmac_instance *new;
MDEBUG(self);
NEW(new);
memcpy(&new->super, &self->super, sizeof(self->super));
/* FIXME: Sharing hinner and houter objects makes gc more difficult */
......@@ -215,12 +223,14 @@ static struct mac_instance *make_hmac_instance(struct mac_algorithm *s,
UINT8 *key)
{
struct hmac_algorithm *self = (struct hmac_algorithm *) s;
struct hmac_instance *instance = xalloc(sizeof(struct hmac_instance));
struct hmac_instance *instance;
UINT8 *pad = alloca(self->hash->block_size);
int i;
MDEBUG(self);
NEW(instance);
instance->super.hash_size = self->super.hash_size;
instance->super.update = do_hmac_update;
instance->super.digest = do_hmac_digest;
......@@ -249,7 +259,9 @@ static struct mac_instance *make_hmac_instance(struct mac_algorithm *s,
struct mac_algorithm *make_hmac_algorithm(struct hash_algorithm *h)
{
struct hmac_algorithm *self = xalloc(sizeof(struct hmac_algorithm));
struct hmac_algorithm *self;
NEW(self);
self->super.hash_size = h->hash_size;
/* Recommended in RFC-2104 */
......
......@@ -56,7 +56,9 @@ static int do_debug(struct abstract_write **w,
struct abstract_write *
make_packet_debug(struct abstract_write *continuation, char *prefix)
{
struct packet_debug *closure = xalloc(sizeof(struct packet_debug));
struct packet_debug *closure;
NEW(closure);
closure->super.super.write = do_debug;
closure->super.next = continuation;
......@@ -133,7 +135,9 @@ static int do_rec_debug(struct packet_handler *self,
struct packet_handler *make_rec_debug_handler(void)
{
struct packet_handler *self = xalloc(sizeof(struct packet_handler));
struct packet_handler *self;
NEW(self);
self->handler = do_rec_debug;
......
......@@ -72,7 +72,9 @@ static int do_disconnect(struct packet_handler *closure,
struct packet_handler *make_disconnect_handler(void)
{
struct packet_handler *res = xalloc(sizeof(struct packet_handler));
struct packet_handler *res;
NEW(res);
res->handler = do_disconnect;
return res;
......
......@@ -75,7 +75,9 @@ struct abstract_write *
make_packet_encrypt(struct abstract_write *continuation,
struct ssh_connection *connection)
{
struct packet_encrypt *closure = xalloc(sizeof(struct packet_encrypt));
struct packet_encrypt *closure;
NEW(closure);
closure->super.super.write = do_encrypt;
closure->super.next = continuation;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment