Path: utzoo!attcan!uunet!cs.utexas.edu!samsung!munnari.oz.au!bruce!merlin!morgana!ianh From: ianh@bhpmrl.oz.au (Ian Hoyle) Newsgroups: comp.sys.sgi Subject: Re: problem with malloc (Irix 3.3.1) Message-ID: Date: 25 Oct 90 19:18:32 GMT References: <1658@merlin.bhpmrl.oz.au> Sender: usenet@bhpmrl.oz.au Lines: 55 ianh@bhpmrl.oz.au (Ian Hoyle) writes: >I've got an ongoing (well it was there with 3.2.2 and we just went to >3.3.1 today) problem with malloc. The application in question is >Rich Burridge's mp postscript filter program, patchlevel 13. >The following code fragment is causing problems: > len = strlen(ptr) ; > FPRINTF(stderr, "%s [] %s [] %i\n", ptr, whoami,strlen(whoami)) ; > timenow = malloc((unsigned)(len + 6 + strlen(whoami) + 1)) ; > FPRINTF(stderr,"After that error\n"); [.... other stuff from dbx ] >I linked it using -lmalloc. I'm completely at a loss to what may be occuring. Well I've fixed the problem. When mp was being linked, the command line in the Makefile was $(CC) $(LDFFLAGS) -o mp $(OBJS) where LDFLAGS = -lmalloc My guess is that there is an implicit -lc tacked on the end of this line thus using the malloc(3C) and *not* malloc(3X). It should have read $(CC) -o mp $(OBJS) $(LDFLAGS) thus loading libmalloc *last*. I don't think it's a case of RTFM because I've just done that and couldn't find reference to exactly where the library definition should go in a cc compile line. eg. from the manual entry for malloc(3X) : "It is found in the library "libmalloc.a", and is loaded if the option -lmalloc is used with cc(1) or ld(1)". But, it's probably there somewhere and I missed it ..... damn it :-( Thanks to those people who replied to me and made lots of useful suggestions to chase up, ian -- Ian Hoyle /\/\ Image Processing & Data Analysis Group / / /\ BHP Melbourne Research Laboratories / / / \ 245 Wellington Rd, Mulgrave, 3170 / / / /\ \ AUSTRALIA \ \/ / / / \ / / / Phone : +61-3-560-7066 \/\/\/ FAX : +61-3-561-6709 E-mail : ianh@bhpmrl.oz.au