This file is part of GNUnet.
Copyright (C) 2001, 2002, 2003, 2005, 2006 GNUnet e.V.
- GNUnet 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 3, or (at your
- option) any later version.
+ GNUnet is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License,
+ or (at your option) any later version.
GNUnet 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.
+ Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
- You should have received a copy of the GNU General Public License
- along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
+ SPDX-License-Identifier: AGPL3.0-or-later
*/
/**
#include <malloc/malloc.h>
#endif
-#define LOG(kind,...) GNUNET_log_from (kind, "util",__VA_ARGS__)
+#define LOG(kind,...) GNUNET_log_from (kind, "util-common-allocation",__VA_ARGS__)
-#define LOG_STRERROR(kind,syscall) GNUNET_log_from_strerror (kind, "util", syscall)
+#define LOG_STRERROR(kind,syscall) GNUNET_log_from_strerror (kind, "util-common-allocation", syscall)
#ifndef INT_MAX
#define INT_MAX 0x7FFFFFFF
* @return allocated memory, never NULL
*/
void **
-GNUNET_xnew_array_2d_ (size_t n, size_t m, size_t elementSize,
- const char *filename, int linenumber)
+GNUNET_xnew_array_2d_ (size_t n,
+ size_t m,
+ size_t elementSize,
+ const char *filename,
+ int linenumber)
{
/* use char pointer internally to avoid void pointer arithmetic warnings */
char **ret = GNUNET_xmalloc_ (n * sizeof (void *) + /* 1. dim header */
{
void *result;
+ (void) filename;
+ (void) linenumber;
#ifdef W32_MEM_LIMIT
size += sizeof (size_t);
if (mem_used + size > W32_MEM_LIMIT)
const char *filename,
int linenumber)
{
+ (void) filename;
+ (void) linenumber;
+
#ifdef W32_MEM_LIMIT
n += sizeof (size_t);
ptr = &((size_t *) ptr)[-1];
ptr = realloc (ptr, n);
if ((NULL == ptr) && (n > 0))
{
- LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "realloc");
+ LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR,
+ "realloc");
GNUNET_assert (0);
}
#ifdef W32_MEM_LIMIT
*/
int
GNUNET_asprintf (char **buf,
- const char *format,
- ...)
+ const char *format,
+ ...)
{
int ret;
va_list args;
va_start (args, format);
ret = VSNPRINTF (NULL, 0, format, args);
va_end (args);
+ GNUNET_assert (ret >= 0);
*buf = GNUNET_malloc (ret + 1);
va_start (args, format);
ret = VSPRINTF (*buf, format, args);
va_list args;
va_start (args, format);
- ret = VSNPRINTF (buf, size, format, args);
+ ret = VSNPRINTF (buf,
+ size,
+ format,
+ args);
va_end (args);
- GNUNET_assert (ret < size);
+ GNUNET_assert ( (ret >= 0) &&
+ (((size_t) ret) < size) );
return ret;
}
msize = ntohs (msg->size);
GNUNET_assert (msize >= sizeof (struct GNUNET_MessageHeader));
ret = GNUNET_malloc (msize);
- GNUNET_memcpy (ret, msg, msize);
+ GNUNET_memcpy (ret,
+ msg,
+ msize);
return ret;
}