Re: mmap question

Alan Cox (alan@lxorguk.ukuu.org.uk)
Fri, 13 Feb 1998 18:53:00 +0000 (GMT)


> I'm interested in a user-space driver for a memory-mapped device. I
> looked at the khg example of vgalib. I'm confused.
>
> It does malloc first, then calls mmap passing the malloc'd buffer.
> Why? Why doesn't it just do anon mmap of /dev/kmem?

If it did that and you did other malloc calls, then malloc not knowing
you had mapped over that might try and allocate the same space again. Its
book-keeping nowdays. SInce modern malloc()'s use mmap its also possible to
do without. For portability a malloc and mmap approach is normally best

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu