Re: Why is the kfree() argument const?

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Linus Torvalds <torvalds@...>
Cc: Linux Kernel Mailing List <linux-kernel@...>, <clameter@...>, <penberg@...>
Date: Wednesday, January 16, 2008 - 6:19 pm

Hi,

Linus Torvalds <torvalds@linux-foundation.org> writes:

[...]


[...]


[...]


Okay, I understood that now.  A const qualifier just forbids modifying
the underlying memory _through this particular pointer_, right?

In the case of slub's kfree(), which takes a const pointer, you pass it
on to slab_free() which actually _DOES_ modification of the underlying
memory when linking the object to the freelist (as far as I understood
the code).

So if I got it right and you actually modify the memory you only got a
const pointer to, you reach a level where you _have to_ break this
policy and cast to a non-const pointer, as it is currently done in
kfree().  No?

	Hannes
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Why is the kfree() argument const?, Johannes Weiner, (Wed Jan 16, 12:32 pm)
Re: Why is the kfree() argument const?, Linus Torvalds, (Wed Jan 16, 2:39 pm)
Re: Why is the kfree() argument const?, Steven Rostedt, (Wed Jan 16, 6:33 pm)
Re: Why is the kfree() argument const?, Johannes Weiner, (Wed Jan 16, 6:19 pm)
Re: Why is the kfree() argument const?, Linus Torvalds, (Wed Jan 16, 7:16 pm)
Re: Why is the kfree() argument const?, Christoph Lameter, (Wed Jan 16, 6:20 pm)
Re: Why is the kfree() argument const?, Linus Torvalds, (Wed Jan 16, 7:18 pm)
Re: Why is the kfree() argument const?, Johannes Weiner, (Wed Jan 16, 7:13 pm)
Re: Why is the kfree() argument const?, Johannes Weiner, (Wed Jan 16, 6:37 pm)
Re: Why is the kfree() argument const?, Christoph Lameter, (Wed Jan 16, 12:48 pm)
Re: Why is the kfree() argument const?, Pekka J Enberg, (Wed Jan 16, 1:45 pm)
Re: Why is the kfree() argument const?, Bernd Petrovitsch, (Wed Jan 16, 1:34 pm)