git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v3 1/3] fast-import: rename mem_pool type to mp_block

From
Jameson Miller <jamill@microsoft.com>
Date
Mar 26, 2018, 17:03 UTC
Message-ID
<20180326170351.197793-2-jamill@microsoft.com>
In-Reply-To
<20180321164152.204869-1-jamill@microsoft.com>

This is part of a patch series to extract the memory pool logic in fast-import into a more generalized version. The existing mem_pool type maps more closely to a "block of memory" (mp_block) in the more generalized memory pool. This commit renames the mem_pool to mp_block to reduce churn in future patches.

Signed-off-by: Jameson Miller <jamill@microsoft.com>
---
 fast-import.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/fast-import.c b/fast-import.c
index 58ef360da4..6c3215d7c3 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -209,8 +209,8 @@ struct last_object {
 	unsigned no_swap : 1;
 };
 
-struct mem_pool {
-	struct mem_pool *next_pool;
+struct mp_block {
+	struct mp_block *next_block;
 	char *next_free;
 	char *end;
 	uintmax_t space[FLEX_ARRAY]; /* more */
@@ -304,9 +304,9 @@ static int global_argc;
 static const char **global_argv;
 
 /* Memory pools */
-static size_t mem_pool_alloc = 2*1024*1024 - sizeof(struct mem_pool);
+static size_t mem_pool_alloc = 2*1024*1024 - sizeof(struct mp_block);
 static size_t total_allocd;
-static struct mem_pool *mem_pool;
+static struct mp_block *mp_block_head;
 
 /* Atom management */
 static unsigned int atom_table_sz = 4451;
@@ -636,14 +636,14 @@ static unsigned int hc_str(const char *s, size_t len)
 
 static void *pool_alloc(size_t len)
 {
-	struct mem_pool *p;
+	struct mp_block *p;
 	void *r;
 
 	/* round up to a 'uintmax_t' alignment */
 	if (len & (sizeof(uintmax_t) - 1))
 		len += sizeof(uintmax_t) - (len & (sizeof(uintmax_t) - 1));
 
-	for (p = mem_pool; p; p = p->next_pool)
+	for (p = mp_block_head; p; p = p->next_block)
 		if ((p->end - p->next_free >= len))
 			break;
 
@@ -652,12 +652,12 @@ static void *pool_alloc(size_t len)
 			total_allocd += len;
 			return xmalloc(len);
 		}
-		total_allocd += sizeof(struct mem_pool) + mem_pool_alloc;
-		p = xmalloc(st_add(sizeof(struct mem_pool), mem_pool_alloc));
-		p->next_pool = mem_pool;
+		total_allocd += sizeof(struct mp_block) + mem_pool_alloc;
+		p = xmalloc(st_add(sizeof(struct mp_block), mem_pool_alloc));
+		p->next_block = mp_block_head;
 		p->next_free = (char *) p->space;
 		p->end = p->next_free + mem_pool_alloc;
-		mem_pool = p;
+		mp_block_head = p;
 	}
 
 	r = p->next_free;
-- 
2.14.3
Previous: Junio C HamanoNext: Jameson Miller
Message 20 of 29 in “Extract memory pool logic into reusable component”
  1. 0/3 Extract memory pool logic into reusable componentjameson.miller81@gmail.com, Mar 21, 2018
  2. 1/3 fast-import: rename mem_pool to fi_mem_pooljameson.miller81@gmail.com, Mar 21, 2018
  3. 3/3 fast-import: use built-in mem pooljameson.miller81@gmail.com, Mar 21, 2018
  4. 2/3 Introduce a reusable memory pool typejameson.miller81@gmail.com, Mar 21, 2018
  5. Junio C HamanoMar 21, 2018
  6. 0/3 Extract memory pool logic into reusable componentJameson Miller, Mar 23, 2018
  7. 1/5 fast-import: rename mem_pool type to mp_blockJameson Miller, Mar 23, 2018
  8. Junio C HamanoMar 23, 2018
  9. 2/5 fast-import: introduce mem_pool typeJameson Miller, Mar 23, 2018
  10. Junio C HamanoMar 23, 2018
  11. 3/5 fast-import: update pool_* functions to work on local poolJameson Miller, Mar 23, 2018
  12. Junio C HamanoMar 23, 2018
  13. 5/5 Expand implementation of mem-pool typeJameson Miller, Mar 23, 2018
  14. Junio C HamanoMar 23, 2018
  15. 4/5 Move the reusable parts of memory pool into its own fileJameson Miller, Mar 23, 2018
  16. Junio C HamanoMar 23, 2018
  17. 2/3 fast-import: introduce mem_pool typeJameson Miller, Mar 26, 2018
  18. Eric SunshineMar 26, 2018
  19. Junio C HamanoMar 27, 2018
  20. 1/3 fast-import: rename mem_pool type to mp_blockJameson Miller, Mar 26, 2018
  21. 3/3 Move reusable parts of memory pool into its own fileJameson Miller, Mar 26, 2018
  22. Junio C HamanoMar 27, 2018
  23. Jameson MillerMar 29, 2018
  24. 0/3 Extract memory pool logic into reusable componentJameson Miller, Mar 26, 2018
  25. 0/3 Extract memory pool logic into reusable componentJameson Miller, Apr 11, 2018
  26. Jameson MillerApr 17, 2018
  27. 3/3 Move reusable parts of memory pool into its own fileJameson Miller, Apr 11, 2018
  28. 2/3 fast-import: introduce mem_pool typeJameson Miller, Apr 11, 2018
  29. 1/3 fast-import: rename mem_pool type to mp_blockJameson Miller, Apr 11, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.