1
0
mirror of https://github.com/libssh2/libssh2.git synced 2025-11-20 02:42:09 +03:00

calloc: introduce LIBSSH2_CALLOC()

A simple function using LIBSSH2_ALLOC + memset, since this pattern was
used in multiple places and this simplies code in general.
This commit is contained in:
Daniel Stenberg
2014-12-22 15:59:21 +01:00
parent 977a3b6a76
commit 031566f9cc
12 changed files with 39 additions and 50 deletions

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2009 by Daiki Ueno
* Copyright (C) 2010 by Daniel Stenberg
* Copyright (C) 2014 by Daniel Stenberg
* All rights reserved.
*
* Redistribution and use in source and binary forms,
@@ -660,13 +660,12 @@ libssh2_agent_init(LIBSSH2_SESSION *session)
{
LIBSSH2_AGENT *agent;
agent = LIBSSH2_ALLOC(session, sizeof *agent);
agent = LIBSSH2_CALLOC(session, sizeof *agent);
if (!agent) {
_libssh2_error(session, LIBSSH2_ERROR_ALLOC,
"Unable to allocate space for agent connection");
return NULL;
}
memset(agent, 0, sizeof *agent);
agent->fd = LIBSSH2_INVALID_SOCKET;
agent->session = session;
_libssh2_list_init(&agent->head);