[M3devel] addresses of constants?

Jay K jay.krell at cornell.edu
Mon Aug 6 05:48:22 CEST 2012


Ugzip.m3 does an unnecessary heap allocation and copy.


Here I have changed it to avoid the heap allocation.
But it still makes a copy.

How can I fix that?

It seems ADR cannot be applied to constants?

CONST
  ZLIB_VERSION = ARRAY [0..5] OF char{
                 ORD('1'), ORD('.'), ORD('0'), ORD('.'), ORD('4'), 0};

This works but still is inefficient:

PROCEDURE deflateInit(strm: z_stream_star; level: int): int =
  VAR version := ZLIB_VERSION;
  BEGIN
    RETURN UgzipP.deflateInit_(strm, level, ADR(version[0]), BYTESIZE(z_stream));
  END deflateInit;


I'd like to say ADR(ZLIB_VERSION[0]) or ADR(ZLIB_VERSION);

const ZLIB_VERSION = "1.0.4"; and ADR(ZLIB_VERSION[0]) of that.


 - Jay
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20120806/90de4878/attachment-0001.html>


More information about the M3devel mailing list