[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r35539 - in gnunet/src: include util
From: |
gnunet |
Subject: |
[GNUnet-SVN] r35539 - in gnunet/src: include util |
Date: |
Sat, 18 Apr 2015 00:57:40 +0200 |
Author: grothoff
Date: 2015-04-18 00:57:40 +0200 (Sat, 18 Apr 2015)
New Revision: 35539
Modified:
gnunet/src/include/gnunet_crypto_lib.h
gnunet/src/util/common_allocation.c
Log:
-doxygen, indentation
Modified: gnunet/src/include/gnunet_crypto_lib.h
===================================================================
--- gnunet/src/include/gnunet_crypto_lib.h 2015-04-17 15:56:47 UTC (rev
35538)
+++ gnunet/src/include/gnunet_crypto_lib.h 2015-04-17 22:57:40 UTC (rev
35539)
@@ -1582,7 +1582,7 @@
*/
size_t
GNUNET_CRYPTO_rsa_private_key_encode (const struct
GNUNET_CRYPTO_rsa_PrivateKey *key,
- char **buffer);
+ char **buffer);
/**
@@ -1595,7 +1595,7 @@
*/
struct GNUNET_CRYPTO_rsa_PrivateKey *
GNUNET_CRYPTO_rsa_private_key_decode (const char *buf,
- size_t len);
+ size_t len);
/**
@@ -1638,7 +1638,7 @@
*/
size_t
GNUNET_CRYPTO_rsa_public_key_encode (const struct GNUNET_CRYPTO_rsa_PublicKey
*key,
- char **buffer);
+ char **buffer);
/**
@@ -1651,7 +1651,7 @@
*/
struct GNUNET_CRYPTO_rsa_PublicKey *
GNUNET_CRYPTO_rsa_public_key_decode (const char *buf,
- size_t len);
+ size_t len);
/**
@@ -1759,7 +1759,7 @@
*/
size_t
GNUNET_CRYPTO_rsa_signature_encode (const struct GNUNET_CRYPTO_rsa_Signature
*sig,
- char **buffer);
+ char **buffer);
/**
@@ -1772,7 +1772,7 @@
*/
struct GNUNET_CRYPTO_rsa_Signature *
GNUNET_CRYPTO_rsa_signature_decode (const char *buf,
- size_t len);
+ size_t len);
/**
@@ -1787,8 +1787,8 @@
*/
struct GNUNET_CRYPTO_rsa_Signature *
GNUNET_CRYPTO_rsa_unblind (struct GNUNET_CRYPTO_rsa_Signature *sig,
- struct GNUNET_CRYPTO_rsa_BlindingKey *bkey,
- struct GNUNET_CRYPTO_rsa_PublicKey *pkey);
+ struct GNUNET_CRYPTO_rsa_BlindingKey *bkey,
+ struct GNUNET_CRYPTO_rsa_PublicKey *pkey);
/**
Modified: gnunet/src/util/common_allocation.c
===================================================================
--- gnunet/src/util/common_allocation.c 2015-04-17 15:56:47 UTC (rev 35538)
+++ gnunet/src/util/common_allocation.c 2015-04-17 22:57:40 UTC (rev 35539)
@@ -53,25 +53,32 @@
* memory is available.
*
* @param size how many bytes of memory to allocate, do NOT use
- * this function (or GNUNET_malloc) to allocate more than several MB
+ * this function (or GNUNET_malloc()) to allocate more than several MB
* of memory, if you are possibly needing a very large chunk use
- * GNUNET_xmalloc_unchecked_ instead.
- * @param filename where in the code was the call to GNUNET_malloc
- * @param linenumber where in the code was the call to GNUNET_malloc
+ * #GNUNET_xmalloc_unchecked_() instead.
+ * @param filename where in the code was the call to GNUNET_malloc()
+ * @param linenumber where in the code was the call to GNUNET_malloc()
* @return pointer to size bytes of memory
*/
void *
-GNUNET_xmalloc_ (size_t size, const char *filename, int linenumber)
+GNUNET_xmalloc_ (size_t size,
+ const char *filename,
+ int linenumber)
{
void *ret;
/* As a security precaution, we generally do not allow very large
- * allocations using the default 'GNUNET_malloc' macro */
- GNUNET_assert_at (size <= GNUNET_MAX_MALLOC_CHECKED, filename, linenumber);
- ret = GNUNET_xmalloc_unchecked_ (size, filename, linenumber);
- if (ret == NULL)
+ * allocations using the default 'GNUNET_malloc()' macro */
+ GNUNET_assert_at (size <= GNUNET_MAX_MALLOC_CHECKED,
+ filename,
+ linenumber);
+ ret = GNUNET_xmalloc_unchecked_ (size,
+ filename,
+ linenumber);
+ if (NULL == ret)
{
- LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "malloc");
+ LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR,
+ "malloc");
GNUNET_assert (0);
}
return ret;
@@ -80,8 +87,8 @@
/**
* Allocate and initialize memory. Checks the return value, aborts if no more
- * memory is available. Don't use GNUNET_xmemdup_ directly. Use the
- * GNUNET_memdup macro.
+ * memory is available. Don't use #GNUNET_xmemdup_() directly. Use the
+ * GNUNET_memdup() macro.
*
* @param buf buffer to initialize from (must contain size bytes)
* @param size number of bytes to allocate
@@ -90,7 +97,9 @@
* @return allocated memory, never NULL
*/
void *
-GNUNET_xmemdup_ (const void *buf, size_t size, const char *filename,
+GNUNET_xmemdup_ (const void *buf,
+ size_t size,
+ const char *filename,
int linenumber)
{
void *ret;
@@ -120,18 +129,19 @@
}
-
/**
- * Wrapper around malloc. Allocates size bytes of memory.
+ * Wrapper around malloc(). Allocates size bytes of memory.
* The memory will be zero'ed out.
*
* @param size the number of bytes to allocate
- * @param filename where in the code was the call to GNUNET_malloc_large
- * @param linenumber where in the code was the call to GNUNET_malloc_large
+ * @param filename where in the code was the call to GNUNET_malloc_unchecked()
+ * @param linenumber where in the code was the call to
GNUNET_malloc_unchecked()
* @return pointer to size bytes of memory, NULL if we do not have enough
memory
*/
void *
-GNUNET_xmalloc_unchecked_ (size_t size, const char *filename, int linenumber)
+GNUNET_xmalloc_unchecked_ (size_t size,
+ const char *filename,
+ int linenumber)
{
void *result;
@@ -142,7 +152,7 @@
#endif
result = malloc (size);
- if (result == NULL)
+ if (NULL == result)
return NULL;
memset (result, 0, size);
@@ -162,12 +172,15 @@
*
* @param ptr the pointer to reallocate
* @param n how many bytes of memory to allocate
- * @param filename where in the code was the call to GNUNET_realloc
- * @param linenumber where in the code was the call to GNUNET_realloc
+ * @param filename where in the code was the call to GNUNET_realloc()
+ * @param linenumber where in the code was the call to GNUNET_realloc()
* @return pointer to size bytes of memory
*/
void *
-GNUNET_xrealloc_ (void *ptr, size_t n, const char *filename, int linenumber)
+GNUNET_xrealloc_ (void *ptr,
+ size_t n,
+ const char *filename,
+ int linenumber)
{
#ifdef W32_MEM_LIMIT
n += sizeof (size_t);
@@ -215,9 +228,13 @@
* @param linenumber where in the code was the call to GNUNET_array_grow
*/
void
-GNUNET_xfree_ (void *ptr, const char *filename, int linenumber)
+GNUNET_xfree_ (void *ptr,
+ const char *filename,
+ int linenumber)
{
- GNUNET_assert_at (ptr != NULL, filename, linenumber);
+ GNUNET_assert_at (NULL != ptr,
+ filename,
+ linenumber);
#ifdef W32_MEM_LIMIT
ptr = &((size_t *) ptr)[-1];
mem_used -= *((size_t *) ptr);
@@ -239,22 +256,33 @@
free (ptr);
}
+
/**
* Dup a string (same semantics as strdup).
*
* @param str the string to dup
- * @param filename where in the code was the call to GNUNET_strdup
- * @param linenumber where in the code was the call to GNUNET_strdup
- * @return strdup(str)
+ * @param filename where in the code was the call to GNUNET_strdup()
+ * @param linenumber where in the code was the call to GNUNET_strdup()
+ * @return `strdup(@a str)`
*/
char *
-GNUNET_xstrdup_ (const char *str, const char *filename, int linenumber)
+GNUNET_xstrdup_ (const char *str,
+ const char *filename,
+ int linenumber)
{
char *res;
+ size_t slen;
- GNUNET_assert_at (str != NULL, filename, linenumber);
- res = GNUNET_xmalloc_ (strlen (str) + 1, filename, linenumber);
- memcpy (res, str, strlen (str) + 1);
+ GNUNET_assert_at (str != NULL,
+ filename,
+ linenumber);
+ slen = strlen (str) + 1;
+ res = GNUNET_xmalloc_ (slen,
+ filename,
+ linenumber);
+ memcpy (res,
+ str,
+ slen);
return res;
}
@@ -279,21 +307,28 @@
*
* @param str the string to dup
* @param len the length of the string to dup
- * @param filename where in the code was the call to GNUNET_strndup
- * @param linenumber where in the code was the call to GNUNET_strndup
- * @return strndup(str,len)
+ * @param filename where in the code was the call to GNUNET_strndup()
+ * @param linenumber where in the code was the call to GNUNET_strndup()
+ * @return `strndup(@a str,@a len)`
*/
char *
-GNUNET_xstrndup_ (const char *str, size_t len, const char *filename,
+GNUNET_xstrndup_ (const char *str,
+ size_t len,
+ const char *filename,
int linenumber)
{
char *res;
if (0 == len)
return GNUNET_strdup ("");
- GNUNET_assert_at (str != NULL, filename, linenumber);
- len = strnlen (str, len);
- res = GNUNET_xmalloc_ (len + 1, filename, linenumber);
+ GNUNET_assert_at (NULL != str,
+ filename,
+ linenumber);
+ len = strnlen (str,
+ len);
+ res = GNUNET_xmalloc_ (len + 1,
+ filename,
+ linenumber);
memcpy (res, str, len);
/* res[len] = '\0'; 'malloc' zeros out anyway */
return res;
@@ -309,12 +344,16 @@
* @param elementSize the size of the elements of the array
* @param oldCount address of the number of elements in the *old array
* @param newCount number of elements in the new array, may be 0
- * @param filename where in the code was the call to GNUNET_array_grow
- * @param linenumber where in the code was the call to GNUNET_array_grow
+ * @param filename where in the code was the call to GNUNET_array_grow()
+ * @param linenumber where in the code was the call to GNUNET_array_grow()
*/
void
-GNUNET_xgrow_ (void **old, size_t elementSize, unsigned int *oldCount,
- unsigned int newCount, const char *filename, int linenumber)
+GNUNET_xgrow_ (void **old,
+ size_t elementSize,
+ unsigned int *oldCount,
+ unsigned int newCount,
+ const char *filename,
+ int linenumber)
{
void *tmp;
size_t size;
@@ -344,15 +383,17 @@
/**
- * Like asprintf, just portable.
+ * Like asprintf(), just portable.
*
* @param buf set to a buffer of sufficient size (allocated, caller must free)
- * @param format format string (see printf, fprintf, etc.)
+ * @param format format string (see printf(), fprintf(), etc.)
* @param ... data for format string
- * @return number of bytes in "*buf" excluding 0-termination
+ * @return number of bytes in address@hidden buf`, excluding 0-termination
*/
int
-GNUNET_asprintf (char **buf, const char *format, ...)
+GNUNET_asprintf (char **buf,
+ const char *format,
+ ...)
{
int ret;
va_list args;
@@ -369,7 +410,7 @@
/**
- * Like snprintf, just aborts if the buffer is of insufficient size.
+ * Like snprintf(), just aborts if the buffer is of insufficient size.
*
* @param buf pointer to buffer that is written to
* @param size number of bytes in buf
@@ -378,7 +419,9 @@
* @return number of bytes written to buf or negative value on error
*/
int
-GNUNET_snprintf (char *buf, size_t size, const char *format, ...)
+GNUNET_snprintf (char *buf,
+ size_t size,
+ const char *format, ...)
{
int ret;
va_list args;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r35539 - in gnunet/src: include util,
gnunet <=