home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / lib / Xdmcp / Alloc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-01-23  |  1.7 KB  |  58 lines

  1. /*
  2.  * $XConsortium: Alloc.c,v 1.1 89/09/14 17:11:04 keith Exp $
  3.  *
  4.  * Copyright 1989 Massachusetts Institute of Technology
  5.  *
  6.  * Permission to use, copy, modify, and distribute this software and its
  7.  * documentation for any purpose and without fee is hereby granted, provided
  8.  * that the above copyright notice appear in all copies and that both that
  9.  * copyright notice and this permission notice appear in supporting
  10.  * documentation, and that the name of M.I.T. not be used in advertising
  11.  * or publicity pertaining to distribution of the software without specific,
  12.  * written prior permission.  M.I.T. makes no representations about the
  13.  * suitability of this software for any purpose.  It is provided "as is"
  14.  * without express or implied warranty.
  15.  *
  16.  * M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
  17.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
  18.  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  19.  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  20.  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
  21.  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  22.  *
  23.  * Author:  Keith Packard, MIT X Consortium
  24.  */
  25.  
  26. /* stubs for use when Xalloc, Xrealloc and Xfree are not defined */
  27.  
  28. extern char    *malloc (), *realloc ();
  29.  
  30. long *
  31. Xalloc (amount)
  32.     unsigned    amount;
  33. {
  34.     if (amount == 0)
  35.     amount = 1;
  36.     return (long *) malloc (amount);
  37. }
  38.  
  39. long *
  40. Xrealloc (old, amount)
  41.     long    *old;
  42.     unsigned    amount;
  43. {
  44.     if (amount == 0)
  45.     amount = 1;
  46.     if (!old)
  47.     return (long *) malloc (amount);
  48.     return (long *) realloc ((char *) old, amount);
  49. }
  50.  
  51. void
  52. Xfree (old)
  53.     long    *old;
  54. {
  55.     if (old)
  56.     free ((char *) old);
  57. }
  58.