home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 6 / FreshFish_September1994.bin / new / dev / c / hce / hcesource / top / source / util.c < prev   
C/C++ Source or Header  |  1992-09-02  |  1KB  |  70 lines

  1. /* Copyright (c) 1988,1991 by Sozobon, Limited.  Author: Tony Andrews
  2.  *
  3.  * Permission is granted to anyone to use this software for any purpose
  4.  * on any computer system, and to redistribute it freely, with the
  5.  * following restrictions:
  6.  * 1) No charge may be made other than reasonable charges for reproduction.
  7.  * 2) Modified versions must be clearly marked as such.
  8.  * 3) The authors are not responsible for any harmful consequences
  9.  *    of using this software, even if they result from defects in it.
  10.  *
  11.  * Modified by Detlef Wuerkner for AMIGA
  12.  * Changes marked with TETISOFT
  13.  */
  14.  
  15. #include <stdio.h>
  16.  
  17. /* ADDED BY TETISOFT */
  18. #include <stdlib.h>
  19.  
  20. /*
  21.  * strsave(s) - copy s to dynamically allocated space
  22.  */
  23. char *
  24. strsave(s)
  25. register char    *s;
  26. {
  27.     char    *malloc(), *strcpy();
  28.  
  29.     return strcpy(malloc((unsigned) (strlen(s) + 1)), s);
  30. }
  31.  
  32. /*
  33.  * alloc() - malloc with error checking
  34.  */
  35. char *
  36. alloc(n)
  37. int    n;
  38. {
  39.     extern    char    *malloc();
  40.     char    *p;
  41.  
  42.     if ((p = malloc(n)) == NULL) {
  43.         fprintf(stderr, "top: out of memory\n");
  44.  
  45. /* CHANGED BY TETISOFT */
  46. /*        exit(1); */
  47.         exit(EXIT_FAILURE);
  48.  
  49.     }
  50.     return p;
  51. }
  52.  
  53. #if    MINIX || UNIX
  54.  
  55. remove(f)
  56. char    *f;
  57. {
  58.     unlink(f);
  59. }
  60.  
  61. rename(f1, f2)
  62. char    *f1, *f2;
  63. {
  64.     unlink(f2);
  65.     link(f1, f2);
  66.     unlink(f1);
  67. }
  68.  
  69. #endif
  70.