Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!tut.cis.ohio-state.edu!ucbvax!dewey.soe.berkeley.edu!oster From: oster@dewey.soe.berkeley.edu (David Phillip Oster) Newsgroups: comp.sys.mac.programmer Subject: Re: Handles and Virtual Memory Message-ID: <33448@ucbvax.BERKELEY.EDU> Date: 3 Jan 90 08:51:14 GMT References: <9415@hoptoad.uucp> <18300010@ux1.cso.uiuc.edu> <18054@dartvax.Dartmouth.EDU> <9438@hoptoad.uucp> <1669@intercon.com> Sender: usenet@ucbvax.BERKELEY.EDU Reply-To: oster@dewey.soe.berkeley.edu.UUCP (David Phillip Oster) Organization: School of Education, UC-Berkeley Lines: 30 In article <1669@intercon.com> amanda@mermaid.intercon.com (Amanda Walker) writes: >Indeed, I've often been tempted to write a rudimentary version of the Mac >memory manager for things like UNIX machines or PCs, simply so that I >can have relocatable (and more importantly, *resizable*) blocks of memory >without having to do my own memory management & reallocation. Go for it! It will take you about 1 minute: consider: typedef char *Ptr, **Handle; Handle UnixNewHandle(size)long size;{ Handle h; h = (Handle) malloc(sizeof(Handle)); *h = (Ptr) malloc(size); return h; } void SetHandleSize(h, newSize)Handle h;long newSize;{ realloc(*h, newsize); } does almost all the work for you. Error handling is left as an exercise. (The above assumes you have a virtual memory system, and a decent implementation of malloc(), so you don't have to worry about fragmentation of the heap.) --- David Phillip Oster -- No, I come from Boston. I just work Arpa: oster@dewey.soe.berkeley.edu -- in cyberspace. Uucp: {uwvax,decvax}!ucbvax!oster%dewey.soe.berkeley.edu