rc-list - mailing list for the rc(1) shell
 help / color / mirror / Atom feed
* Re: A potentially useful patch
@ 1993-09-21 14:17 rsalz
  0 siblings, 0 replies; 2+ messages in thread
From: rsalz @ 1993-09-21 14:17 UTC (permalink / raw)
  To: culliton, rc

I absolutely hate it when people use #ifdef to break up C flow of
control statements.  This seems cleaner and fits Byron's coding
style (using !p for p == NULL -- ick!):

  extern void *erealloc(void *p, SIZE_T n) {
	  extern void *realloc(void *, SIZE_T);
+ #ifdef BROKENREALLOC
+	  if (p == NULL)
+		  return ealloc(n);
+ #endif
	  if ((p = realloc(p, n)) == NULL) {
		  uerror("realloc");
		  rc_exit(1);
	  }
	  return p;
  }

	/r$



^ permalink raw reply	[flat|nested] 2+ messages in thread
* A potentially useful patch
@ 1993-09-21  0:33 Tom Culliton x2278
  0 siblings, 0 replies; 2+ messages in thread
From: Tom Culliton x2278 @ 1993-09-21  0:33 UTC (permalink / raw)
  To: rc

Sigh.... While trying to get Alan's read integrated I rediscovered that
SCO-ODT 1.1 has a broken realloc.  It dumps core when it gets a null
pointer for the old buffer.  Fortunately Byron's code doesn't seem to
rely on this behaviour.  Just in case though, here's a patch for other
folks in the same boat.

Tom

*** config.h.old	Wed Feb  3 15:37:36 1993
--- config.h	Mon Sep 20 20:29:01 1993
***************
*** 108,113 ****
--- 108,122 ----
  #define NOJOB
   */
  
+ /*
+  * SCO-ODT 1.1 has a broken realloc which dumps core when it gets a null
+  * pointer for the old buffer.  Byron's code doesn't seem to rely on this
+  * behaviour, but just in case something in the future does, you can define
+  * this to enable a fanny shield.  Don't do it unless you know that you
+  * have this problem.
+ #define BROKENREALLOC
+ */
+  
  /* Beginning of defaults section: */
  
  #ifndef CUSTOM
*** nalloc.c.old	Thu Feb 27 02:22:10 1992
--- nalloc.c	Mon Sep 20 19:43:52 1993
***************
*** 122,127 ****
--- 122,132 ----
  
  extern void *erealloc(void *p, SIZE_T n) {
  	extern void *realloc(void *, SIZE_T);
+ #ifdef BROKENREALLOC
+ 	if (!p) {
+ 		p = ealloc(n);
+ 	} else
+ #endif
  	if ((p = realloc(p, n)) == NULL) {
  		uerror("realloc");
  		rc_exit(1);


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1993-09-21 14:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1993-09-21 14:17 A potentially useful patch rsalz
  -- strict thread matches above, loose matches on Subject: below --
1993-09-21  0:33 Tom Culliton x2278

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).