gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [libmicrohttpd] branch master updated (d4935945 -> 2abfb2cc


From: gnunet
Subject: [GNUnet-SVN] [libmicrohttpd] branch master updated (d4935945 -> 2abfb2cc)
Date: Wed, 12 Jun 2019 16:39:16 +0200

This is an automated email from the git hooks/post-receive script.

karlson2k pushed a change to branch master
in repository libmicrohttpd.

    from d4935945 daemon.c: minor marcos refactoring for clarity
     new 16c9a00c memorypool.c: added asserts
     new 2abfb2cc memorypool: refactored includes, moved out unrelated function

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/microhttpd/daemon.c     | 15 +++++++++++++++
 src/microhttpd/memorypool.c | 38 ++++++++++++++++++++++----------------
 src/microhttpd/memorypool.h |  7 +++++--
 3 files changed, 42 insertions(+), 18 deletions(-)

diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index 8ec310cc..2729bb21 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -234,6 +234,21 @@ MHD_default_logger_ (void *cls,
 }
 
 
+/**
+ * Free the memory given by @a ptr. Calls "free(ptr)".  This function
+ * should be used to free the username returned by
+ * #MHD_digest_auth_get_username().
+ * @note Since v0.9.56
+ *
+ * @param ptr pointer to free.
+ */
+_MHD_EXTERN void
+MHD_free (void *ptr)
+{
+  free (ptr);
+}
+
+
 /**
  * Trace up to and return master daemon. If the supplied daemon
  * is a master, then return the daemon itself.
diff --git a/src/microhttpd/memorypool.c b/src/microhttpd/memorypool.c
index bda45e1e..415b8aa5 100644
--- a/src/microhttpd/memorypool.c
+++ b/src/microhttpd/memorypool.c
@@ -1,6 +1,7 @@
 /*
      This file is part of libmicrohttpd
-     Copyright (C) 2007, 2009, 2010 Daniel Pittman and Christian Grothoff
+     Copyright (C) 2007--2019 Daniel Pittman, Christian Grothoff and
+     Karlson2k (Evgeny Grin)
 
      This library is free software; you can redistribute it and/or
      modify it under the terms of the GNU Lesser General Public
@@ -21,8 +22,11 @@
  * @file memorypool.c
  * @brief memory pool
  * @author Christian Grothoff
+ * @author Karlson2k (Evgeny Grin)
  */
 #include "memorypool.h"
+#include "internal.h"
+#include "mhd_assert.h"
 
 /* define MAP_ANONYMOUS for Mac OS X */
 #if defined(MAP_ANON) && !defined(MAP_ANONYMOUS)
@@ -77,21 +81,6 @@ struct MemoryPool
 };
 
 
-/**
- * Free the memory given by @a ptr. Calls "free(ptr)".  This function
- * should be used to free the username returned by
- * #MHD_digest_auth_get_username().
- * @note Since v0.9.56
- *
- * @param ptr pointer to free.
- */
-_MHD_EXTERN void
-MHD_free (void *ptr)
-{
-  free (ptr);
-}
-
-
 /**
  * Create a memory pool.
  *
@@ -158,6 +147,9 @@ MHD_pool_destroy (struct MemoryPool *pool)
 {
   if (NULL == pool)
     return;
+
+  mhd_assert (pool->end >= pool->pos);
+  mhd_assert (pool->size >= pool->end - pool->pos);
   if (MHD_NO == pool->is_mmap)
     free (pool->memory);
   else
@@ -184,6 +176,8 @@ MHD_pool_destroy (struct MemoryPool *pool)
 size_t
 MHD_pool_get_free (struct MemoryPool *pool)
 {
+  mhd_assert (pool->end >= pool->pos);
+  mhd_assert (pool->size >= pool->end - pool->pos);
   return (pool->end - pool->pos);
 }
 
@@ -207,6 +201,8 @@ MHD_pool_allocate (struct MemoryPool *pool,
   void *ret;
   size_t asize;
 
+  mhd_assert (pool->end >= pool->pos);
+  mhd_assert (pool->size >= pool->end - pool->pos);
   asize = ROUND_TO_ALIGN (size);
   if ( (0 == asize) && (0 != size) )
     return NULL; /* size too close to SIZE_MAX */
@@ -253,6 +249,11 @@ MHD_pool_reallocate (struct MemoryPool *pool,
   void *ret;
   size_t asize;
 
+  mhd_assert (pool->end >= pool->pos);
+  mhd_assert (pool->size >= pool->end - pool->pos);
+  mhd_assert (old != NULL || old_size == 0);
+  mhd_assert (old == NULL || pool->memory <= (char*)old);
+  mhd_assert (old == NULL || pool->memory + pool->size >= (char*)old + 
old_size);
   asize = ROUND_TO_ALIGN (new_size);
   if ( (0 == asize) &&
        (0 != new_size) )
@@ -316,6 +317,11 @@ MHD_pool_reset (struct MemoryPool *pool,
                size_t copy_bytes,
                 size_t new_size)
 {
+  mhd_assert (pool->end >= pool->pos);
+  mhd_assert (pool->size >= pool->end - pool->pos);
+  mhd_assert (keep != NULL || copy_bytes == 0);
+  mhd_assert (keep == NULL || pool->memory <= (char*)keep);
+  mhd_assert (keep == NULL || pool->memory + pool->size >= (char*)keep + 
copy_bytes);
   if ( (NULL != keep) &&
        (keep != pool->memory) )
     {
diff --git a/src/microhttpd/memorypool.h b/src/microhttpd/memorypool.h
index 36136af8..2863b2f3 100644
--- a/src/microhttpd/memorypool.h
+++ b/src/microhttpd/memorypool.h
@@ -1,6 +1,7 @@
 /*
      This file is part of libmicrohttpd
-     Copyright (C) 2007, 2009 Daniel Pittman and Christian Grothoff
+     Copyright (C) 2007--2019 Daniel Pittman, Christian Grothoff and
+     Karlson2k (Evgeny Grin)
 
      This library is free software; you can redistribute it and/or
      modify it under the terms of the GNU Lesser General Public
@@ -23,12 +24,14 @@
  *        for each connection and bounding memory use for each
  *        request
  * @author Christian Grothoff
+ * @author Karlson2k (Evgeny Grin)
  */
 
 #ifndef MEMORYPOOL_H
 #define MEMORYPOOL_H
 
-#include "internal.h"
+#include "mhd_options.h"
+#include <stddef.h>
 
 /**
  * Opaque handle for a memory pool.

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]