diff options
author | Werner Koch <[email protected]> | 2005-04-05 17:09:13 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2005-04-05 17:09:13 +0000 |
commit | 80f4424658f055e9738dcfca1ef1a5bd27797189 (patch) | |
tree | 77f5fe724d2ff69b5b549ffe0b836a38e97ad8cf /util/memory.c | |
parent | * mainproc.c (proc_plaintext): Properly handle SIG+LITERAL (old-style PGP) (diff) | |
download | gnupg-80f4424658f055e9738dcfca1ef1a5bd27797189.tar.gz gnupg-80f4424658f055e9738dcfca1ef1a5bd27797189.zip |
Changes to make use of code taken from libassuan. This replaces the
old ad-hoc connection code to gpg-agent. We do need this for the
forthcoming diversion of card code to an already running gpg-agent
with card-support.
Diffstat (limited to '')
-rw-r--r-- | util/memory.c | 53 |
1 files changed, 29 insertions, 24 deletions
diff --git a/util/memory.c b/util/memory.c index c062bdd5f..f84e507dc 100644 --- a/util/memory.c +++ b/util/memory.c @@ -1,5 +1,5 @@ /* memory.c - memory allocation - * Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc. + * Copyright (C) 1998, 1999, 2001, 2005 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -603,29 +603,6 @@ m_size( const void *a ) } -#if 0 /* not used */ -/**************** - * Make a copy of the memory block at a - */ -void * -FNAME(copy)( const void *a FNAMEPRT ) -{ - void *b; - size_t n; - - if( !a ) - return NULL; - - n = m_size(a); Aiiiih woher nehmen - if( m_is_secure(a) ) - b = FNAME(alloc_secure)(n FNAMEARG); - else - b = FNAME(alloc)(n FNAMEARG); - memcpy(b, a, n ); - return b; -} -#endif - char * FNAME(strdup)( const char *a FNAMEPRT ) { @@ -634,3 +611,31 @@ FNAME(strdup)( const char *a FNAMEPRT ) strcpy(p, a); return p; } + + +/* Wrapper around m_alloc_clear to take the usual 2 arguments of a + calloc style function. */ +void * +xcalloc (size_t n, size_t m) +{ + size_t nbytes; + + nbytes = n * m; + if (m && nbytes / m != n) + out_of_core (nbytes, 0); + return m_alloc_clear (nbytes); +} + +/* Wrapper around m_alloc_csecure_lear to take the usual 2 arguments + of a calloc style function. */ +void * +xcalloc_secure (size_t n, size_t m) +{ + size_t nbytes; + + nbytes = n * m; + if (m && nbytes / m != n) + out_of_core (nbytes, 1); + return m_alloc_secure_clear (nbytes); +} + |