home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / utilities / d / desklib / !DeskSrc / FN / Libraries / DeskMem / c / Calls < prev    next >
Encoding:
Text File  |  1996-09-18  |  2.1 KB  |  66 lines

  1. /*
  2.     ####             #    #     # #
  3.     #   #            #    #       #          The FreeWare C library for
  4.     #   #  ##   ###  #  # #     # ###             RISC OS machines
  5.     #   # #  # #     # #  #     # #  #   ___________________________________
  6.     #   # ####  ###  ##   #     # #  #
  7.     #   # #        # # #  #     # #  #    Please refer to the accompanying
  8.     ####   ### ####  #  # ##### # ###    documentation for conditions of use
  9.     ________________________________________________________________________
  10.  
  11.     File:    DeskMem.c.XCalls
  12.     Author:  Copyright © 1995 Julian Smith
  13.     Version: 1.02 (17 Nov 1995)
  14.     Purpose: Standard functions for allocating immovable bits of memory.
  15.     History: 1.00 (07 Sep 1995) JS
  16.              1.01 (10 Nov 1995) JS Put more common code into
  17.                                    Desk_DeskMem__XHandleError.
  18.              1.02 (17 Nov 1995) JS Put error handling into separate Error.c 
  19.                                    file.
  20.              1.03 (18 Nov 1995) JS Now uses Desk_DeskMem_Raw* macros.
  21. */
  22.  
  23.  
  24. #include "Desk.Debug.h"
  25. #include "Desk.Error.h"
  26.  
  27. #include "Defs.h"
  28.  
  29.  
  30.  
  31.  
  32. void    *Desk_DeskMem_Calloc( size_t num, size_t size)
  33. {
  34. void    *ptr = Desk_DeskMem_RawCalloc( num, size);
  35. Desk_Debug5_Printf( Desk_error_PLACE "Desk_DeskMem_Calloc called, num=%i, size=%i\n", num, size);
  36. if ( ptr || num==0 || size==0)    return ptr;
  37. return Desk_DeskMem__HandleError( size*num, NULL);
  38. }
  39.  
  40.  
  41. void    *Desk_DeskMem_Malloc( size_t size)
  42. {
  43. void    *ptr;
  44. Desk_Debug5_Printf( Desk_error_PLACE "Desk_DeskMem_Malloc called, size=%i\n", size);
  45. ptr = Desk_DeskMem_RawMalloc( size);
  46. if ( ptr || size==0)    return ptr;
  47. return Desk_DeskMem__HandleError( size, NULL);
  48. }
  49.  
  50.  
  51. void    *Desk_DeskMem_Realloc( void *oldptr, size_t size)
  52. {
  53. void    *ptr;
  54. Desk_Debug5_Printf( Desk_error_PLACE "Desk_DeskMem_Realloc called, oldptr=0x%p, size=%i\n", oldptr, size);
  55. ptr = Desk_DeskMem_RawRealloc( oldptr, size);
  56. if ( ptr || size==0)    return ptr;
  57. return Desk_DeskMem__HandleError( size, oldptr);
  58. }
  59.  
  60.  
  61. void    Desk_DeskMem_Free( void *ptr)
  62. {
  63. Desk_Debug5_Printf( Desk_error_PLACE "Desk_DeskMem_Free called for ptr 0x%p\n", ptr);
  64. Desk_DeskMem_RawFree( ptr);
  65. }
  66.