Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!mcsun!hp4nl!fwi.uva.nl!robbel From: robbel@fwi.uva.nl (Robert Belleman) Newsgroups: comp.sys.amiga.programmer Subject: Re: Message Ports Message-ID: <1991Jun7.140841.28168@fwi.uva.nl> Date: 7 Jun 91 14:08:41 GMT References: <22192@cbmvax.commodore.com> Sender: news@fwi.uva.nl Distribution: comp Organization: FWI, University of Amsterdam Lines: 61 Nntp-Posting-Host: wendy.fwi.uva.nl drysdale@cbmvax.commodore.com (Scott Drysdale) writes: >In article bart@asgard.pub.uu.oz.au (John Butcher) writes: >>been trying to do message ports, but I havent had lots of success, my ports >>wont get properly recognized by name. Below small test program I wrote : [small test program deleted] >CreatePort() simply points to the name you give it (argv[1] in your case). >you want to do something like this: > > char *name; > name = AllocMem(strlen(argv[1]) + 1, MEMF_PUBLIC); > strcpy(name, argv[1]); > mp = CreatePort(name, 0); > >*note* do NOT free(name) - you want the port to live forever (or until >you delete it, whichever comes first). I think that's dirty code. Say, as another example like this, I'd want to change the name of a task, _permanently_ ; (hold on; following is all from memory) main(int argc, char *argv[]) { struct *Task mytask; mytask = FindTask(NULL); /* find _this_ task */ mytask->tc_Node.ln_Name = argv[1]; } ... would obviously not work for the same reason as John's code. But if I would change this to what Scot suggests (allocating memory for the name, copying argv[1] to that memory and putting the name pointer to that and NOT freeing anything), this would eat memory as I won't be able to free() it anymore after my program exits! Even when the task exits! How would you handle this situation? >> John Butcher : bart@asgard.pub.uu.oz.au > --Scotty >-- >=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= >Scott Drysdale Software Engineer >Commodore Amiga Inc. UUCP {allegra|burdvax|rutgers|ihnp4}!cbmvax!drysdale > PHONE - yes. >"Have you hugged your hog today?" >=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -- Rob Robert Belleman robbel@fwi.uva.nl -- ______________________________________________________________________ / Robert Belleman, University of Amsterdam \ | robbel@fwi.uva.nl | | robbel@nki.nl |