home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 373.lha / route_v1.0 / src / alloc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-04-25  |  1.1 KB  |  72 lines

  1. #include <stdio.h>
  2.  
  3. extern char *malloc();
  4.  
  5. void Nomem();
  6.  
  7. /*
  8.  * allocate x bytes of far memory
  9.  */
  10. char *Alloc(x)
  11. long x;
  12. {
  13.     char *fp;
  14.  
  15.     if (x >= 0x10000) {
  16.         printf("Error! malloc() too big!\n");
  17.         exit(-1);
  18.     }
  19.     if ((fp = malloc((short) x)) == NULL)
  20.         Nomem();        /* memory allocation error */
  21.     return(fp);
  22. }
  23.  
  24. /*
  25.  * a memory allocation request has failed
  26.  */
  27. void Nomem ()
  28. {
  29.     printf( "out of memory\n" );
  30.     exit( -1 );
  31. }
  32.  
  33. /*
  34.  * Free memory alloctated by Alloc();
  35.  */
  36. Free(x)
  37. char *x;
  38. {
  39.     free(x);
  40. }
  41.  
  42. /* edlib  version 1.0 of 04/08/88 */
  43. /*
  44.     string to upper changes all lower case letters in a string to upper
  45.     case.
  46. */
  47. #include <ctype.h>
  48.  
  49. char *strupr(str)
  50. char *str;
  51. {
  52.     char *temp = str;
  53.  
  54.     for ( ; *temp ; temp++ )
  55.         *temp = (char) toupper(*temp);
  56.  
  57.     return(str);
  58. }
  59.  
  60. int stricmp(str1,str2)
  61. char *str1,*str2;
  62. {
  63.     int index = 0;
  64.  
  65.     while ( str1[index] && str2[index] &&
  66.             tolower(str1[index]) == tolower(str2[index]) )
  67.         ++index;
  68.  
  69.     return( (tolower(str1[index]) < tolower(str2[index])) ? -1 :
  70.           ( (tolower(str1[index]) > tolower(str2[index])) ?  1 : 0) );
  71. }
  72.