From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <249de27d2581f3a562d4e3cb3a52d0a8@plan9.bell-labs.com> To: 9fans@cse.psu.edu Subject: Re: [9fans] same functions everywhere From: "Russ Cox" In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Date: Wed, 23 Apr 2003 11:05:17 -0400 Topicbox-Message-UUID: 96e1e8fc-eacb-11e9-9e20-41e7f4b1d025 > Reading the code for different commands and filesystems, I have found > there are at least three functions repeated with equivalent > implementations all over the place. These are erealloc emalloc and estrdup. > They call the function without the e and call sysfatal on error. Wouldn't it > be more economical and clear to have them on a library?. I almost did this but was talked out of it. The problem is that if they are in the library then it encourages other libraries to use them, and then we end up with a C library in which it is impossible to correctly handle an out-of-memory error. The decision to abort is best left up to the application.