2002-10-08 Marcus Brinkmann <marcus@g10code.de>
* util.h (_gpgme_malloc, _gpgme_realloc, _gpgme_calloc, _gpgme_strdup, _gpgme_free): Remove prototypes. (xtrymalloc, xtrycalloc, xtryrealloc, xtrystrdup, xfree): Remove macros. * util.c: File removed. * Makefile.am (libgpgme_la_SOURCES): Remove util.h. * conversion.c (_gpgme_decode_c_string): Use malloc instead of xtrymalloc, realloc instead of xtryrealloc, calloc instead of xtrycalloc, free instead of xfree. (_gpgme_data_append_percentstring_for_xml): Likewise. * data.c (_gpgme_data_new, _gpgme_data_release): Likewise. * data-compat.c (gpgme_data_new_from_filepart): Likewise. * data-mem.c (mem_write, mem_release, gpgme_data_new_from_mem, _gpgme_data_get_as_string): Likewise. * debug.c (debug_init): Likewise. * decrypt.c (_gpgme_release_decrypt_result): Likewise. * delete.c (_gpgme_release_delete_result): Likewise. * edit.c (_gpgme_release_edit_result, _gpgme_op_edit_start): Likewise. * encrypt.c (_gpgme_release_encrypt_result): Likewise. * engine.c (_gpgme_engine_get_info, _gpgme_engine_new, _gpgme_engine_release): Likewise. * engine-gpgsm.c (_gpgme_gpgsm_new, _gpgme_gpgsm_release, _gpgme_gpgsm_op_decrypt, _gpgme_gpgsm_op_delete, gpgsm_set_recipients, _gpgme_gpgsm_op_encrypt, _gpgme_gpgsm_op_export, _gpgme_gpgsm_op_genkey, _gpgme_gpgsm_op_import, _gpgme_gpgsm_op_keylist, _gpgme_gpgsm_op_keylist_ext, _gpgme_gpgsm_op_sign, _gpgme_gpgsm_op_verify, gpgsm_status_handler): Likewise. * genkey.c (_gpgme_release_genkey_result): Likewise. * gpgme.c (gpgme_new, gpgme_release): Likewise. * import.c (_gpgme_release_import_result): Likewise. * key.c (_gpgme_key_cache_init, _gpgme_key_cache_add, key_new, add_subkey, gpgme_key_release, _gpgme_key_append_name): Likewise. * keylist.c (_gpgme_release_keylist_result, keylist_colon_handler, _gpgme_op_keylist_event_cb, gpgme_op_keylist_next): Likewise. * ops.h (test_and_allocate_result): Likewise. * passphrase.c (_gpgme_release_passphrase_result, _gpgme_passphrase_status_handler, _gpgme_passphrase_command_handler): Likewise. * progress.c (_gpgme_progress_status_handler): Likewise. * recipient.c (gpgme_recipients_new, gpgme_recipients_release, gpgme_recipients_add_name_with_validity): Likewise. * rungpg.c (_gpgme_gpg_new, _gpgme_gpg_release, _gpgme_gpg_add_arg, _gpgme_gpg_add_data, _gpgme_gpg_set_colon_line_handler, free_argv, free_fd_data_map, build_argv, _gpgme_gpg_spawn, read_status, read_colon_line): Likewise. * sign.c (_gpgme_release_sign_result): Likewise. * signers.c (_gpgme_signers_add): Likewise. * trustlist.c (trust_item_new, trustlist_colon_handler, _gpgme_op_trustlist_event_cb, gpgme_op_trustlist_next, gpgme_trustitem_release): Likewise. * verify.c (_gpgme_release_verify_result, finish_sig): Likewise. * version.c (gpgme_get_engine_info, _gpgme_get_program_version): Likewise. * w32-io.c (create_reader, create_writer, destroy_reader, destroy_writer, build_commandline, _gpgme_io_spawn): Likewise. * w32-sema.c (critsect_init, _gpgme_sema_cs_destroy): Likewise. * w32-util.c (read_w32_registry_string): Likewise. * wait.c (_gpgme_fd_table_deinit, _gpgme_fd_table_put, _gpgme_wait_event_cb, _gpgme_add_io_cb, _gpgme_remove_io_cb) * data-compat.c: Include <stdlib.h>.
This commit is contained in:
parent
0447e0dd6d
commit
7385627265
@ -1,3 +1,69 @@
|
||||
2002-10-08 Marcus Brinkmann <marcus@g10code.de>
|
||||
|
||||
* util.h (_gpgme_malloc, _gpgme_realloc, _gpgme_calloc,
|
||||
_gpgme_strdup, _gpgme_free): Remove prototypes.
|
||||
(xtrymalloc, xtrycalloc, xtryrealloc, xtrystrdup, xfree): Remove
|
||||
macros.
|
||||
* util.c: File removed.
|
||||
* Makefile.am (libgpgme_la_SOURCES): Remove util.h.
|
||||
* conversion.c (_gpgme_decode_c_string): Use malloc instead of
|
||||
xtrymalloc, realloc instead of xtryrealloc, calloc instead of
|
||||
xtrycalloc, free instead of xfree.
|
||||
(_gpgme_data_append_percentstring_for_xml): Likewise.
|
||||
* data.c (_gpgme_data_new, _gpgme_data_release): Likewise.
|
||||
* data-compat.c (gpgme_data_new_from_filepart): Likewise.
|
||||
* data-mem.c (mem_write, mem_release, gpgme_data_new_from_mem,
|
||||
_gpgme_data_get_as_string): Likewise.
|
||||
* debug.c (debug_init): Likewise.
|
||||
* decrypt.c (_gpgme_release_decrypt_result): Likewise.
|
||||
* delete.c (_gpgme_release_delete_result): Likewise.
|
||||
* edit.c (_gpgme_release_edit_result, _gpgme_op_edit_start):
|
||||
Likewise.
|
||||
* encrypt.c (_gpgme_release_encrypt_result): Likewise.
|
||||
* engine.c (_gpgme_engine_get_info, _gpgme_engine_new,
|
||||
_gpgme_engine_release): Likewise.
|
||||
* engine-gpgsm.c (_gpgme_gpgsm_new, _gpgme_gpgsm_release,
|
||||
_gpgme_gpgsm_op_decrypt, _gpgme_gpgsm_op_delete,
|
||||
gpgsm_set_recipients, _gpgme_gpgsm_op_encrypt,
|
||||
_gpgme_gpgsm_op_export, _gpgme_gpgsm_op_genkey,
|
||||
_gpgme_gpgsm_op_import, _gpgme_gpgsm_op_keylist,
|
||||
_gpgme_gpgsm_op_keylist_ext, _gpgme_gpgsm_op_sign,
|
||||
_gpgme_gpgsm_op_verify, gpgsm_status_handler): Likewise.
|
||||
* genkey.c (_gpgme_release_genkey_result): Likewise.
|
||||
* gpgme.c (gpgme_new, gpgme_release): Likewise.
|
||||
* import.c (_gpgme_release_import_result): Likewise.
|
||||
* key.c (_gpgme_key_cache_init, _gpgme_key_cache_add, key_new,
|
||||
add_subkey, gpgme_key_release, _gpgme_key_append_name): Likewise.
|
||||
* keylist.c (_gpgme_release_keylist_result, keylist_colon_handler,
|
||||
_gpgme_op_keylist_event_cb, gpgme_op_keylist_next): Likewise.
|
||||
* ops.h (test_and_allocate_result): Likewise.
|
||||
* passphrase.c (_gpgme_release_passphrase_result,
|
||||
_gpgme_passphrase_status_handler,
|
||||
_gpgme_passphrase_command_handler): Likewise.
|
||||
* progress.c (_gpgme_progress_status_handler): Likewise.
|
||||
* recipient.c (gpgme_recipients_new, gpgme_recipients_release,
|
||||
gpgme_recipients_add_name_with_validity): Likewise.
|
||||
* rungpg.c (_gpgme_gpg_new, _gpgme_gpg_release,
|
||||
_gpgme_gpg_add_arg, _gpgme_gpg_add_data,
|
||||
_gpgme_gpg_set_colon_line_handler, free_argv, free_fd_data_map,
|
||||
build_argv, _gpgme_gpg_spawn, read_status, read_colon_line):
|
||||
Likewise.
|
||||
* sign.c (_gpgme_release_sign_result): Likewise.
|
||||
* signers.c (_gpgme_signers_add): Likewise.
|
||||
* trustlist.c (trust_item_new, trustlist_colon_handler,
|
||||
_gpgme_op_trustlist_event_cb, gpgme_op_trustlist_next,
|
||||
gpgme_trustitem_release): Likewise.
|
||||
* verify.c (_gpgme_release_verify_result, finish_sig): Likewise.
|
||||
* version.c (gpgme_get_engine_info, _gpgme_get_program_version):
|
||||
Likewise.
|
||||
* w32-io.c (create_reader, create_writer, destroy_reader,
|
||||
destroy_writer, build_commandline, _gpgme_io_spawn): Likewise.
|
||||
* w32-sema.c (critsect_init, _gpgme_sema_cs_destroy): Likewise.
|
||||
* w32-util.c (read_w32_registry_string): Likewise.
|
||||
* wait.c (_gpgme_fd_table_deinit, _gpgme_fd_table_put,
|
||||
_gpgme_wait_event_cb, _gpgme_add_io_cb, _gpgme_remove_io_cb)
|
||||
* data-compat.c: Include <stdlib.h>.
|
||||
|
||||
2002-10-08 Marcus Brinkmann <marcus@g10code.de>
|
||||
|
||||
New data object component:
|
||||
|
@ -56,7 +56,7 @@ system_components = ${ath_components} posix-util.c posix-sema.c posix-io.c
|
||||
endif
|
||||
|
||||
libgpgme_la_SOURCES = \
|
||||
gpgme.h types.h util.h util.c conversion.c context.h ops.h \
|
||||
gpgme.h types.h util.h conversion.c context.h ops.h \
|
||||
data.h data.c data-fd.c data-stream.c data-mem.c data-user.c \
|
||||
data-compat.c \
|
||||
recipient.c signers.c wait.c wait.h op-support.c \
|
||||
|
@ -64,7 +64,7 @@ _gpgme_decode_c_string (const char *src, char **destp)
|
||||
|
||||
/* We can malloc a buffer of the same length, because the converted
|
||||
string will never be larger. */
|
||||
dest = xtrymalloc (strlen (src) + 1);
|
||||
dest = malloc (strlen (src) + 1);
|
||||
if (!dest)
|
||||
return mk_error (Out_Of_Core);
|
||||
|
||||
@ -238,7 +238,7 @@ _gpgme_data_append_percentstring_for_xml (GpgmeData dh, const char *str)
|
||||
int val;
|
||||
GpgmeError err;
|
||||
|
||||
buf = xtrymalloc (strlen (str));
|
||||
buf = malloc (strlen (str));
|
||||
dst = buf;
|
||||
for (src = str; *src; src++)
|
||||
{
|
||||
@ -252,6 +252,6 @@ _gpgme_data_append_percentstring_for_xml (GpgmeData dh, const char *str)
|
||||
}
|
||||
|
||||
err = _gpgme_data_append_for_xml (dh, buf, dst - buf);
|
||||
xfree (buf);
|
||||
free (buf);
|
||||
return err;
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ _gpgme_data_new (GpgmeData *r_dh, struct gpgme_data_cbs *cbs)
|
||||
return mk_error (Invalid_Value);
|
||||
|
||||
*r_dh = NULL;
|
||||
dh = xtrycalloc (1, sizeof (*dh));
|
||||
dh = calloc (1, sizeof (*dh));
|
||||
if (!dh)
|
||||
return mk_error (Out_Of_Core);
|
||||
|
||||
@ -56,7 +56,7 @@ void
|
||||
_gpgme_data_release (GpgmeData dh)
|
||||
{
|
||||
if (dh)
|
||||
xfree (dh);
|
||||
free (dh);
|
||||
}
|
||||
|
||||
|
||||
|
@ -103,7 +103,7 @@ debug_init (void)
|
||||
s1++;
|
||||
if (!(s2 = strchr (s1, ':')))
|
||||
s2 = s1 + strlen (s1);
|
||||
p = xtrymalloc (s2 - s1 + 1);
|
||||
p = malloc (s2 - s1 + 1);
|
||||
if (p)
|
||||
{
|
||||
memcpy (p, s1, s2 - s1);
|
||||
@ -115,7 +115,7 @@ debug_init (void)
|
||||
setvbuf (fp, NULL, _IOLBF, 0);
|
||||
errfp = fp;
|
||||
}
|
||||
xfree (p);
|
||||
free (p);
|
||||
}
|
||||
#ifndef HAVE_DOSISH_SYSTEM
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ _gpgme_release_decrypt_result (DecryptResult result)
|
||||
{
|
||||
if (!result)
|
||||
return;
|
||||
xfree (result);
|
||||
free (result);
|
||||
}
|
||||
|
||||
/* Check whether STRING starts with TOKEN and return true in this
|
||||
|
@ -51,7 +51,7 @@ _gpgme_release_delete_result (DeleteResult result)
|
||||
{
|
||||
if (!result)
|
||||
return;
|
||||
xfree (result);
|
||||
free (result);
|
||||
}
|
||||
|
||||
|
||||
|
@ -40,7 +40,7 @@ _gpgme_release_edit_result (EditResult result)
|
||||
{
|
||||
if (!result)
|
||||
return;
|
||||
xfree (result);
|
||||
free (result);
|
||||
}
|
||||
|
||||
void
|
||||
@ -84,7 +84,7 @@ _gpgme_op_edit_start (GpgmeCtx ctx, int synchronous,
|
||||
goto leave;
|
||||
|
||||
assert (!ctx->result.edit);
|
||||
ctx->result.edit = xtrymalloc (sizeof *ctx->result.edit);
|
||||
ctx->result.edit = malloc (sizeof *ctx->result.edit);
|
||||
if (!ctx->result.edit)
|
||||
{
|
||||
err = mk_error (Out_Of_Core);
|
||||
|
@ -50,7 +50,7 @@ _gpgme_release_encrypt_result (EncryptResult result)
|
||||
if (!result)
|
||||
return;
|
||||
gpgme_data_release (result->xmlinfo);
|
||||
xfree (result);
|
||||
free (result);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -302,7 +302,7 @@ _gpgme_gpgsm_new (GpgsmObject *r_gpgsm)
|
||||
int nfds;
|
||||
|
||||
*r_gpgsm = NULL;
|
||||
gpgsm = xtrycalloc (1, sizeof *gpgsm);
|
||||
gpgsm = calloc (1, sizeof *gpgsm);
|
||||
if (!gpgsm)
|
||||
{
|
||||
err = mk_error (Out_Of_Core);
|
||||
@ -541,9 +541,9 @@ _gpgme_gpgsm_release (GpgsmObject gpgsm)
|
||||
|
||||
assuan_disconnect (gpgsm->assuan_ctx);
|
||||
|
||||
xfree (gpgsm->colon.attic.line);
|
||||
xfree (gpgsm->command);
|
||||
xfree (gpgsm);
|
||||
free (gpgsm->colon.attic.line);
|
||||
free (gpgsm->command);
|
||||
free (gpgsm);
|
||||
}
|
||||
|
||||
/* Forward declaration. */
|
||||
@ -649,7 +649,7 @@ _gpgme_gpgsm_op_decrypt (GpgsmObject gpgsm, GpgmeData ciph, GpgmeData plain)
|
||||
if (!gpgsm)
|
||||
return mk_error (Invalid_Value);
|
||||
|
||||
gpgsm->command = xtrystrdup ("DECRYPT");
|
||||
gpgsm->command = strdup ("DECRYPT");
|
||||
if (!gpgsm->command)
|
||||
return mk_error (Out_Of_Core);
|
||||
|
||||
@ -688,7 +688,7 @@ _gpgme_gpgsm_op_delete (GpgsmObject gpgsm, GpgmeKey key, int allow_secret)
|
||||
}
|
||||
length++;
|
||||
|
||||
line = xtrymalloc (length);
|
||||
line = malloc (length);
|
||||
if (!line)
|
||||
return mk_error (Out_Of_Core);
|
||||
|
||||
@ -742,7 +742,7 @@ gpgsm_set_recipients (GpgsmObject gpgsm, GpgmeRecipients recp)
|
||||
int valid_recipients = 0;
|
||||
|
||||
linelen = 10 + 40 + 1; /* "RECIPIENT " + guess + '\0'. */
|
||||
line = xtrymalloc (10 + 40 + 1);
|
||||
line = malloc (10 + 40 + 1);
|
||||
if (!line)
|
||||
return mk_error (Out_Of_Core);
|
||||
strcpy (line, "RECIPIENT ");
|
||||
@ -751,10 +751,10 @@ gpgsm_set_recipients (GpgsmObject gpgsm, GpgmeRecipients recp)
|
||||
int newlen = 11 + strlen (r->name);
|
||||
if (linelen < newlen)
|
||||
{
|
||||
char *newline = xtryrealloc (line, newlen);
|
||||
char *newline = realloc (line, newlen);
|
||||
if (! newline)
|
||||
{
|
||||
xfree (line);
|
||||
free (line);
|
||||
return mk_error (Out_Of_Core);
|
||||
}
|
||||
line = newline;
|
||||
@ -768,11 +768,11 @@ gpgsm_set_recipients (GpgsmObject gpgsm, GpgmeRecipients recp)
|
||||
valid_recipients = 1;
|
||||
else if (err != GPGME_Invalid_Key)
|
||||
{
|
||||
xfree (line);
|
||||
free (line);
|
||||
return err;
|
||||
}
|
||||
}
|
||||
xfree (line);
|
||||
free (line);
|
||||
if (!valid_recipients && gpgsm->status.fnc)
|
||||
gpgsm->status.fnc (gpgsm->status.fnc_value, GPGME_STATUS_NO_RECP, "");
|
||||
return 0;
|
||||
@ -790,7 +790,7 @@ _gpgme_gpgsm_op_encrypt (GpgsmObject gpgsm, GpgmeRecipients recp,
|
||||
if (!recp)
|
||||
return mk_error (Not_Implemented);
|
||||
|
||||
gpgsm->command = xtrystrdup ("ENCRYPT");
|
||||
gpgsm->command = strdup ("ENCRYPT");
|
||||
if (!gpgsm->command)
|
||||
return mk_error (Out_Of_Core);
|
||||
|
||||
@ -844,10 +844,10 @@ _gpgme_gpgsm_op_export (GpgsmObject gpgsm, GpgmeRecipients recp,
|
||||
/* New string is old string + ' ' + s + '\0'. */
|
||||
if (cmdlen < cmdi + 1 + slen + 1)
|
||||
{
|
||||
char *newcmd = xtryrealloc (cmd, cmdlen * 2);
|
||||
char *newcmd = realloc (cmd, cmdlen * 2);
|
||||
if (!newcmd)
|
||||
{
|
||||
xfree (cmd);
|
||||
free (cmd);
|
||||
return mk_error (Out_Of_Core);
|
||||
}
|
||||
cmd = newcmd;
|
||||
@ -886,7 +886,7 @@ _gpgme_gpgsm_op_genkey (GpgsmObject gpgsm, GpgmeData help_data, int use_armor,
|
||||
if (!gpgsm || !pubkey || seckey)
|
||||
return mk_error (Invalid_Value);
|
||||
|
||||
gpgsm->command = xtrystrdup ("GENKEY");
|
||||
gpgsm->command = strdup ("GENKEY");
|
||||
if (!gpgsm->command)
|
||||
return mk_error (Out_Of_Core);
|
||||
|
||||
@ -914,7 +914,7 @@ _gpgme_gpgsm_op_import (GpgsmObject gpgsm, GpgmeData keydata)
|
||||
if (!gpgsm)
|
||||
return mk_error (Invalid_Value);
|
||||
|
||||
gpgsm->command = xtrystrdup ("IMPORT");
|
||||
gpgsm->command = strdup ("IMPORT");
|
||||
if (!gpgsm->command)
|
||||
return mk_error (Out_Of_Core);
|
||||
|
||||
@ -948,7 +948,7 @@ _gpgme_gpgsm_op_keylist (GpgsmObject gpgsm, const char *pattern,
|
||||
return err;
|
||||
|
||||
/* Length is "LISTSECRETKEYS " + p + '\0'. */
|
||||
line = xtrymalloc (15 + strlen (pattern) + 1);
|
||||
line = malloc (15 + strlen (pattern) + 1);
|
||||
if (!line)
|
||||
return mk_error (Out_Of_Core);
|
||||
if (secret_only)
|
||||
@ -1011,7 +1011,7 @@ _gpgme_gpgsm_op_keylist_ext (GpgsmObject gpgsm, const char *pattern[],
|
||||
length++;
|
||||
}
|
||||
}
|
||||
line = xtrymalloc (length);
|
||||
line = malloc (length);
|
||||
if (!line)
|
||||
return mk_error (Out_Of_Core);
|
||||
if (secret_only)
|
||||
@ -1084,7 +1084,7 @@ _gpgme_gpgsm_op_sign (GpgsmObject gpgsm, GpgmeData in, GpgmeData out,
|
||||
if (!gpgsm)
|
||||
return mk_error (Invalid_Value);
|
||||
|
||||
gpgsm->command = xtrystrdup (mode == GPGME_SIG_MODE_DETACH
|
||||
gpgsm->command = strdup (mode == GPGME_SIG_MODE_DETACH
|
||||
? "SIGN --detached" : "SIGN");
|
||||
if (!gpgsm->command)
|
||||
return mk_error (Out_Of_Core);
|
||||
@ -1154,7 +1154,7 @@ _gpgme_gpgsm_op_verify (GpgsmObject gpgsm, GpgmeData sig, GpgmeData signed_text,
|
||||
if (!gpgsm)
|
||||
return mk_error (Invalid_Value);
|
||||
|
||||
gpgsm->command = xtrystrdup ("VERIFY");
|
||||
gpgsm->command = strdup ("VERIFY");
|
||||
if (!gpgsm->command)
|
||||
return mk_error (Out_Of_Core);
|
||||
|
||||
@ -1285,7 +1285,7 @@ gpgsm_status_handler (void *opaque, int fd)
|
||||
if (gpgsm->colon.attic.linesize
|
||||
< *alinelen + linelen + 1)
|
||||
{
|
||||
unsigned char *newline = xtryrealloc (*aline,
|
||||
unsigned char *newline = realloc (*aline,
|
||||
*alinelen + linelen + 1);
|
||||
if (!newline)
|
||||
{
|
||||
|
@ -122,7 +122,7 @@ _gpgme_engine_get_info (GpgmeProtocol proto)
|
||||
|
||||
if (path && version)
|
||||
{
|
||||
char *info = xtrymalloc (strlen (fmt) + strlen (strproto[proto])
|
||||
char *info = malloc (strlen (fmt) + strlen (strproto[proto])
|
||||
+ strlen (path) + strlen (version) + 1);
|
||||
if (!info)
|
||||
info = " <engine>\n"
|
||||
@ -144,7 +144,7 @@ _gpgme_engine_new (GpgmeProtocol proto, EngineObject *r_engine)
|
||||
EngineObject engine;
|
||||
GpgmeError err = 0;
|
||||
|
||||
engine = xtrycalloc (1, sizeof *engine);
|
||||
engine = calloc (1, sizeof *engine);
|
||||
if (!engine)
|
||||
{
|
||||
err = mk_error (Out_Of_Core);
|
||||
@ -204,7 +204,7 @@ _gpgme_engine_release (EngineObject engine)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
xfree (engine);
|
||||
free (engine);
|
||||
}
|
||||
|
||||
|
||||
|
@ -42,7 +42,7 @@ _gpgme_release_genkey_result (GenKeyResult result)
|
||||
{
|
||||
if (!result)
|
||||
return;
|
||||
xfree (result);
|
||||
free (result);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -47,7 +47,7 @@ gpgme_new (GpgmeCtx *r_ctx)
|
||||
if (!r_ctx)
|
||||
return mk_error (Invalid_Value);
|
||||
*r_ctx = 0;
|
||||
ctx = xtrycalloc (1, sizeof *ctx);
|
||||
ctx = calloc (1, sizeof *ctx);
|
||||
if (!ctx)
|
||||
return mk_error (Out_Of_Core);
|
||||
ctx->keylist_mode = GPGME_KEYLIST_MODE_LOCAL;
|
||||
@ -78,9 +78,9 @@ gpgme_release (GpgmeCtx ctx)
|
||||
gpgme_data_release (ctx->notation);
|
||||
gpgme_signers_clear (ctx);
|
||||
if (ctx->signers)
|
||||
xfree (ctx->signers);
|
||||
free (ctx->signers);
|
||||
/* FIXME: Release the key_queue. */
|
||||
xfree (ctx);
|
||||
free (ctx);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -44,7 +44,7 @@ _gpgme_release_import_result (ImportResult result)
|
||||
if (!result)
|
||||
return;
|
||||
gpgme_data_release (result->xmlinfo);
|
||||
xfree (result);
|
||||
free (result);
|
||||
}
|
||||
|
||||
|
||||
|
28
gpgme/key.c
28
gpgme/key.c
@ -89,7 +89,7 @@ _gpgme_key_cache_init (void)
|
||||
if (!key_cache_initialized)
|
||||
{
|
||||
key_cache_size = 503;
|
||||
key_cache = xtrycalloc (key_cache_size, sizeof *key_cache);
|
||||
key_cache = calloc (key_cache_size, sizeof *key_cache);
|
||||
if (!key_cache)
|
||||
{
|
||||
key_cache_size = 0;
|
||||
@ -195,7 +195,7 @@ _gpgme_key_cache_add (GpgmeKey key)
|
||||
}
|
||||
else
|
||||
{
|
||||
item = xtrymalloc (sizeof *item);
|
||||
item = malloc (sizeof *item);
|
||||
if (!item)
|
||||
{
|
||||
UNLOCK (key_cache_lock);
|
||||
@ -278,7 +278,7 @@ key_new (GpgmeKey *r_key, int secret)
|
||||
GpgmeKey key;
|
||||
|
||||
*r_key = NULL;
|
||||
key = xtrycalloc (1, sizeof *key);
|
||||
key = calloc (1, sizeof *key);
|
||||
if (!key)
|
||||
return mk_error (Out_Of_Core);
|
||||
key->ref_count = 1;
|
||||
@ -323,7 +323,7 @@ add_subkey (GpgmeKey key, int secret)
|
||||
{
|
||||
struct subkey_s *k, *kk;
|
||||
|
||||
k = xtrycalloc (1, sizeof *k);
|
||||
k = calloc (1, sizeof *k);
|
||||
if (!k)
|
||||
return NULL;
|
||||
|
||||
@ -383,12 +383,12 @@ gpgme_key_release (GpgmeKey key)
|
||||
}
|
||||
UNLOCK (key_ref_lock);
|
||||
|
||||
xfree (key->keys.fingerprint);
|
||||
free (key->keys.fingerprint);
|
||||
for (k = key->keys.next; k; k = k2)
|
||||
{
|
||||
k2 = k->next;
|
||||
xfree (k->fingerprint);
|
||||
xfree (k);
|
||||
free (k->fingerprint);
|
||||
free (k);
|
||||
}
|
||||
for (u = key->uids; u; u = u2)
|
||||
{
|
||||
@ -396,14 +396,14 @@ gpgme_key_release (GpgmeKey key)
|
||||
for (c = u->certsigs; c; c = c2)
|
||||
{
|
||||
c2 = c->next;
|
||||
xfree (c);
|
||||
free (c);
|
||||
}
|
||||
xfree (u);
|
||||
free (u);
|
||||
}
|
||||
xfree (key->issuer_serial);
|
||||
xfree (key->issuer_name);
|
||||
xfree (key->chain_id);
|
||||
xfree (key);
|
||||
free (key->issuer_serial);
|
||||
free (key->issuer_name);
|
||||
free (key->chain_id);
|
||||
free (key);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -561,7 +561,7 @@ _gpgme_key_append_name (GpgmeKey key, const char *s)
|
||||
/* We can malloc a buffer of the same length, because the converted
|
||||
string will never be larger. Actually we allocate it twice the
|
||||
size, so that we are able to store the parsed stuff there too. */
|
||||
uid = xtrymalloc (sizeof *uid + 2*strlen (s)+3);
|
||||
uid = malloc (sizeof *uid + 2*strlen (s)+3);
|
||||
if (!uid)
|
||||
return mk_error (Out_Of_Core);
|
||||
memset (uid, 0, sizeof *uid);
|
||||
|
@ -47,7 +47,7 @@ _gpgme_release_keylist_result (KeylistResult result)
|
||||
{
|
||||
if (!result)
|
||||
return;
|
||||
xfree (result);
|
||||
free (result);
|
||||
}
|
||||
|
||||
/* Append some XML info. args is currently ignore but we might want
|
||||
@ -397,7 +397,7 @@ keylist_colon_handler (GpgmeCtx ctx, char *line)
|
||||
case 8: /* X.509 serial number */
|
||||
if (rectype == RT_CRT || rectype == RT_CRS)
|
||||
{
|
||||
key->issuer_serial = xtrystrdup (p);
|
||||
key->issuer_serial = strdup (p);
|
||||
if (!key->issuer_serial)
|
||||
ctx->error = mk_error (Out_Of_Core);
|
||||
}
|
||||
@ -492,7 +492,7 @@ keylist_colon_handler (GpgmeCtx ctx, char *line)
|
||||
case 10: /* fingerprint (take only the first one)*/
|
||||
if (!key->keys.fingerprint && *p)
|
||||
{
|
||||
key->keys.fingerprint = xtrystrdup (p);
|
||||
key->keys.fingerprint = strdup (p);
|
||||
if (!key->keys.fingerprint)
|
||||
ctx->error = mk_error (Out_Of_Core);
|
||||
}
|
||||
@ -500,7 +500,7 @@ keylist_colon_handler (GpgmeCtx ctx, char *line)
|
||||
case 13: /* gpgsm chain ID (take only the first one)*/
|
||||
if (!key->chain_id && *p)
|
||||
{
|
||||
key->chain_id = xtrystrdup (p);
|
||||
key->chain_id = strdup (p);
|
||||
if (!key->chain_id)
|
||||
ctx->error = mk_error (Out_Of_Core);
|
||||
}
|
||||
@ -539,7 +539,7 @@ _gpgme_op_keylist_event_cb (void *data, GpgmeEventIO type, void *type_data)
|
||||
|
||||
_gpgme_key_cache_add (key);
|
||||
|
||||
q = xtrymalloc (sizeof *q);
|
||||
q = malloc (sizeof *q);
|
||||
if (!q)
|
||||
{
|
||||
gpgme_key_release (key);
|
||||
@ -728,7 +728,7 @@ gpgme_op_keylist_next (GpgmeCtx ctx, GpgmeKey *r_key)
|
||||
ctx->key_cond = 0;
|
||||
|
||||
*r_key = queue_item->key;
|
||||
xfree (queue_item);
|
||||
free (queue_item);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@
|
||||
{ \
|
||||
if (!ctx->result.field) \
|
||||
{ \
|
||||
ctx->result.field = xtrycalloc (1, sizeof *ctx->result.field); \
|
||||
ctx->result.field = calloc (1, sizeof *ctx->result.field); \
|
||||
if (!ctx->result.field) \
|
||||
{ \
|
||||
ctx->error = mk_error (Out_Of_Core); \
|
||||
|
@ -45,9 +45,9 @@ _gpgme_release_passphrase_result (PassphraseResult result)
|
||||
{
|
||||
if (!result)
|
||||
return;
|
||||
xfree (result->passphrase_info);
|
||||
xfree (result->userid_hint);
|
||||
xfree (result);
|
||||
free (result->passphrase_info);
|
||||
free (result->userid_hint);
|
||||
free (result);
|
||||
}
|
||||
|
||||
|
||||
@ -61,8 +61,8 @@ _gpgme_passphrase_status_handler (GpgmeCtx ctx, GpgmeStatusCode code, char *args
|
||||
switch (code)
|
||||
{
|
||||
case GPGME_STATUS_USERID_HINT:
|
||||
xfree (ctx->result.passphrase->userid_hint);
|
||||
if (!(ctx->result.passphrase->userid_hint = xtrystrdup (args)))
|
||||
free (ctx->result.passphrase->userid_hint);
|
||||
if (!(ctx->result.passphrase->userid_hint = strdup (args)))
|
||||
ctx->error = mk_error (Out_Of_Core);
|
||||
break;
|
||||
|
||||
@ -78,8 +78,8 @@ _gpgme_passphrase_status_handler (GpgmeCtx ctx, GpgmeStatusCode code, char *args
|
||||
|
||||
case GPGME_STATUS_NEED_PASSPHRASE:
|
||||
case GPGME_STATUS_NEED_PASSPHRASE_SYM:
|
||||
xfree (ctx->result.passphrase->passphrase_info);
|
||||
ctx->result.passphrase->passphrase_info = xtrystrdup (args);
|
||||
free (ctx->result.passphrase->passphrase_info);
|
||||
ctx->result.passphrase->passphrase_info = strdup (args);
|
||||
if (!ctx->result.passphrase->passphrase_info)
|
||||
ctx->error = mk_error (Out_Of_Core);
|
||||
break;
|
||||
@ -109,7 +109,7 @@ _gpgme_passphrase_command_handler (void *opaque, GpgmeStatusCode code, const cha
|
||||
|
||||
if (!ctx->result.passphrase)
|
||||
{
|
||||
ctx->result.passphrase = xtrycalloc (1, sizeof *ctx->result.passphrase);
|
||||
ctx->result.passphrase = calloc (1, sizeof *ctx->result.passphrase);
|
||||
if (!ctx->result.passphrase)
|
||||
{
|
||||
ctx->error = mk_error (Out_Of_Core);
|
||||
@ -145,7 +145,7 @@ _gpgme_passphrase_command_handler (void *opaque, GpgmeStatusCode code, const cha
|
||||
userid_hint = "[User ID hint missing]";
|
||||
if (!passphrase_info)
|
||||
passphrase_info = "[passphrase info missing]";
|
||||
buf = xtrymalloc (20 + strlen (userid_hint)
|
||||
buf = malloc (20 + strlen (userid_hint)
|
||||
+ strlen (passphrase_info) + 3);
|
||||
if (!buf)
|
||||
{
|
||||
@ -158,7 +158,7 @@ _gpgme_passphrase_command_handler (void *opaque, GpgmeStatusCode code, const cha
|
||||
|
||||
s = ctx->passphrase_cb (ctx->passphrase_cb_value,
|
||||
buf, &ctx->result.passphrase->last_pw_handle);
|
||||
xfree (buf);
|
||||
free (buf);
|
||||
return s;
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ _gpgme_progress_status_handler (GpgmeCtx ctx, GpgmeStatusCode code, char *args)
|
||||
if (code != GPGME_STATUS_PROGRESS || !*args || !ctx->progress_cb)
|
||||
return;
|
||||
|
||||
args_cpy = xtrystrdup (args);
|
||||
args_cpy = strdup (args);
|
||||
if (!args_cpy)
|
||||
{
|
||||
ctx->error = mk_error (Out_Of_Core);
|
||||
@ -76,5 +76,5 @@ _gpgme_progress_status_handler (GpgmeCtx ctx, GpgmeStatusCode code, char *args)
|
||||
if (type != 'X')
|
||||
ctx->progress_cb (ctx->progress_cb_value, args_cpy, type, current, total);
|
||||
|
||||
xfree (args_cpy);
|
||||
free (args_cpy);
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ gpgme_recipients_new (GpgmeRecipients *r_rset)
|
||||
{
|
||||
GpgmeRecipients rset;
|
||||
|
||||
rset = xtrycalloc ( 1, sizeof *rset );
|
||||
rset = calloc ( 1, sizeof *rset );
|
||||
if (!rset)
|
||||
return mk_error (Out_Of_Core);
|
||||
*r_rset = rset;
|
||||
@ -63,10 +63,10 @@ gpgme_recipients_release ( GpgmeRecipients rset )
|
||||
|
||||
for (u = rset->list; u; u = u2) {
|
||||
u2 = u->next;
|
||||
xfree(u);
|
||||
free(u);
|
||||
}
|
||||
}
|
||||
xfree ( rset );
|
||||
free ( rset );
|
||||
}
|
||||
|
||||
|
||||
@ -112,7 +112,7 @@ gpgme_recipients_add_name_with_validity (GpgmeRecipients rset,
|
||||
|
||||
if (!name || !rset )
|
||||
return mk_error (Invalid_Value);
|
||||
r = xtrymalloc ( sizeof *r + strlen (name) );
|
||||
r = malloc ( sizeof *r + strlen (name) );
|
||||
if (!r)
|
||||
return mk_error (Out_Of_Core);
|
||||
r->validity = val;
|
||||
|
@ -247,7 +247,7 @@ _gpgme_gpg_new (GpgObject *r_gpg)
|
||||
GpgObject gpg;
|
||||
int rc = 0;
|
||||
|
||||
gpg = xtrycalloc (1, sizeof *gpg);
|
||||
gpg = calloc (1, sizeof *gpg);
|
||||
if (!gpg)
|
||||
{
|
||||
rc = mk_error (Out_Of_Core);
|
||||
@ -267,7 +267,7 @@ _gpgme_gpg_new (GpgObject *r_gpg)
|
||||
/* Allocate the read buffer for the status pipe. */
|
||||
gpg->status.bufsize = 1024;
|
||||
gpg->status.readpos = 0;
|
||||
gpg->status.buffer = xtrymalloc (gpg->status.bufsize);
|
||||
gpg->status.buffer = malloc (gpg->status.bufsize);
|
||||
if (!gpg->status.buffer)
|
||||
{
|
||||
rc = mk_error (Out_Of_Core);
|
||||
@ -321,16 +321,16 @@ _gpgme_gpg_release (GpgObject gpg)
|
||||
{
|
||||
struct arg_and_data_s *next = gpg->arglist->next;
|
||||
|
||||
xfree (gpg->arglist);
|
||||
free (gpg->arglist);
|
||||
gpg->arglist = next;
|
||||
}
|
||||
|
||||
xfree (gpg->status.buffer);
|
||||
xfree (gpg->colon.buffer);
|
||||
free (gpg->status.buffer);
|
||||
free (gpg->colon.buffer);
|
||||
if (gpg->argv)
|
||||
free_argv (gpg->argv);
|
||||
gpgme_data_release (gpg->cmd.cb_data);
|
||||
xfree (gpg->cmd.keyword);
|
||||
free (gpg->cmd.keyword);
|
||||
|
||||
if (gpg->status.fd[0] != -1)
|
||||
_gpgme_io_close (gpg->status.fd[0]);
|
||||
@ -343,7 +343,7 @@ _gpgme_gpg_release (GpgObject gpg)
|
||||
free_fd_data_map (gpg->fd_data_map);
|
||||
if (gpg->cmd.fd != -1)
|
||||
_gpgme_io_close (gpg->cmd.fd);
|
||||
xfree (gpg);
|
||||
free (gpg);
|
||||
}
|
||||
|
||||
void
|
||||
@ -365,7 +365,7 @@ _gpgme_gpg_add_arg ( GpgObject gpg, const char *arg )
|
||||
if (gpg->pm.active)
|
||||
return 0;
|
||||
|
||||
a = xtrymalloc ( sizeof *a + strlen (arg) );
|
||||
a = malloc ( sizeof *a + strlen (arg) );
|
||||
if ( !a ) {
|
||||
gpg->arg_error = 1;
|
||||
return mk_error(Out_Of_Core);
|
||||
@ -389,7 +389,7 @@ _gpgme_gpg_add_data (GpgObject gpg, GpgmeData data, int dup_to, int inbound)
|
||||
if (gpg->pm.active)
|
||||
return 0;
|
||||
|
||||
a = xtrymalloc (sizeof *a - 1);
|
||||
a = malloc (sizeof *a - 1);
|
||||
if (!a)
|
||||
{
|
||||
gpg->arg_error = 1;
|
||||
@ -478,12 +478,12 @@ _gpgme_gpg_set_colon_line_handler ( GpgObject gpg,
|
||||
|
||||
gpg->colon.bufsize = 1024;
|
||||
gpg->colon.readpos = 0;
|
||||
gpg->colon.buffer = xtrymalloc (gpg->colon.bufsize);
|
||||
gpg->colon.buffer = malloc (gpg->colon.bufsize);
|
||||
if (!gpg->colon.buffer) {
|
||||
return mk_error (Out_Of_Core);
|
||||
}
|
||||
if (_gpgme_io_pipe (gpg->colon.fd, 1) == -1) {
|
||||
xfree (gpg->colon.buffer); gpg->colon.buffer = NULL;
|
||||
free (gpg->colon.buffer); gpg->colon.buffer = NULL;
|
||||
return mk_error (Pipe_Error);
|
||||
}
|
||||
if ( _gpgme_io_set_close_notify (gpg->colon.fd[0],
|
||||
@ -555,8 +555,8 @@ free_argv ( char **argv )
|
||||
int i;
|
||||
|
||||
for (i=0; argv[i]; i++ )
|
||||
xfree (argv[i]);
|
||||
xfree (argv);
|
||||
free (argv[i]);
|
||||
free (argv);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -574,7 +574,7 @@ free_fd_data_map ( struct fd_data_map_s *fd_data_map )
|
||||
_gpgme_io_close (fd_data_map[i].peer_fd);
|
||||
/* don't release data because this is only a reference */
|
||||
}
|
||||
xfree (fd_data_map);
|
||||
free (fd_data_map);
|
||||
}
|
||||
|
||||
|
||||
@ -630,10 +630,10 @@ build_argv (GpgObject gpg)
|
||||
argc++;
|
||||
argc += 2; /* --comment */
|
||||
|
||||
argv = xtrycalloc (argc + 1, sizeof *argv);
|
||||
argv = calloc (argc + 1, sizeof *argv);
|
||||
if (!argv)
|
||||
return mk_error (Out_Of_Core);
|
||||
fd_data_map = xtrycalloc (datac + 1, sizeof *fd_data_map);
|
||||
fd_data_map = calloc (datac + 1, sizeof *fd_data_map);
|
||||
if (!fd_data_map)
|
||||
{
|
||||
free_argv (argv);
|
||||
@ -641,20 +641,20 @@ build_argv (GpgObject gpg)
|
||||
}
|
||||
|
||||
argc = datac = 0;
|
||||
argv[argc] = xtrystrdup ("gpg"); /* argv[0] */
|
||||
argv[argc] = strdup ("gpg"); /* argv[0] */
|
||||
if (!argv[argc])
|
||||
{
|
||||
xfree (fd_data_map);
|
||||
free (fd_data_map);
|
||||
free_argv (argv);
|
||||
return mk_error (Out_Of_Core);
|
||||
}
|
||||
argc++;
|
||||
if (need_special)
|
||||
{
|
||||
argv[argc] = xtrystrdup ("--enable-special-filenames");
|
||||
argv[argc] = strdup ("--enable-special-filenames");
|
||||
if (!argv[argc])
|
||||
{
|
||||
xfree (fd_data_map);
|
||||
free (fd_data_map);
|
||||
free_argv (argv);
|
||||
return mk_error (Out_Of_Core);
|
||||
}
|
||||
@ -662,10 +662,10 @@ build_argv (GpgObject gpg)
|
||||
}
|
||||
if (use_agent)
|
||||
{
|
||||
argv[argc] = xtrystrdup ("--use-agent");
|
||||
argv[argc] = strdup ("--use-agent");
|
||||
if (!argv[argc])
|
||||
{
|
||||
xfree (fd_data_map);
|
||||
free (fd_data_map);
|
||||
free_argv (argv);
|
||||
return mk_error (Out_Of_Core);
|
||||
}
|
||||
@ -673,27 +673,27 @@ build_argv (GpgObject gpg)
|
||||
}
|
||||
if (!gpg->cmd.used)
|
||||
{
|
||||
argv[argc] = xtrystrdup ("--batch");
|
||||
argv[argc] = strdup ("--batch");
|
||||
if (!argv[argc])
|
||||
{
|
||||
xfree (fd_data_map);
|
||||
free (fd_data_map);
|
||||
free_argv (argv);
|
||||
return mk_error (Out_Of_Core);
|
||||
}
|
||||
argc++;
|
||||
}
|
||||
argv[argc] = xtrystrdup ("--comment");
|
||||
argv[argc] = strdup ("--comment");
|
||||
if (!argv[argc])
|
||||
{
|
||||
xfree (fd_data_map);
|
||||
free (fd_data_map);
|
||||
free_argv (argv);
|
||||
return mk_error (Out_Of_Core);
|
||||
}
|
||||
argc++;
|
||||
argv[argc] = xtrystrdup ("");
|
||||
argv[argc] = strdup ("");
|
||||
if (!argv[argc])
|
||||
{
|
||||
xfree (fd_data_map);
|
||||
free (fd_data_map);
|
||||
free_argv (argv);
|
||||
return mk_error (Out_Of_Core);
|
||||
}
|
||||
@ -712,7 +712,7 @@ build_argv (GpgObject gpg)
|
||||
if (_gpgme_io_pipe (fds, fd_data_map[datac].inbound ? 1 : 0)
|
||||
== -1)
|
||||
{
|
||||
xfree (fd_data_map);
|
||||
free (fd_data_map);
|
||||
free_argv (argv);
|
||||
return mk_error (Pipe_Error);
|
||||
}
|
||||
@ -756,10 +756,10 @@ build_argv (GpgObject gpg)
|
||||
fd_data_map[datac].dup_to = a->dup_to;
|
||||
if (a->dup_to == -1)
|
||||
{
|
||||
argv[argc] = xtrymalloc (25);
|
||||
argv[argc] = malloc (25);
|
||||
if (!argv[argc])
|
||||
{
|
||||
xfree (fd_data_map);
|
||||
free (fd_data_map);
|
||||
free_argv (argv);
|
||||
return mk_error (Out_Of_Core);
|
||||
}
|
||||
@ -772,10 +772,10 @@ build_argv (GpgObject gpg)
|
||||
}
|
||||
else
|
||||
{
|
||||
argv[argc] = xtrystrdup (a->arg);
|
||||
argv[argc] = strdup (a->arg);
|
||||
if (!argv[argc])
|
||||
{
|
||||
xfree (fd_data_map);
|
||||
free (fd_data_map);
|
||||
free_argv (argv);
|
||||
return mk_error (Out_Of_Core);
|
||||
}
|
||||
@ -832,7 +832,7 @@ _gpgme_gpg_spawn (GpgObject gpg, void *opaque)
|
||||
n = 3; /* status_fd, colon_fd and end of list */
|
||||
for (i = 0; gpg->fd_data_map[i].data; i++)
|
||||
n++;
|
||||
fd_child_list = xtrycalloc (n + n, sizeof *fd_child_list);
|
||||
fd_child_list = calloc (n + n, sizeof *fd_child_list);
|
||||
if (!fd_child_list)
|
||||
return mk_error (Out_Of_Core);
|
||||
fd_parent_list = fd_child_list + n;
|
||||
@ -885,7 +885,7 @@ _gpgme_gpg_spawn (GpgObject gpg, void *opaque)
|
||||
|
||||
status = _gpgme_io_spawn (_gpgme_get_gpg_path (),
|
||||
gpg->argv, fd_child_list, fd_parent_list);
|
||||
xfree (fd_child_list);
|
||||
free (fd_child_list);
|
||||
if (status == -1)
|
||||
return mk_error (Exec_Error);
|
||||
|
||||
@ -996,7 +996,7 @@ read_status (GpgObject gpg)
|
||||
{
|
||||
/* Need more room for the read. */
|
||||
bufsize += 1024;
|
||||
buffer = xtryrealloc (buffer, bufsize);
|
||||
buffer = realloc (buffer, bufsize);
|
||||
if (!buffer)
|
||||
return mk_error (Out_Of_Core);
|
||||
}
|
||||
@ -1046,8 +1046,8 @@ read_status (GpgObject gpg)
|
||||
|| r->code == GPGME_STATUS_GET_HIDDEN))
|
||||
{
|
||||
gpg->cmd.code = r->code;
|
||||
xfree (gpg->cmd.keyword);
|
||||
gpg->cmd.keyword = xtrystrdup (rest);
|
||||
free (gpg->cmd.keyword);
|
||||
gpg->cmd.keyword = strdup (rest);
|
||||
if (!gpg->cmd.keyword)
|
||||
return mk_error (Out_Of_Core);
|
||||
/* This should be the last thing we have
|
||||
@ -1171,7 +1171,7 @@ read_colon_line ( GpgObject gpg )
|
||||
if (bufsize - readpos < 256) {
|
||||
/* need more room for the read */
|
||||
bufsize += 1024;
|
||||
buffer = xtryrealloc (buffer, bufsize);
|
||||
buffer = realloc (buffer, bufsize);
|
||||
if ( !buffer )
|
||||
return mk_error (Out_Of_Core);
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ _gpgme_release_sign_result (SignResult result)
|
||||
if (!result)
|
||||
return;
|
||||
gpgme_data_release (result->xmlinfo);
|
||||
xfree (result);
|
||||
free (result);
|
||||
}
|
||||
|
||||
/* Parse the args and save the information
|
||||
|
@ -82,7 +82,7 @@ gpgme_signers_add (GpgmeCtx ctx, const GpgmeKey key)
|
||||
int n = ctx->signers_size + 5;
|
||||
int j;
|
||||
|
||||
newarr = xtryrealloc (ctx->signers, n * sizeof (*newarr));
|
||||
newarr = realloc (ctx->signers, n * sizeof (*newarr));
|
||||
if (!newarr)
|
||||
return mk_error (Out_Of_Core);
|
||||
for (j = ctx->signers_size; j < n; j++)
|
||||
|
@ -46,7 +46,7 @@ trust_item_new (void)
|
||||
{
|
||||
GpgmeTrustItem item;
|
||||
|
||||
item = xtrycalloc (1, sizeof *item);
|
||||
item = calloc (1, sizeof *item);
|
||||
return item;
|
||||
}
|
||||
|
||||
@ -127,7 +127,7 @@ trustlist_colon_handler (GpgmeCtx ctx, char *line)
|
||||
item->val[1] = 0;
|
||||
break;
|
||||
case 9: /* user ID */
|
||||
item->name = xtrystrdup (p);
|
||||
item->name = strdup (p);
|
||||
if (!item->name)
|
||||
ctx->error = mk_error (Out_Of_Core);
|
||||
break;
|
||||
@ -148,7 +148,7 @@ _gpgme_op_trustlist_event_cb (void *data, GpgmeEventIO type, void *type_data)
|
||||
|
||||
assert (type == GPGME_EVENT_NEXT_KEY);
|
||||
|
||||
q = xtrymalloc (sizeof *q);
|
||||
q = malloc (sizeof *q);
|
||||
if (!q)
|
||||
{
|
||||
gpgme_trust_item_release (item);
|
||||
@ -251,7 +251,7 @@ gpgme_op_trustlist_next (GpgmeCtx ctx, GpgmeTrustItem *r_item)
|
||||
ctx->trust_queue = q->next;
|
||||
|
||||
*r_item = q->item;
|
||||
xfree (q);
|
||||
free (q);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -283,8 +283,8 @@ gpgme_trust_item_release (GpgmeTrustItem item)
|
||||
{
|
||||
if (!item)
|
||||
return;
|
||||
xfree (item->name);
|
||||
xfree (item);
|
||||
free (item->name);
|
||||
free (item);
|
||||
}
|
||||
|
||||
|
||||
|
66
gpgme/util.c
66
gpgme/util.c
@ -1,66 +0,0 @@
|
||||
/* util.c
|
||||
* Copyright (C) 2000 Werner Koch (dd9jn)
|
||||
* Copyright (C) 2001 g10 Code GmbH
|
||||
*
|
||||
* This file is part of GPGME.
|
||||
*
|
||||
* GPGME is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GPGME is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "util.h"
|
||||
|
||||
void *
|
||||
_gpgme_malloc (size_t n )
|
||||
{
|
||||
return malloc (n);
|
||||
}
|
||||
|
||||
void *
|
||||
_gpgme_calloc (size_t n, size_t m )
|
||||
{
|
||||
return calloc (n, m);
|
||||
}
|
||||
|
||||
void *
|
||||
_gpgme_realloc (void *p, size_t n)
|
||||
{
|
||||
return realloc (p, n );
|
||||
}
|
||||
|
||||
|
||||
char *
|
||||
_gpgme_strdup (const char *p)
|
||||
{
|
||||
return strdup (p);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
_gpgme_free ( void *a )
|
||||
{
|
||||
free (a);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
13
gpgme/util.h
13
gpgme/util.h
@ -25,19 +25,6 @@
|
||||
#include "types.h"
|
||||
#include "debug.h"
|
||||
|
||||
void *_gpgme_malloc (size_t n );
|
||||
void *_gpgme_calloc (size_t n, size_t m );
|
||||
void *_gpgme_realloc (void *p, size_t n);
|
||||
char *_gpgme_strdup (const char *p);
|
||||
void _gpgme_free ( void *a );
|
||||
|
||||
#define xtrymalloc(a) _gpgme_malloc((a))
|
||||
#define xtrycalloc(a,b) _gpgme_calloc((a),(b))
|
||||
#define xtryrealloc(a,b) _gpgme_realloc((a),(b))
|
||||
#define xtrystrdup(a) _gpgme_strdup((a))
|
||||
#define xfree(a) _gpgme_free((a))
|
||||
|
||||
|
||||
#define mk_error(a) ( GPGME_##a )
|
||||
|
||||
#define DIM(v) (sizeof(v)/sizeof((v)[0]))
|
||||
|
@ -56,7 +56,7 @@ _gpgme_release_verify_result (VerifyResult result)
|
||||
{
|
||||
VerifyResult next_result = result->next;
|
||||
gpgme_data_release (result->notation);
|
||||
xfree (result);
|
||||
free (result);
|
||||
result = next_result;
|
||||
}
|
||||
}
|
||||
@ -185,7 +185,7 @@ finish_sig (GpgmeCtx ctx, int stop)
|
||||
|
||||
ctx->result.verify->collecting = 0;
|
||||
/* Create a new result structure. */
|
||||
res2 = xtrycalloc (1, sizeof *res2);
|
||||
res2 = calloc (1, sizeof *res2);
|
||||
if (!res2)
|
||||
{
|
||||
ctx->error = mk_error (Out_Of_Core);
|
||||
|
@ -166,7 +166,7 @@ gpgme_get_engine_info ()
|
||||
"%s"
|
||||
"</EngineInfo>\n";
|
||||
|
||||
info = xtrymalloc (strlen (fmt)
|
||||
info = malloc (strlen (fmt)
|
||||
+ strlen (openpgp_info
|
||||
? openpgp_info : cms_info) + 1);
|
||||
if (info)
|
||||
@ -177,7 +177,7 @@ gpgme_get_engine_info ()
|
||||
const char *fmt = "<EngineInfo>\n"
|
||||
"%s%s"
|
||||
"</EngineInfo>\n";
|
||||
info = xtrymalloc (strlen (fmt) + strlen (openpgp_info)
|
||||
info = malloc (strlen (fmt) + strlen (openpgp_info)
|
||||
+ strlen (cms_info) + 1);
|
||||
if (info)
|
||||
sprintf (info, fmt, openpgp_info, cms_info);
|
||||
@ -251,7 +251,7 @@ _gpgme_get_program_version (const char *const path)
|
||||
mark = strrchr (line, ' ');
|
||||
if (!mark)
|
||||
return NULL;
|
||||
return xtrystrdup (mark + 1);
|
||||
return strdup (mark + 1);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
@ -226,7 +226,7 @@ create_reader (HANDLE fd)
|
||||
sec_attr.nLength = sizeof sec_attr;
|
||||
sec_attr.bInheritHandle = FALSE;
|
||||
|
||||
c = xtrycalloc (1, sizeof *c );
|
||||
c = calloc (1, sizeof *c );
|
||||
if (!c)
|
||||
return NULL;
|
||||
|
||||
@ -242,7 +242,7 @@ create_reader (HANDLE fd)
|
||||
CloseHandle (c->have_space_ev);
|
||||
if (c->stopped)
|
||||
CloseHandle (c->stopped);
|
||||
xfree (c);
|
||||
free (c);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -260,7 +260,7 @@ create_reader (HANDLE fd)
|
||||
CloseHandle (c->have_space_ev);
|
||||
if (c->stopped)
|
||||
CloseHandle (c->stopped);
|
||||
xfree (c);
|
||||
free (c);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -288,7 +288,7 @@ destroy_reader (struct reader_context_s *c)
|
||||
CloseHandle (c->have_space_ev);
|
||||
CloseHandle (c->thread_hd);
|
||||
DESTROY_LOCK (c->mutex);
|
||||
xfree (c);
|
||||
free (c);
|
||||
}
|
||||
|
||||
|
||||
@ -479,7 +479,7 @@ create_writer (HANDLE fd)
|
||||
sec_attr.nLength = sizeof sec_attr;
|
||||
sec_attr.bInheritHandle = FALSE;
|
||||
|
||||
c = xtrycalloc (1, sizeof *c );
|
||||
c = calloc (1, sizeof *c );
|
||||
if (!c)
|
||||
return NULL;
|
||||
|
||||
@ -495,7 +495,7 @@ create_writer (HANDLE fd)
|
||||
CloseHandle (c->is_empty);
|
||||
if (c->stopped)
|
||||
CloseHandle (c->stopped);
|
||||
xfree (c);
|
||||
free (c);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -513,7 +513,7 @@ create_writer (HANDLE fd)
|
||||
CloseHandle (c->is_empty);
|
||||
if (c->stopped)
|
||||
CloseHandle (c->stopped);
|
||||
xfree (c);
|
||||
free (c);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -541,7 +541,7 @@ destroy_writer (struct writer_context_s *c)
|
||||
CloseHandle (c->is_empty);
|
||||
CloseHandle (c->thread_hd);
|
||||
DESTROY_LOCK (c->mutex);
|
||||
xfree (c);
|
||||
free (c);
|
||||
}
|
||||
|
||||
|
||||
@ -771,7 +771,7 @@ build_commandline ( char **argv )
|
||||
* program parses the commandline and does some unquoting */
|
||||
for (i=0; argv[i]; i++)
|
||||
n += strlen (argv[i]) + 2 + 1; /* 2 extra bytes for possible quoting */
|
||||
buf = p = xtrymalloc (n);
|
||||
buf = p = malloc (n);
|
||||
if ( !buf )
|
||||
return NULL;
|
||||
*buf = 0;
|
||||
@ -859,7 +859,7 @@ _gpgme_io_spawn ( const char *path, char **argv,
|
||||
NULL );
|
||||
if ( hnul == INVALID_HANDLE_VALUE ) {
|
||||
DEBUG1 ("can't open `nul': ec=%d\n", (int)GetLastError ());
|
||||
xfree (arg_string);
|
||||
free (arg_string);
|
||||
return -1;
|
||||
}
|
||||
/* Make sure that the process has a connected stdin */
|
||||
@ -888,7 +888,7 @@ _gpgme_io_spawn ( const char *path, char **argv,
|
||||
&pi /* returns process information */
|
||||
) ) {
|
||||
DEBUG1 ("CreateProcess failed: ec=%d\n", (int) GetLastError ());
|
||||
xfree (arg_string);
|
||||
free (arg_string);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ critsect_init (struct critsect_s *s)
|
||||
return;
|
||||
}
|
||||
/* now init it */
|
||||
mp = xtrymalloc ( sizeof *mp );
|
||||
mp = malloc ( sizeof *mp );
|
||||
if (!mp) {
|
||||
LeaveCriticalSection (&init_lock);
|
||||
sema_fatal ("out of core while creating critical section lock");
|
||||
@ -108,7 +108,7 @@ _gpgme_sema_cs_destroy ( struct critsect_s *s )
|
||||
{
|
||||
if (s && s->private) {
|
||||
DeleteCriticalSection ((CRITICAL_SECTION*)s->private);
|
||||
xfree (s->private);
|
||||
free (s->private);
|
||||
s->private = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -73,12 +73,12 @@ read_w32_registry_string (const char *root, const char *dir, const char *name)
|
||||
if (RegQueryValueEx (key_handle, name, 0, NULL, NULL, &nbytes))
|
||||
goto leave;
|
||||
n1 = nbytes + 1;
|
||||
result = xtrymalloc (n1);
|
||||
result = malloc (n1);
|
||||
if (!result)
|
||||
goto leave;
|
||||
if (RegQueryValueEx (key_handle, name, 0, NULL, result, &n1))
|
||||
{
|
||||
xfree(result);
|
||||
free (result);
|
||||
result = NULL;
|
||||
goto leave;
|
||||
}
|
||||
|
20
gpgme/wait.c
20
gpgme/wait.c
@ -66,7 +66,7 @@ _gpgme_fd_table_deinit (fd_table_t fdt)
|
||||
{
|
||||
DESTROY_LOCK (fdt->lock);
|
||||
if (fdt->fds)
|
||||
xfree (fdt->fds);
|
||||
free (fdt->fds);
|
||||
}
|
||||
|
||||
/* XXX We should keep a marker and roll over for speed. */
|
||||
@ -85,7 +85,7 @@ _gpgme_fd_table_put (fd_table_t fdt, int fd, int dir, void *opaque, int *idx)
|
||||
if (i == fdt->size)
|
||||
{
|
||||
#define FDT_ALLOCSIZE 10
|
||||
new_fds = xtryrealloc (fdt->fds, (fdt->size + FDT_ALLOCSIZE)
|
||||
new_fds = realloc (fdt->fds, (fdt->size + FDT_ALLOCSIZE)
|
||||
* sizeof (*new_fds));
|
||||
if (!new_fds)
|
||||
{
|
||||
@ -187,7 +187,7 @@ _gpgme_wait_event_cb (void *data, GpgmeEventIO type, void *type_data)
|
||||
#define CTX_DONE_LIST_SIZE_INITIAL 8
|
||||
int new_size = ctx_done_list_size ? 2 * ctx_done_list_size
|
||||
: CTX_DONE_LIST_SIZE_INITIAL;
|
||||
GpgmeCtx *new_list = xtryrealloc (ctx_done_list,
|
||||
GpgmeCtx *new_list = realloc (ctx_done_list,
|
||||
new_size * sizeof (GpgmeCtx *));
|
||||
assert (new_list);
|
||||
#if 0
|
||||
@ -335,16 +335,16 @@ _gpgme_add_io_cb (void *data, int fd, int dir,
|
||||
assert (fnc);
|
||||
|
||||
*r_tag = NULL;
|
||||
tag = xtrymalloc (sizeof *tag);
|
||||
tag = malloc (sizeof *tag);
|
||||
if (!tag)
|
||||
return mk_error (Out_Of_Core);
|
||||
tag->fdt = fdt;
|
||||
|
||||
/* Allocate a structure to hold info about the handler. */
|
||||
item = xtrycalloc (1, sizeof *item);
|
||||
item = calloc (1, sizeof *item);
|
||||
if (!item)
|
||||
{
|
||||
xfree (tag);
|
||||
free (tag);
|
||||
return mk_error (Out_Of_Core);
|
||||
}
|
||||
item->dir = dir;
|
||||
@ -354,8 +354,8 @@ _gpgme_add_io_cb (void *data, int fd, int dir,
|
||||
err = _gpgme_fd_table_put (fdt, fd, dir, item, &tag->idx);
|
||||
if (err)
|
||||
{
|
||||
xfree (tag);
|
||||
xfree (item);
|
||||
free (tag);
|
||||
free (item);
|
||||
return mk_error (Out_Of_Core);
|
||||
}
|
||||
|
||||
@ -373,8 +373,8 @@ _gpgme_remove_io_cb (void *data)
|
||||
LOCK (fdt->lock);
|
||||
DEBUG2 ("setting fd %d (item=%p) done", fdt->fds[idx].fd,
|
||||
fdt->fds[idx].opaque);
|
||||
xfree (fdt->fds[idx].opaque);
|
||||
xfree (tag);
|
||||
free (fdt->fds[idx].opaque);
|
||||
free (tag);
|
||||
|
||||
/* Free the table entry. */
|
||||
fdt->fds[idx].fd = -1;
|
||||
|
Loading…
Reference in New Issue
Block a user