use calloc instead of malloc + memset
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2600 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
parent
f60996526a
commit
47d2baf5a3
|
@ -480,9 +480,8 @@ static int ctapi_load_module(sc_context_t *ctx,
|
|||
sc_error(ctx, "CT_init() failed with %d\n", rv);
|
||||
continue;
|
||||
}
|
||||
reader = (sc_reader_t *) malloc(sizeof(sc_reader_t));
|
||||
reader = (sc_reader_t *) calloc(1, sizeof(sc_reader_t));
|
||||
priv = (struct ctapi_private_data *) malloc(sizeof(struct ctapi_private_data));
|
||||
memset(reader, 0, sizeof(*reader));
|
||||
reader->drv_data = priv;
|
||||
reader->ops = &ctapi_ops;
|
||||
reader->driver = &ctapi_drv;
|
||||
|
@ -521,10 +520,9 @@ static int ctapi_init(sc_context_t *ctx, void **reader_data)
|
|||
struct ctapi_global_private_data *gpriv;
|
||||
scconf_block **blocks = NULL, *conf_block = NULL;
|
||||
|
||||
gpriv = (struct ctapi_global_private_data *) malloc(sizeof(struct ctapi_global_private_data));
|
||||
gpriv = (struct ctapi_global_private_data *) calloc(1, sizeof(struct ctapi_global_private_data));
|
||||
if (gpriv == NULL)
|
||||
return SC_ERROR_OUT_OF_MEMORY;
|
||||
memset(gpriv, 0, sizeof(*gpriv));
|
||||
*reader_data = gpriv;
|
||||
|
||||
for (i = 0; ctx->conf_blocks[i] != NULL; i++) {
|
||||
|
|
|
@ -639,7 +639,7 @@ static int pcsc_init(sc_context_t *ctx, void **reader_data)
|
|||
}
|
||||
p = reader_buf;
|
||||
do {
|
||||
sc_reader_t *reader = (sc_reader_t *) malloc(sizeof(sc_reader_t));
|
||||
sc_reader_t *reader = (sc_reader_t *) calloc(1, sizeof(sc_reader_t));
|
||||
struct pcsc_private_data *priv = (struct pcsc_private_data *) malloc(sizeof(struct pcsc_private_data));
|
||||
struct pcsc_slot_data *pslot = (struct pcsc_slot_data *) malloc(sizeof(struct pcsc_slot_data));
|
||||
sc_slot_info_t *slot;
|
||||
|
@ -654,7 +654,6 @@ static int pcsc_init(sc_context_t *ctx, void **reader_data)
|
|||
break;
|
||||
}
|
||||
|
||||
memset(reader, 0, sizeof(*reader));
|
||||
reader->drv_data = priv;
|
||||
reader->ops = &pcsc_ops;
|
||||
reader->driver = &pcsc_drv;
|
||||
|
|
|
@ -119,10 +119,9 @@ static int extract_certificate_and_pkey(PluginInstance *inst,
|
|||
goto err;
|
||||
rsa->flags |= RSA_FLAG_SIGN_VER;
|
||||
RSA_set_method(rsa, sc_get_method());
|
||||
priv = (struct sc_priv_data *) malloc(sizeof(*priv));
|
||||
priv = (struct sc_priv_data *) calloc(1, sizeof(*priv));
|
||||
if (priv == NULL)
|
||||
goto err;
|
||||
memset(priv, 0, sizeof(struct sc_priv_data));
|
||||
priv->cert_id = cert_id;
|
||||
priv->ref_count = 1;
|
||||
RSA_set_app_data(rsa, priv);
|
||||
|
|
Loading…
Reference in New Issue