From owner-freebsd-hackers Fri Dec 27 15:07:44 1996 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.4/8.8.4) id PAA12819 for hackers-outgoing; Fri, 27 Dec 1996 15:07:44 -0800 (PST) Received: from mail.crl.com (mail.crl.com [165.113.1.22]) by freefall.freebsd.org (8.8.4/8.8.4) with SMTP id PAA12810 for ; Fri, 27 Dec 1996 15:07:42 -0800 (PST) Received: from phaeton.Artisoft.COM by mail.crl.com with SMTP id AA18232 (5.65c/IDA-1.5 for ); Fri, 27 Dec 1996 15:07:48 -0800 Received: (from terry@localhost) by phaeton.artisoft.com (8.6.11/8.6.9) id PAA25406; Fri, 27 Dec 1996 15:59:28 -0700 From: Terry Lambert Message-Id: <199612272259.PAA25406@phaeton.artisoft.com> Subject: Re: MMAP() problem partially solved... To: scrappy@hub.org (Marc G. Fournier) Date: Fri, 27 Dec 1996 15:59:28 -0700 (MST) Cc: hackers@FreeBSD.ORG In-Reply-To: from "Marc G. Fournier" at Dec 21, 96 08:28:00 pm X-Mailer: ELM [version 2.4 PL24] Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk > 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.