delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1992/08/12/09:03:11

Date: Wed, 12 Aug 92 14:53:45 +0100
From: buers AT dg1 DOT chemie DOT uni-konstanz DOT de (Dieter Buerssner)
To: kunst AT prl DOT philips DOT nl
Cc: djgpp AT sun DOT soe DOT clarkson DOT edu, dj AT ctron DOT com
Subject: patch for onexit.c (was: atexit returns garbage)

Pieter Kunst writes:

 > (2)  The atexit() function (K&R, 2nd ed., p.253) returns garbage 
 >      instead of the expected 0 if successful. (I think this was not 
 >      the case in version 1.05 of DJGPP.)

The following patch should help. 

	Dieter

*** onexit.org	Wed Aug 12 14:37:57 1992
--- onexit.c	Wed Aug 12 14:43:14 1992
***************
*** 19,32 ****
  void (*func)(int);
  int arg;
  {
    struct atexit *a = (struct atexit *)malloc(sizeof(struct atexit));
    a->next = __atexit;
    a->function = func;
    a->arg = arg;
    __atexit = a;
  }
  
  atexit(a)
  {
!   on_exit(a,0);
  }
--- 19,37 ----
  void (*func)(int);
  int arg;
  {
+   if (func == 0)
+     return (-1);
    struct atexit *a = (struct atexit *)malloc(sizeof(struct atexit));
+   if (!(*a))
+     return (-1);
    a->next = __atexit;
    a->function = func;
    a->arg = arg;
    __atexit = a;
+   return(0);
  }
  
  atexit(a)
  {
!   return(on_exit(a,0));
  }


- Raw text -


  webmaster     delorie software   privacy  
  Copyright 2019   by DJ Delorie     Updated Jul 2019