Date: Fri, 27 Dec 1996 15:59:28 -0700 (MST) From: Terry Lambert <terry@lambert.org> To: scrappy@hub.org (Marc G. Fournier) Cc: hackers@FreeBSD.ORG Subject: Re: MMAP() problem partially solved... Message-ID: <199612272259.PAA25406@phaeton.artisoft.com> In-Reply-To: <Pine.BSF.3.95.961221202328.1105E-100000@thelab.hub.org> from "Marc G. Fournier" at Dec 21, 96 08:28:00 pm
next in thread | previous in thread | raw e-mail | index | archive | help
> First off, I've sort of found the problem I was having with storing > and recovering the 'int' value from the mmap()'d region... > > Since I was doing 'sprintf(mem_loc, "%d", value);', I was attempting > to store a 5byte char into a 4byte region, so memory overruns. I've changed > things so that I'm allocating 10bytes of space instead of 'sizeof(int)' to > get around that.. > > Still curious as to whether there is something better I should be using, > mind you...something like 'mem_loc = (char *)&size;'? > > Oh well...back to the code...sorry for the disruption... *(int *)mem_lock = value; /* store int without converting it*/ value = *(int *)mem_loc; /* retrieve int without converting it*/ This assumes that mem_lock is alignerd to a 4 byte boundry. Terry Lambert terry@lambert.org --- Any opinions in this posting are my own and not those of my present or previous employers.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199612272259.PAA25406>