Commit 26227133 authored by Niels Möller's avatar Niels Möller

Use NEW() macro.

Rev: src/packet_ignore.c:1.5
Rev: src/pad.c:1.16
Rev: src/publickey_crypto.c:1.17
Rev: src/randomness.c:1.6
Rev: src/read_data.c:1.9
Rev: src/read_line.c:1.11
Rev: src/read_packet.c:1.24
Rev: src/server.c:1.16
Rev: src/server_keyexchange.c:1.13
parent 3a97ae5e
......@@ -37,7 +37,9 @@ static int do_ignore(struct packet_handler *closure,
struct packet_handler *make_ignore_handler(void)
{
struct packet_handler *res = xalloc(sizeof(struct packet_handler));
struct packet_handler *res;
NEW(res);
res->handler = do_ignore;
return res;
......
......@@ -85,10 +85,12 @@ make_packet_pad(struct abstract_write *continuation,
struct ssh_connection *connection,
struct randomness *random)
{
struct packet_pad *closure = xalloc(sizeof(struct packet_pad));
struct packet_pad *closure;
MDEBUG(closure);
NEW(closure);
closure->super.super.write = do_pad;
closure->super.next = continuation;
closure->connection = connection;
......
......@@ -309,7 +309,7 @@ static struct signer *make_dss_signer(struct signature_algorithm *c,
simple_buffer_init(&private_buffer, private_length, private);
res = xalloc(sizeof(struct dss_signer));
NEW(res);
mpz_init(res->public.p);
mpz_init(res->public.q);
......@@ -351,7 +351,7 @@ static struct verifier *make_dss_verifier(struct signature_algorithm *closure,
|| (atom != ATOM_SSH_DSS) )
return 0;
res = xalloc(sizeof(struct dss_verifier));
NEW(res);
mpz_init(res->public.p);
mpz_init(res->public.q);
......@@ -375,7 +375,9 @@ static struct verifier *make_dss_verifier(struct signature_algorithm *closure,
struct signature_algorithm *make_dss_algorithm(struct randomness *random)
{
struct dss_algorithm *dss = xalloc(sizeof(struct dss_algorithm));
struct dss_algorithm *dss;
NEW(dss);
dss->super.make_signer = make_dss_signer;
dss->super.make_verifier = make_dss_verifier;
......@@ -427,7 +429,9 @@ static void zn_power(struct group *c, mpz_t res, mpz_t g, mpz_t e)
/* Assumes p is a prime number */
struct group *make_zn(mpz_t p)
{
struct group_zn *res = xalloc(sizeof(struct group_zn));
struct group_zn *res;
NEW(res);
res->super.member = zn_member;
res->super.invert = zn_invert;
......@@ -491,11 +495,11 @@ void init_diffie_hellman_instance(struct diffie_hellman_method *m,
struct diffie_hellman_method *make_dh1(struct randomness *r)
{
struct diffie_hellman_method *res
= xalloc(sizeof(struct diffie_hellman_method));
struct diffie_hellman_method *res;
mpz_t p;
NEW(res);
mpz_init_set_str(p,
"FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1"
"29024E088A67CC74020BBEA63B139B22514A08798E3404DD"
......
......@@ -73,10 +73,11 @@ static void do_poor_random(struct randomness **r, UINT32 length, UINT8 *dst)
struct randomness *make_poor_random(struct hash_algorithm *hash,
struct lsh_string *init)
{
struct poor_random *self
= xalloc(sizeof(struct poor_random) - 1 + hash->hash_size);
struct poor_random *self;
time_t now = time(NULL); /* To avoid cycles */
NEW(self);
self->super.random = do_poor_random;
self->hash = MAKE_HASH(hash);
......
......@@ -78,7 +78,9 @@ struct read_handler *make_read_data(struct abstract_write *handler,
struct callback *close_callback,
UINT32 block_size)
{
struct read_data *closure = xalloc(sizeof(struct read_data));
struct read_data *closure;
NEW(closure);
closure->super.handler = do_read_data;
closure->block_size = block_size;
......
......@@ -159,7 +159,9 @@ static int do_read_line(struct read_handler **h,
struct read_handler *make_read_line(struct line_handler *handler)
{
struct read_line *closure = xalloc(sizeof(struct read_line));
struct read_line *closure;
NEW(closure);
closure->super.handler = do_read_line;
closure->pos = 0;
......
......@@ -303,7 +303,9 @@ static int do_read_packet(struct read_handler **h,
struct read_handler *make_read_packet(struct abstract_write *handler,
struct ssh_connection *connection)
{
struct read_packet *closure = xalloc(sizeof(struct read_packet));
struct read_packet *closure;
NEW(closure);
closure->super.handler = do_read_packet;
......
......@@ -151,8 +151,9 @@ static struct read_handler *do_line(struct line_handler **h,
struct read_handler *make_server_read_line(struct ssh_connection *c)
{
struct server_line_handler *closure
= xalloc(sizeof(struct server_line_handler));
struct server_line_handler *closure;
NEW(closure);
closure->super.handler = do_line;
closure->connection = c;
......@@ -168,7 +169,9 @@ make_server_callback(struct io_backend *b,
struct make_kexinit *init,
struct packet_handler *kexinit_handler)
{
struct server_callback *connected = xalloc(sizeof(struct server_callback));
struct server_callback *connected;
NEW(connected);
connected->super.f = server_initiate;
connected->backend = b;
......@@ -193,7 +196,9 @@ static int server_die(struct close_callback *closure, int reason)
struct close_callback *make_server_close_handler(void)
{
struct close_callback *c = xalloc(sizeof(struct close_callback));
struct close_callback *c;
NEW(c);
c->f = server_die;
......
......@@ -120,9 +120,14 @@ static int do_init_dh(struct keyexchange_algorithm *c,
void **algorithms)
{
struct dh_server_exchange *closure = (struct dh_server_exchange *) c;
struct dh_server *dh = xalloc(sizeof(struct dh_server));
struct dh_server *dh;
MDEBUG(closure);
MDEBUG(connection);
MDEBUG_SUBTYPE(finished);
MDEBUG_SUBTYPE(ignored);
NEW(dh);
/* FIXME: Use this value to choose a signer function */
if (hostkey_algorithm_atom != ATOM_SSH_DSS)
......@@ -159,7 +164,9 @@ make_dh_server(struct diffie_hellman_method *dh,
struct lsh_string *server_key,
struct signer *signer)
{
struct dh_server_exchange *self = xalloc(sizeof(struct dh_server_exchange));
struct dh_server_exchange *self;
NEW(self);
self->super.init = do_init_dh;
self->dh = dh;
......@@ -210,7 +217,9 @@ static int do_install(struct install_keys *c,
struct install_keys *make_server_install_keys(void **algorithms)
{
struct server_install_keys *self = xalloc(sizeof(struct server_install_keys));
struct server_install_keys *self;
NEW(self);
self->super.install = do_install;
self->algorithms = algorithms;
......
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