+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:
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 \
/* 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);
int val;
GpgmeError err;
- buf = xtrymalloc (strlen (str));
+ buf = malloc (strlen (str));
dst = buf;
for (src = str; *src; src++)
{
}
err = _gpgme_data_append_for_xml (dh, buf, dst - buf);
- xfree (buf);
+ free (buf);
return err;
}
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);
_gpgme_data_release (GpgmeData dh)
{
if (dh)
- xfree (dh);
+ free (dh);
}
\f
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);
setvbuf (fp, NULL, _IOLBF, 0);
errfp = fp;
}
- xfree (p);
+ free (p);
}
#ifndef HAVE_DOSISH_SYSTEM
}
{
if (!result)
return;
- xfree (result);
+ free (result);
}
/* Check whether STRING starts with TOKEN and return true in this
{
if (!result)
return;
- xfree (result);
+ free (result);
}
{
if (!result)
return;
- xfree (result);
+ free (result);
}
void
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);
if (!result)
return;
gpgme_data_release (result->xmlinfo);
- xfree (result);
+ free (result);
}
/*
int nfds;
*r_gpgsm = NULL;
- gpgsm = xtrycalloc (1, sizeof *gpgsm);
+ gpgsm = calloc (1, sizeof *gpgsm);
if (!gpgsm)
{
err = mk_error (Out_Of_Core);
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. */
if (!gpgsm)
return mk_error (Invalid_Value);
- gpgsm->command = xtrystrdup ("DECRYPT");
+ gpgsm->command = strdup ("DECRYPT");
if (!gpgsm->command)
return mk_error (Out_Of_Core);
}
length++;
- line = xtrymalloc (length);
+ line = malloc (length);
if (!line)
return mk_error (Out_Of_Core);
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 ");
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;
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;
if (!recp)
return mk_error (Not_Implemented);
- gpgsm->command = xtrystrdup ("ENCRYPT");
+ gpgsm->command = strdup ("ENCRYPT");
if (!gpgsm->command)
return mk_error (Out_Of_Core);
/* 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;
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);
if (!gpgsm)
return mk_error (Invalid_Value);
- gpgsm->command = xtrystrdup ("IMPORT");
+ gpgsm->command = strdup ("IMPORT");
if (!gpgsm->command)
return mk_error (Out_Of_Core);
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)
length++;
}
}
- line = xtrymalloc (length);
+ line = malloc (length);
if (!line)
return mk_error (Out_Of_Core);
if (secret_only)
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);
if (!gpgsm)
return mk_error (Invalid_Value);
- gpgsm->command = xtrystrdup ("VERIFY");
+ gpgsm->command = strdup ("VERIFY");
if (!gpgsm->command)
return mk_error (Out_Of_Core);
if (gpgsm->colon.attic.linesize
< *alinelen + linelen + 1)
{
- unsigned char *newline = xtryrealloc (*aline,
+ unsigned char *newline = realloc (*aline,
*alinelen + linelen + 1);
if (!newline)
{
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"
EngineObject engine;
GpgmeError err = 0;
- engine = xtrycalloc (1, sizeof *engine);
+ engine = calloc (1, sizeof *engine);
if (!engine)
{
err = mk_error (Out_Of_Core);
default:
break;
}
- xfree (engine);
+ free (engine);
}
{
if (!result)
return;
- xfree (result);
+ free (result);
}
static void
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;
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
if (!result)
return;
gpgme_data_release (result->xmlinfo);
- xfree (result);
+ free (result);
}
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;
}
else
{
- item = xtrymalloc (sizeof *item);
+ item = malloc (sizeof *item);
if (!item)
{
UNLOCK (key_cache_lock);
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;
{
struct subkey_s *k, *kk;
- k = xtrycalloc (1, sizeof *k);
+ k = calloc (1, sizeof *k);
if (!k)
return NULL;
}
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)
{
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);
}
/**
/* 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);
{
if (!result)
return;
- xfree (result);
+ free (result);
}
/* Append some XML info. args is currently ignore but we might want
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);
}
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);
}
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);
}
_gpgme_key_cache_add (key);
- q = xtrymalloc (sizeof *q);
+ q = malloc (sizeof *q);
if (!q)
{
gpgme_key_release (key);
ctx->key_cond = 0;
*r_key = queue_item->key;
- xfree (queue_item);
+ free (queue_item);
return 0;
}
{ \
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); \
{
if (!result)
return;
- xfree (result->passphrase_info);
- xfree (result->userid_hint);
- xfree (result);
+ free (result->passphrase_info);
+ free (result->userid_hint);
+ free (result);
}
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;
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;
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);
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)
{
s = ctx->passphrase_cb (ctx->passphrase_cb_value,
buf, &ctx->result.passphrase->last_pw_handle);
- xfree (buf);
+ free (buf);
return s;
}
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);
if (type != 'X')
ctx->progress_cb (ctx->progress_cb_value, args_cpy, type, current, total);
- xfree (args_cpy);
+ free (args_cpy);
}
{
GpgmeRecipients rset;
- rset = xtrycalloc ( 1, sizeof *rset );
+ rset = calloc ( 1, sizeof *rset );
if (!rset)
return mk_error (Out_Of_Core);
*r_rset = rset;
for (u = rset->list; u; u = u2) {
u2 = u->next;
- xfree(u);
+ free(u);
}
}
- xfree ( rset );
+ free ( 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;
GpgObject gpg;
int rc = 0;
- gpg = xtrycalloc (1, sizeof *gpg);
+ gpg = calloc (1, sizeof *gpg);
if (!gpg)
{
rc = mk_error (Out_Of_Core);
/* 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);
{
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]);
free_fd_data_map (gpg->fd_data_map);
if (gpg->cmd.fd != -1)
_gpgme_io_close (gpg->cmd.fd);
- xfree (gpg);
+ free (gpg);
}
void
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);
if (gpg->pm.active)
return 0;
- a = xtrymalloc (sizeof *a - 1);
+ a = malloc (sizeof *a - 1);
if (!a)
{
gpg->arg_error = 1;
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],
int i;
for (i=0; argv[i]; i++ )
- xfree (argv[i]);
- xfree (argv);
+ free (argv[i]);
+ free (argv);
}
static void
_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);
}
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);
}
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);
}
}
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);
}
}
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);
}
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);
}
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);
}
}
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);
}
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;
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);
{
/* Need more room for the read. */
bufsize += 1024;
- buffer = xtryrealloc (buffer, bufsize);
+ buffer = realloc (buffer, bufsize);
if (!buffer)
return mk_error (Out_Of_Core);
}
|| 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
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);
}
if (!result)
return;
gpgme_data_release (result->xmlinfo);
- xfree (result);
+ free (result);
}
/* Parse the args and save the information
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++)
{
GpgmeTrustItem item;
- item = xtrycalloc (1, sizeof *item);
+ item = calloc (1, sizeof *item);
return item;
}
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;
assert (type == GPGME_EVENT_NEXT_KEY);
- q = xtrymalloc (sizeof *q);
+ q = malloc (sizeof *q);
if (!q)
{
gpgme_trust_item_release (item);
ctx->trust_queue = q->next;
*r_item = q->item;
- xfree (q);
+ free (q);
return 0;
}
{
if (!item)
return;
- xfree (item->name);
- xfree (item);
+ free (item->name);
+ free (item);
}
+++ /dev/null
-/* 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);
-}
-
-
-
-
-
-
#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]))
{
VerifyResult next_result = result->next;
gpgme_data_release (result->notation);
- xfree (result);
+ free (result);
result = next_result;
}
}
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);
"%s"
"</EngineInfo>\n";
- info = xtrymalloc (strlen (fmt)
+ info = malloc (strlen (fmt)
+ strlen (openpgp_info
? openpgp_info : cms_info) + 1);
if (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);
mark = strrchr (line, ' ');
if (!mark)
return NULL;
- return xtrystrdup (mark + 1);
+ return strdup (mark + 1);
}
return NULL;
sec_attr.nLength = sizeof sec_attr;
sec_attr.bInheritHandle = FALSE;
- c = xtrycalloc (1, sizeof *c );
+ c = calloc (1, sizeof *c );
if (!c)
return NULL;
CloseHandle (c->have_space_ev);
if (c->stopped)
CloseHandle (c->stopped);
- xfree (c);
+ free (c);
return NULL;
}
CloseHandle (c->have_space_ev);
if (c->stopped)
CloseHandle (c->stopped);
- xfree (c);
+ free (c);
return NULL;
}
CloseHandle (c->have_space_ev);
CloseHandle (c->thread_hd);
DESTROY_LOCK (c->mutex);
- xfree (c);
+ free (c);
}
sec_attr.nLength = sizeof sec_attr;
sec_attr.bInheritHandle = FALSE;
- c = xtrycalloc (1, sizeof *c );
+ c = calloc (1, sizeof *c );
if (!c)
return NULL;
CloseHandle (c->is_empty);
if (c->stopped)
CloseHandle (c->stopped);
- xfree (c);
+ free (c);
return NULL;
}
CloseHandle (c->is_empty);
if (c->stopped)
CloseHandle (c->stopped);
- xfree (c);
+ free (c);
return NULL;
}
CloseHandle (c->is_empty);
CloseHandle (c->thread_hd);
DESTROY_LOCK (c->mutex);
- xfree (c);
+ free (c);
}
* 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;
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 */
&pi /* returns process information */
) ) {
DEBUG1 ("CreateProcess failed: ec=%d\n", (int) GetLastError ());
- xfree (arg_string);
+ free (arg_string);
return -1;
}
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");
{
if (s && s->private) {
DeleteCriticalSection ((CRITICAL_SECTION*)s->private);
- xfree (s->private);
+ free (s->private);
s->private = NULL;
}
}
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;
}
{
DESTROY_LOCK (fdt->lock);
if (fdt->fds)
- xfree (fdt->fds);
+ free (fdt->fds);
}
/* XXX We should keep a marker and roll over for speed. */
if (i == fdt->size)
{
#define FDT_ALLOCSIZE 10
- new_fds = xtryrealloc (fdt->fds, (fdt->size + FDT_ALLOCSIZE)
- * sizeof (*new_fds));
+ new_fds = realloc (fdt->fds, (fdt->size + FDT_ALLOCSIZE)
+ * sizeof (*new_fds));
if (!new_fds)
{
UNLOCK (fdt->lock);
#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,
- new_size * sizeof (GpgmeCtx *));
+ GpgmeCtx *new_list = realloc (ctx_done_list,
+ new_size * sizeof (GpgmeCtx *));
assert (new_list);
#if 0
if (!new_list)
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;
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);
}
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;