[comp.sys.atari.st] Mshrink

dag@chinet.UUCP (Daniel A. Glasser) (04/26/88)

I believe that some of the confusion here stems from the Abucus Internals
book (first edition, I don't have the second edition) which not only has a
description which is incomprehensable, but uses a different name than most
other docs.  The name they give it is SETBLOCK...  The function should not
be compiler specific if the compiler package offers bios/xbios/gemdos calls.
The Mark Williams C package does it with macros in the file osbind.h, the
Lattice C package uses functions in the library (since they use a 32 bit
'int' and TOS uses 16 bit ints...)

Mshrink() takes two parameters, the first is a pointer to the beginning of
a block of memory that has been allocated by a call to Malloc() (this includes
the basepage/TPA of a program in memory) and the second parameter is a long
containing the number of bytes to be freed.  Mshrink() is a GEMDOS function
and has function code 74.

*WARNING***WARNING***WARNING***WARNING***WARNING***WARNING***WARNING***WARNING*
* DO NOT CALL MSHRINK WITH THE FIRST PARAMETER POINTING TO ANYTHING EXCEPT    *
* THE BEGINNING OF A BLOCK ALLOCATED WITH THE *GEMDOS* Malloc FUNCTION OR THE *
* BASEPAGE OF A PROCESS IN MEMORY!  (Pexec() does an Malloc())  THE SYSTEM    *
* WILL VERY LIKELY GO BERZERK!                                                *
*WARNING***WARNING***WARNING***WARNING***WARNING***WARNING***WARNING***WARNING*
-- 
		Daniel A. Glasser	dag@chinet.UUCP
    One of those things that goes "BUMP!!! (ouch!)" in the night.
 ...!att-ih!chinet!dag | ...!ihnp4!mwc!dag | ...!ihnp4!mwc!gorgon!dag

apratt@atari.UUCP (Allan Pratt) (04/28/88)

From article <4983@chinet.UUCP>, by dag@chinet.UUCP (Daniel A. Glasser):

> Mshrink() takes two parameters, the first is a pointer to the beginning
> of a block of memory that has been allocated by a call to Malloc() (this
> includes the basepage/TPA of a program in memory) and the second
> parameter is a long containing the number of bytes to be freed. 
> Mshrink() is a GEMDOS function and has function code 74. 

Poor Dan Glasser has forgotten something:  the macro Mshrink includes
a dummy parameter, because the Gemdos call has an unused argument.

#define Mshrink(base,newsize) gemdos(0x4a,0,base,newsize)

Most macro files (including Atari's osbind.h) have this definition, but
you have to know it's there if you're setting up your own bindings.

This is a handy time to mention that the arguments to Fdatime are
documented wrong: the correct call is:

	Fdatime(timebuf,handle,wflag)
	int *timebuf;		/* pointer to two int's */
	int handle;		/* handle of file to change */
	int wflag;		/* 1 for write, 0 for read */

============================================
Opinions expressed above do not necessarily	-- Allan Pratt, Atari Corp.
reflect those of Atari Corp. or anyone else.	  ...ames!atari!apratt

wes@obie.UUCP (Barnacle Wes) (05/01/88)

In article <1047@atari.UUCP>, apratt@atari.UUCP (Allan Pratt) writes:
% This is a handy time to mention that the arguments to Fdatime are
% documented wrong: the correct call is:
% 
% 	Fdatime(timebuf,handle,wflag)
% 	int *timebuf;		/* pointer to two int's */
% 	int handle;		/* handle of file to change */
% 	int wflag;		/* 1 for write, 0 for read */

For those of you with MWC, Fdatime is documented correctly there.
<grin, snicker, chuckle>  :-)  Of course, this includes all the new
registered developers, doesn't it?

-- 
    /\              -  "Against Stupidity,  -    {backbones}!
   /\/\  .    /\    -  The Gods Themselves  -  utah-cs!uplherc!
  /    \/ \/\/  \   -   Contend in Vain."   -   sp7040!obie!
 / U i n T e c h \  -       Schiller        -        wes