Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!mit-eddie!uw-beaver!tektronix!tekcrl!tekfdi!videovax!stever From: stever@videovax.Tek.COM (Steven E. Rice, P.E.) Newsgroups: comp.sys.amiga Subject: Re: AllocMem()/FreeMem() question. Message-ID: <4709@videovax.Tek.COM> Date: Thu, 3-Dec-87 12:47:30 EST Article-I.D.: videovax.4709 Posted: Thu Dec 3 12:47:30 1987 Date-Received: Thu, 10-Dec-87 04:42:53 EST References: <2060@crash.cts.com> Reply-To: stever@videovax.Tek.COM (Steven E. Rice, P.E.) Organization: Tektronix Television Systems, Beaverton, Oregon Lines: 53 Keywords: trash free memory list, crash, burn Summary: Are you *SURE* you want to do this??????? In article <2060@crash.cts.com>, Wade Bickel (haitex@pnet01.cts.com) writes: > dillon@CORY.BERKELEY.EDU (Matt Dillon) writes: > >> Here's a question: >> >> If I AllocMem() a block of memory, can I FreeMem() a subsegment of >> that block (being careful to do everything on 8 byte boundries). That is: >> >> ptr = AllocMem(16, MEMF_PUBLIC); >> FreeMem(ptr+8,8); >> >> so ptr now points to 8 bytes allocated memory. Then at some point >> later on: >> >> FreeMem(ptr, 8); >> >> ??? >> >> -Matt > > > Seems that you should be able to, though I would think that > a structured approach to coding your allocations would avoid the > need to do so. The syntax and logic seem good, TRY IT! Ummmmmmm. . . Perhaps it might be a good idea to find out just *how* the system keeps track of what was allocated and how it is returned! In many cases, when memory is allocated, a few extra bytes are included at the beginning, identifying the block size and leaving space for a pointer so the block can be linked back into the free memory pool. If you turn back a piece you haven't explicitly allocated, you might find that the system would use data in the unreturned part as the block size, and stomp on part of the data in the unreturned part to link the "block" into the free list. Could be very, very messy. . . Steve Rice ----------------------------------------------------------------------------- new: stever@videovax.tv.Tek.com old: {decvax | hplabs | ihnp4 | uw-beaver}!tektronix!videovax!stever inews > 50% filler inews > 50% filler inews > 50% filler inews > 50% filler inews > 50% filler inews > 50% filler inews > 50% filler inews > 50% filler inews > 50% filler inews > 50% filler