;       SCCSID = @(#)smrfreme.asm       6.1 90/11/17
;       SCCSID @(#)smrfreme.asm 6.3 90/02/13
PAGE 60,132    ;
; ****************************************************************************
; *                                                                          *
; *                       IBM/Microsoft Confidential                         *
; *                                                                          *
; *                 Copyright (c) IBM Corporation  1987, 1990                *
; *                 Copyright (c) Microsoft Corp.  1987, 1990                *
; *                           All Rights Reserved                            *
; *                                                                          *
; ****************************************************************************

;***************************************************************************
; Source File Name:     SMRFREME.ASM
;
; Subroutine Name:      DOSSMFREEMEM
;
; Descriptive Name:     Free memory from the Session Manager's heap.
;
; Function:     This will free (DosSubFree) memory allocated (DosSubAloc)
;               by the Session Manager.  It will NOT Deallocate (DosFreeSeg)
;               a segment if all it's memory is freed (DosSubFree).
;               1st WORD of memory block MUST be it's size.
;
; Notes:
;       Dependencies:   None.
;
;       Restrictions:   Can not free more than 64K.  1st word of segment
;                       MUST be the size of the segment.
;
;       Change History:
;
;       @T52  02/09/90  TPL  DCR 704 work
;       MDLL  01/10/94  BJN  Page Tune segments for Merged DLL.
;
; Entry Point:
;       Linkage:  EXTRN DOSSMFREEMEM : FAR
;                       PUSH@   Address to free
;                       CALL    DOSSMGETMEM
;
; Inputs:
;       DWORD    Address     Address to free
;
; Exit Normal:
;       AX      ReturnCode Value = 0, memory allocated
;
; Exit Errors:
;       AX      ReturnCode    DosSubFree     return codes
;                             DosFreeSeg     return codes
;
; Effects:      All other registers preserved.
;
; Internal References:
;
;          Routines:
;
; External References:
;          Routines:
;
;***************************************************************************
ifdef I1
;
;  Get Pointer to memory to free
;  First word is # of bytes to free
;  DOSSUBFREE
;
;***************************************************************************
else

.386C

   SESMGR  EQU  -1                      ;Needed for pmshl.inc

   EXTRN MemorySegments : WORD          ; Array of 64K segments
   EXTRN SegmentSizes   : WORD          ; Array of sizes of MemorySegments

   EXTRN DOSSUBFREE     : FAR
.xlist
   INCLUDE SMRFREME.INC
.xcref
   INCLUDE ERROR2.INC
   INCLUDE STRUC.INC
   INCLUDE SMREQUS.INC           ; General Equates

;CDATA   SEGMENT WORD PUBLIC 'FAR_DATA' USE16                           ;MDLL
;CDATA   ENDS                                                           ;MDLL
.cref
.list

CODE_TUNE1   SEGMENT WORD PUBLIC 'CODE' USE16                           ;MDLL
   ASSUME CS:CODE_TUNE1,DS:NOTHING,SS:NOTHING,ES:NOTHING                ;MDLL

    PUBLIC  DOSSMFREEMEM
DOSSMFREEMEM  PROC FAR

   Local_Bytes  EQU  0
   ENTER Local_Bytes,0
   PUSH DS                             ; Save caller's registers
   PUSH SI

   LDS  SI, SS:[BP].FreeMemAddress     ; DS:SI --> Memory to free
   PUSH DS                             ; Selector to free
   PUSH SI                             ; Offset to free
   PUSH WORD PTR [SI]                  ; First word is # of bytes to free
   CALL DOSSUBFREE                     ; Free them

   POP  SI                             ; Restore caller's registers
   POP  DS
   LEAVE
   RET    FreeMemLen                    ; Return to caller

DOSSMFREEMEM  ENDP
CODE_TUNE1   ENDS                                                       ;MDLL
endif
   END
