Re: Why is the kfree() argument const?

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Johannes Weiner
Date: Wednesday, January 16, 2008 - 3: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, 9:32 am)
Re: Why is the kfree() argument const?, Christoph Lameter, (Wed Jan 16, 9:48 am)
Re: Why is the kfree() argument const?, Bernd Petrovitsch, (Wed Jan 16, 10:34 am)
Re: Why is the kfree() argument const?, Pekka J Enberg, (Wed Jan 16, 10:45 am)
Re: Why is the kfree() argument const?, Linus Torvalds, (Wed Jan 16, 11:39 am)
Re: Why is the kfree() argument const?, Johannes Weiner, (Wed Jan 16, 3:19 pm)
Re: Why is the kfree() argument const?, Christoph Lameter, (Wed Jan 16, 3:20 pm)
Re: Why is the kfree() argument const?, Johannes Weiner, (Wed Jan 16, 3:37 pm)
Re: Why is the kfree() argument const?, Linus Torvalds, (Wed Jan 16, 4:16 pm)
Re: Why is the kfree() argument const?, Linus Torvalds, (Wed Jan 16, 4:18 pm)