Thread (12 messages) 12 messages, 4 authors, 2021-06-27

Re: [PATCH 1/3] mm: Add kvrealloc()

From: Dave Chinner <david@fromorbit.com>
Date: 2021-06-25 05:02:46
Also in: linux-xfs

On Fri, Jun 25, 2021 at 04:54:11AM +0100, Matthew Wilcox wrote:
On Fri, Jun 25, 2021 at 12:30:27PM +1000, Dave Chinner wrote:
quoted
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 8ae31622deef..34d88ff00f31 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -830,6 +830,20 @@ static inline void *kvcalloc(size_t n, size_t size, gfp_t flags)
 extern void kvfree(const void *addr);
 extern void kvfree_sensitive(const void *addr, size_t len);
 
+static inline void *kvrealloc(void *p, size_t oldsize, size_t newsize,
+		gfp_t flags)
+{
+	void *newp;
+
+	if (oldsize >= newsize)
+		return p;
+	newp = kvmalloc(newsize, flags);
+	memcpy(newp, p, oldsize);
+	kvfree(p);
+	return newp;
+}
Why make this an inline function instead of putting it in mm/util.c?
Not fussed, I can do that.

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help