Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!julius.cs.uiuc.edu!apple!bbn.com!papaya.bbn.com!rsalz From: rsalz@bbn.com (Rich Salz) Newsgroups: comp.unix.programmer Subject: Re: hiding lint's ravings (was Re: FAQ - malloc array - clarify) Keywords: malloc, Sun, lint Message-ID: <2830@litchi.bbn.com> Date: 11 Sep 90 18:11:47 GMT References: <8056@helios.TAMU.EDU> <1990Sep08.022034.8444@virtech.uucp> <8086@helios.TAMU.EDU> Organization: BBN Systems and Technology, Inc. Lines: 27 In <8086@helios.TAMU.EDU> jdm5548@diamond.tamu.edu (James Darrell McCauley) writes: [ Summary: extern char *malloc(); double **dpp = (double **)malloc((unsigned int)n * sizeof (double*)); causes lint to complain "possible pointer alignment problem". ] Some people said ignore it, but James replied: >Well, I can just ignore warnings like this, but those who review >my code (professors, employers, clients) are not likely to. Then, simply put, they are not competent to review your code. If you need a better solution, you can often fool lint by writing your own malloc function that returns something with worst-case alignment. For example: #define NEW(type, count) xmalloc(count * sizeof (type)) typedef double *ALIGN; ALIGN xmalloc(i) int i; { ALIGN p = (ALIGN)malloc((unsigned int)i); if (p == NULL) FatalError("no memory"); return p; } double **dpp = NEW(double*, n); -- Please send comp.sources.unix-related mail to rsalz@uunet.uu.net. Use a domain-based address or give alternate paths, or you may lose out.