From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,a1797de6fe6f5fbc,start X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!k33g2000yqa.googlegroups.com!not-for-mail From: Justin Squirek Newsgroups: comp.lang.ada Subject: Simple question with dynamic memory allocation Date: Sun, 18 Oct 2009 20:54:54 -0700 (PDT) Organization: http://groups.google.com Message-ID: <9a22eec3-925d-4551-bafe-a4c862d2413d@k33g2000yqa.googlegroups.com> NNTP-Posting-Host: 71.56.32.142 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1255924494 21216 127.0.0.1 (19 Oct 2009 03:54:54 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 19 Oct 2009 03:54:54 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: k33g2000yqa.googlegroups.com; posting-host=71.56.32.142; posting-account=9sSOLAoAAABguukttEnE7BTWuhamXqod User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3,gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:8722 Date: 2009-10-18T20:54:54-07:00 List-Id: I am working on an Ada 3d engine to render 3ds models and right now for simplicities sake I was using a record with bounded arrays for the model type... However, because 3ds models have multiple groups (currently I am restricted to only rendering one per model record) and the amount of verticies is unknown I may be wasting memory by having the bounded arrays i.e. they are set to MAXIMUM_VERTICES instead of just that of a loaded model's mesh's verticies. What is the best way to dynamically allocate memory in ada? (I have seen tutorials that use Uncheck_Deallocation and linked lists, but I would like to know if there is an option through a preexisting ada libraries) >>> .... MAXIMUM_VERTICES : CONSTANT := 8000; MAXIMUM_POLYGONS : CONSTANT := 8000; MODEL_3DS_MAIN : CONSTANT := 16#4D4D#; MODEL_3DS_EDIT : CONSTANT := 16#3D3D#; MODEL_3DS_MESH : CONSTANT := 16#4100#; MODEL_3DS_NAME : CONSTANT := 16#4000#; MODEL_3DS_VERTCIES : CONSTANT := 16#4110#; MODEL_3DS_POLYGONS : CONSTANT := 16#4120#; MODEL_3DS_MAPPING : CONSTANT := 16#4140#; package Float_32_Elementary_Functions is new Ada.Numerics.Generic_Elementary_Functions(Float_32); use Float_32_Elementary_Functions; subtype Record_Vertex is Record_Vector_3d; type Record_Map_Coordinate is record U : Float_32; V : Float_32; end record; type Record_Polygon is record A : Integer_16_Signed; B : Integer_16_Signed; C : Integer_16_Signed; end record; type Array_Record_Vertex is array (1..MAXIMUM_VERTICES) of Record_Vertex; type Array_Record_Vertex_8 is array (1..8) of Record_Vertex; type Array_Record_Map_Coordinate is array (1..MAXIMUM_VERTICES) of Record_Map_Coordinate; type Array_Polygon is array (1..MAXIMUM_POLYGONS, 1..3) of Integer_16_Unsigned; type Record_Model is record File_Name : Unbounded_String := To_Unbounded_String (""); Vertices : Integer_16_Unsigned := 0; Polygons : Integer_16_Unsigned := 0; Texture_Id : Integer_32_Unsigned := 0; Name : String(1..20) := (others => Character'Val(0)); Polygon : Array_Polygon := (others => (others => 0)); Map_Coordinate : Array_Record_Map_Coordinate := (others => (others => 0.0)); Vertex : Array_Record_Vertex := (others => (others => 0.0)); Normal : Array_Record_Vertex := (others => (others => 0.0)); Sphere_Vertex : Array_Record_Vertex_8 := (others => (others => 0.0)); Sphere_Center : Record_Vertex := (others => 0.0); Sphere_Radius : Float_32 := 0.0; end record; type Record_Model_Constant_Access is access constant Record_Model; ... <<< 3ds Mesh rendered with engine at current stage: [1] http://i971.photobucket.com/albums/ae196/Justin_Sq/ada_3ds_render.jpg Thanks in advance for any help:)