1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634
|
--- ./src/sia/sip_shared/mem_alloc.c 2014-10-14 12:40:26.000000000 +0200
+++ /dev/null 2014-10-10 00:17:42.528636087 +0200
@@ -1,210 +0,0 @@
-//TODO unit tests
-
-#include "mem_alloc.h"
-
-#include <assert.h>
-#include <stdlib.h>
-#include <stddef.h>
-#include <stdio.h>
-#include <limits.h>
-#include "f77_name.h"
-#include "f_types.h"
-
-#define BYTES_PER_MB 1048576
-#define ALIGN 8
-
-char * base_ptr = NULL; //start of allocated memory
-char * nxt_ptr = NULL; //address of next free memory
-long long top_int = 0LL; //highest address (as long long int) of allocated memory + 1
-long long total_bytes = 0LL; //total number of bytes allocated
-
-
-/**
- * initializes dynamic memory system by obtaining requested memory via malloc
- *
- * @param[in] megabytes amount of memory to be allocate and managed
- * @param[in] sheap_flag not currently implemented
- * @param[out] ierr 0 if successful, -1 if not successful
- *
- * If successful, this routine makes the memory management system active.
- * If this subroutine is called again while the memory system is active, it will simply return.
-*/
-void F77_NAME(mem_alloc_init,MEM_ALLOC_INIT)(f_int *megabytes, f_int *sheap_flag, f_int *ierr){
-#ifdef ALTIX
- assert (false); //altix memory management not implemented
-#endif
-// printf("mem_alloc_init called with %d megabytes\n", *megabytes);
- assert( sizeof(long long) == sizeof(char *)); //verify assumption about size of pointers
- *ierr = 0;
- if (total_bytes == 0){ //only do this once unless free has been called to reset.
- total_bytes = (long long)(*megabytes) * BYTES_PER_MB;
- // total_bytes = (*megabytes) * BYTES_PER_MB;
- base_ptr = (char *)malloc(total_bytes);
- if (base_ptr == 0)
- {
- printf("malloc failed: %d megabytes",*megabytes);
- total_bytes = 0;
- *ierr = -1;
- return;
- }
- nxt_ptr = base_ptr;
- top_int = (long long)base_ptr + total_bytes;
- assert (top_int > 0); //check that using signed type (long long) for addresses OK
- return;
- }
- return;
-}
-
-/**
- * Allocates nwords elements of size element_size from managed array. It is assumed that this subroutine
- * will be invoked from Fortran, so the parameters are described from the point of view of the Fortran code.
- * After return, the allocated memory is in base(ixmem):base(ixmem+nwords-1)
- *
- * @param[in] base the first element of a 1-element array declared and allocated in fortran
- * @param[in] element_size the size of the elements in the array
- * @param[out] ixmem integer*8 index into array indicating start of allocated memory.
- * @param[in] heap not currently implemented
- * @param[out] ierr value is 0 if successful
- */
-void F77_NAME(mem_alloc,MEM_ALLOC)
- (char *base, f_int *nwords, f_int *element_size, long long *ixmem, f_int *heap, f_int *ierr){
- assert (total_bytes != 0);
- *ierr = 0;
- f_int esize = *element_size;
- long long nbytes = (long long)(*nwords) * esize;
- long long fiddle = ALIGN-1;
- long long nxt_int = (long long)nxt_ptr;
-// printf("mem_alloc called with nwords %d and esize %d, previous nxt_int is %lld.\n",*nwords,esize,nxt_int);
- long long alloc_int = (nxt_int + fiddle) & ~(fiddle); //align on ALIGN byte boundary
- nxt_int = alloc_int + nbytes;
-// printf("mem_alloc calculated nxt_int is %lld.\n",nxt_int);
- if (nxt_int > top_int){
- printf("Error base_ptr=%lld, nxt_int= %lld, top_int = %lld",base_ptr, nxt_int,top_int);
- *ierr = -1;
- return;
- }
- nxt_ptr = (char *)nxt_int;
- long long base_int = (long long)base;
- // printf("mem_alloc done with nwords %d.base_ptr is %lld and nxt_ptr is %lld\n",*nwords, base_ptr, nxt_ptr);
- // printf("size of f_int is %d\n.",sizeof(f_int));
- // printf ("result of adding 1 to esize is %d\n", 1+esize);fflush(stdout);
- *ixmem = (long long)((alloc_int - base_int)/esize + 1);
-}
-
-
-/** allocates nbytes bytes from the managed array. It is assumed that this subroutine
- * will be invoked from C and has an interface similar to malloc
- *
- * @param nbytes[n] number of bytes
- * @return address of allocated memory, or 0 if not successful
- */
-char * mem_alloc_c(size_t nbytes){
- assert (total_bytes != 0);
- long long fiddle = ALIGN-1;
- long long nxt_int = (long long)nxt_ptr;
- long long alloc_int = (nxt_int + fiddle) & ~(fiddle); //align on ALIGN byte boundary
- nxt_int = alloc_int + nbytes;
- printf("mem_alloc_c called with %d bytes\n",nbytes);
- if (nxt_int >= top_int || nxt_int <= 0 ){ //check that enough memory available
- printf("nxt_int= %lld, top_int = %lld\n",nxt_int,top_int);
- alloc_int = 0;
- return NULL;
- }
- nxt_ptr = (char *)nxt_int;
- return (char *)alloc_int;
-}
-
-
-/**
- * frees all memory above addr so that it can be reallocated.
- *
- * @param addr[in] starting address of memory to be free. Must be in allocated memory
- * @param ierr[out] return code
- *
- * Note: mem_alloc_free will fail if called with invalid input. There is no scenario where there is a normal
- * return and ierr != 0. We may want to change this interface.
-*/
-void F77_NAME(mem_alloc_free,MEM_ALLOC_FREE)(char *addr, f_int *ierr){
- *ierr = 0;
- assert(base_ptr <= addr && (long long) addr <= top_int); //given address must be in allocated memory
- nxt_ptr = addr;
-}
-
-/**
-* mem_alloc_free_all returns all managed memory to OS and makes memory management inactive.
-* After calling this subroutine, the mem_alloc_init may be called to reinitialize the memory
-* management system.
-*/
-void F77_NAME(mem_alloc_free_all,MEM_ALLOC_FREE_ALL)(){
- if (base_ptr != 0) free(base_ptr);
- base_ptr = NULL;
- nxt_ptr = NULL;
- total_bytes = 0;
-}
-
-
-/**
- * Frees all memory allocated by mem_alloc so that it can be reallocated. The
- * memory system remains active. Freed memory is not reinitialized to 0.
-*/
-void F77_NAME(mem_alloc_reset,MEM_ALLOC_RESET)(){
- nxt_ptr = base_ptr;
-}
-
-
-/**
- * returns the amount of memory allocated
- *
- * *param nbused[out] amount of memory already allocated by mem_alloc
- */
-void F77_NAME(mem_alloc_query, MEM_ALLOC_QUERY)(long long *nbused){
- *nbused = (long long)nxt_ptr - (long long)base_ptr;
-}
-
-
-/**
- * returns the number of objects of a particular size that can be allocated.
- *
- * *param size[in] size of the object
- * *param number[out] number of objects that can be allocated
- */
-void F77_NAME(mem_query_free, MEM_QUERY_FREE)(f_int* size,f_int *number){
- *number = (f_int) (total_bytes)/(*size);
-}
-
-
-/**
- * returns the base address of the managed memory
- */
-long long F77_NAME(get_mem_base_addr,GET_MEM_BASE_ADDR)(){
- return (long long)base_ptr;
-}
-
-/** returns address of base(ix) where base is an array with 'size'-byte elements
- *
- * @param[in] base first element of array
- * @param[in] ix index of element whose address is to be returned
- * @param[in] size size of elements of array
- *
- * @returns address of base(ix)
- */
-long long F77_NAME(c_loc64, C_LOC64)(char *base, long long *ix, f_int *size)
-{
- long long addr;
- addr = (long long) base + (*ix-1)*(*size);
- return addr;
-}
-
-long long F77_NAME(get_max_heap_usage,GET_MAX_HEAP_USAGE) ()
-{
- return total_bytes;
-
-}
-
-/*for debugging*/
-void print_mem_values(){
- printf("base_ptr = %p\n", (void *)base_ptr);
- printf("nxt_ptr = %p\n", (void *) nxt_ptr);
- printf("top_int = %lld\n", top_int);
- printf("total_bytes = %lld\n", total_bytes);
-}
--- /dev/null 2014-10-10 00:17:42.528636087 +0200
+++ ./src/sia/sip_shared/mem_alloc.F 2014-10-14 12:40:36.000652136 +0200
@@ -0,0 +1,272 @@
+C Copyright (c) 2003-2010 University of Florida
+C
+C This program is free software; you can redistribute it and/or modify
+C it under the terms of the GNU General Public License as published by
+C the Free Software Foundation; either version 2 of the License, or
+C (at your option) any later version.
+
+C This program is distributed in the hope that it will be useful,
+C but WITHOUT ANY WARRANTY; without even the implied warranty of
+C MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+C GNU General Public License for more details.
+
+C The GNU General Public License is included in this distribution
+C in the file COPYRIGHT.
+ subroutine mem_alloc(base, nwords, element_size, ixmem,
+ * heap, ierr)
+c--------------------------------------------------------------------------
+c Allocates "nwords*element_size" bytes of memory using MPI_ALLOC_MEM,
+c and returns an index "ixmem" relative to the base address. Upon
+c return, the memory may be referenced by Fortran code as base(ixmem+i-1),
+c i = 1, 2, 3, ...,nwords.
+c
+c Arguments:
+c base Base array to reference the returned index.
+c nwords Number of words of memory to allocate.
+c element_size Number of bytes per element.
+c ixmem Returned index used in conjunction with "base" to
+c reference the allocated memory. This argument
+c should also be declared integer*8.
+c heap Logical variable. heap = .true. requests heap
+c allocation, .false. requests allocation on
+c shared heap.
+c ierr Return code. 0 = Successful allocation, otherwise
+c the subroutine was unable to obtain the required
+c amount of memory.
+c
+c--------------------------------------------------------------------------
+
+ implicit none
+ include 'machine_types.h'
+ include 'mem_alloc_data.h'
+ include 'parallel_info.h'
+#ifdef ALTIX
+ include 'sheap.h'
+#endif
+
+ integer base(*)
+ integer nwords, element_size, ierr
+ integer*8 ixmem
+ integer*8 addr1, addr2
+ integer*8 get_index_from_base
+ integer*8 size
+ integer type
+ integer sheap_flag
+
+ integer*8 ixx, c_loc64
+
+ logical heap
+
+ ierr = 0
+
+ if (nwords .lt. 0) then
+ print *,'Error: mem_alloc was called with nwords = ',nwords
+ call abort_job()
+ endif
+
+ if (element_size .eq. 8) then
+
+c-------------------------------------------------------------------------
+c Force alignment on a 8-byte boundary.
+c-------------------------------------------------------------------------
+
+ if (memnxt/8*8 .ne. memnxt) then
+ memnxt = (memnxt+7)/8*8
+ endif
+ endif
+
+ size = nwords
+ size = size * element_size
+
+c print *,'Task ',me,' MEM_ALLOC: nwords, element_size, size ',
+c * nwords, element_size, size,' memnxt ',memnxt,
+c * ' mem_malloced ',mem_malloced
+ if (memnxt + size .gt. mem_malloced) then
+ print *,'Memory exhausted.'
+ print *,'mem_malloced: ',mem_malloced,' memnxt ',memnxt,
+ * ' size requested ',element_size,'*',nwords
+ ierr = 1
+ return
+ endif
+
+c print *,'Task ',me,' memix, intsize = ',memix,intsize
+#ifdef ALTIX
+ addr1 = %loc(ishared_heap)
+#else
+ addr1 = c_loc64(membase, memix, intsize)
+#endif
+ addr2 = addr1 + memnxt
+ if (element_size .eq. 4) then
+ type = 1
+ else if (element_size .eq. 8) then
+ type = 2
+ else
+ print *,'MEM_ALLOC: invalid element size ',element_size
+ endif
+
+c print *,'Task ',me,' ADDR1, ADDR2 ',ADDR1,ADDR2
+#ifdef ALTIX
+ ixmem = get_index_from_base(addr2, ishared_heap, type)
+#else
+ ixmem = get_index_from_base(addr2, base, type)
+#endif
+c print *,'Task ',me,' IXMEM RETURNED FROM MEM_ALLOC: ',
+c * ixmem,' @base(ixmem) ',
+#ifdef ALTIX
+c * %loc(ishared_heap(ixmem)), %loc(dshared_heap(ixmem))
+#else
+c * c_loc64(base, ixmem, element_size)
+#endif
+ memnxt = memnxt + size
+c print *,'Task ',me,' New value of memnxt = ',memnxt
+
+ return
+ end
+
+ subroutine mem_alloc_init(mem_needed, sheap_flag, ierr)
+c------------------------------------------------------------------
+c Performs an actual malloc of the amount of memory needed. This
+c will only be done one time in the life of an execution, even
+c if we are called multiple times.
+c------------------------------------------------------------------
+ implicit none
+ include 'mem_alloc_data.h'
+ include 'machine_types.h'
+ include 'parallel_info.h'
+c include 'nothreads.h'
+#ifdef ALTIX
+ include 'sheap.h'
+#endif
+
+ integer mem_needed
+ integer nwords, ierr
+ integer*8 c_loc64
+ integer sheap_flag
+ integer*8 temp
+
+ logical first
+ save first
+
+ data first/.true./
+
+ ierr = 0
+
+ if (first) then
+ first = .false.
+
+ call init_machine_types() ! must be initialized.
+ temp = mem_needed * 1024
+ mem_malloced = temp * 1024
+
+ nwords = mem_malloced / intsize
+#ifdef ALTIX
+ call fallocate_it(sheap_flag, nwords, ierr )
+#else
+
+c--------------------------------------------------------------------------
+c "Normal" memory allocation via malloc.
+c-------------------------------------------------------------------------
+
+ call malloc_wrapper(nwords, intsize, sheap_flag,
+ * membase, memix, ierr)
+#endif
+
+ memnxt = 0
+c print *,'MEM_ALLOC_INIT: mem_needed ',mem_needed,
+c * ' mem_malloced ',mem_malloced
+c print *,'Task ',me,' MEM BASE ADDR :',
+#ifdef ALTIX
+c * ishptr
+#else
+c * c_loc64(membase,memix,intsize)
+#endif
+c print *,'Task ',me,
+c * ' memix at end of mem_alloc_init= ',memix
+ endif
+
+ return
+ end
+
+ subroutine mem_alloc_reset()
+c-----------------------------------------------------------------------
+c Resets the "next" pointer for the mem_alloc block.
+c----------------------------------------------------------------------
+ implicit none
+ include 'mem_alloc_data.h'
+
+ memnxt = 0
+ return
+ end
+
+ subroutine mem_alloc_query(nbused)
+c--------------------------------------------------------------------------
+c Returns the total bytes used so far.
+c--------------------------------------------------------------------------
+ implicit none
+ include 'mem_alloc_data.h'
+
+ integer*8 nbused
+ nbused = memnxt
+ return
+ end
+
+ integer*8 function get_mem_base_addr()
+ implicit none
+c--------------------------------------------------------------------------
+c Returns the address of the processor's heap memory.
+c--------------------------------------------------------------------------
+
+ include 'mem_alloc_data.h'
+ include 'machine_types.h'
+ integer*8 c_loc64
+
+#ifdef ALTIX
+ include 'sheap.h'
+
+ get_mem_base_addr = ishptr
+#else
+ get_mem_base_addr = c_loc64(membase, memix, intsize)
+#endif
+ return
+ end
+
+ subroutine mem_alloc_free(addr, ierr)
+c--------------------------------------------------------------------------
+c Reclaims all memory allocated beyond "addr" in mem_alloc_init.
+c This memory can then be claimed again via mem_alloc.
+c--------------------------------------------------------------------------
+ include 'mem_alloc_data.h'
+ include 'machine_types.h'
+#ifdef ALTIX
+ include 'sheap.h'
+#endif
+ integer*8 addr
+ integer ierr
+
+ integer*8 c_loc64, base
+
+ ierr = 0
+#ifdef ALTIX
+ base = %loc(ishared_heap)
+#else
+ base = c_loc64(membase, memix, intsize)
+#endif
+ if (addr .lt. base) then
+ print *,'Error in mem_alloc_free: called with addr ',
+ * addr,' but the base address is ',base
+ ierr = 1
+ endif
+ memnxt = addr - base
+ return
+ end
+
+ integer*8 function get_max_heap_usage()
+c--------------------------------------------------------------------------
+c Returns the number of bytes malloced for heap memory.
+c--------------------------------------------------------------------------
+ implicit none
+ include 'mem_alloc_data.h'
+
+ get_max_heap_usage = mem_malloced
+ return
+ end
--- /dev/null 2014-10-10 00:17:42.528636087 +0200
+++ ./src/sia/include/mem_alloc_data.h 2014-10-14 13:06:57.735842888 +0200
@@ -0,0 +1,4 @@
+ common /mem_alloc_data/memnxt, memix, mem_malloced, membase
+ integer*8 memnxt
+ integer*8 memix, mem_malloced
+ integer membase(1)
--- /dev/null 2014-10-10 00:17:42.528636087 +0200
+++ ./src/sia/sip_shared/malloc_wrapper.c 2014-10-14 13:21:03.656435546 +0200
@@ -0,0 +1,136 @@
+/*
+* Copyright (c) 2003-2010 University of Florida
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 2 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* The GNU General Public License is included in this distribution
+* in the file COPYRIGHT.
+*/
+#include <stdio.h>
+#include <stdlib.h>
+#include "f77_name.h"
+#include "f_types.h"
+#ifdef HP
+#include <stddef.h>
+#endif
+
+#ifdef ALTIX
+#include <mpp/shmem.h>
+#endif
+
+#define MAX_MEM_ALLOC_PTRS 1000
+f_int *malloced_pointers[MAX_MEM_ALLOC_PTRS];
+int malloced_len[MAX_MEM_ALLOC_PTRS];
+int n_malloced_pointers = 0;
+
+void F77_NAME(malloc_wrapper, MALLOC_WRAPPER)(f_int *nwords,
+ f_int *element_size, f_int *sheap_flag,
+ void *x, long long *ixmem,
+ f_int *ierr)
+{
+ size_t nbytes = (*nwords) * (*element_size);
+ size_t nb_shmalloc;
+ f_int *fp, *fp2;
+ long long llvar;
+#ifdef HP
+ ptrdiff_t offset;
+#else
+ long long offset;
+#endif
+
+ if (*sheap_flag)
+ {
+#ifdef USE_SHMEM
+ nb_shmalloc = (size_t) nbytes;
+ printf("Call shmalloc with %ld\n", nb_shmalloc);
+ fp = (f_int *) shmalloc(nb_shmalloc);
+ printf("Pointer from shmalloc: %x\n", fp);
+#else
+ printf("Error: shmalloc not implemented for this machine.\n");
+ *ierr = -1;
+ return;
+#endif
+ }
+ else
+ {
+ nbytes = (*nwords);
+ nbytes *= (*element_size);
+ nbytes += 8;
+
+ fp = (f_int *) malloc(nbytes);
+ }
+
+ if (!fp)
+ {
+ printf("(SH)MALLOC ERROR: nwords %d, element size %d\n",*nwords,
+ *element_size);
+ *ierr = -1;
+ return;
+ }
+
+ llvar = (long long) fp;
+ if (llvar/8*8 == llvar)
+ fp2 = fp;
+ else
+ fp2 = fp + 1;
+
+ /* Enter the memory pointer into the set of malloc'd pointers. */
+ if (n_malloced_pointers >= MAX_MEM_ALLOC_PTRS)
+ {
+ printf("Error: Limit of %d mem_alloc pointers has been exceeded.\n",
+ MAX_MEM_ALLOC_PTRS);
+ *ierr = -1;
+ return;
+ }
+
+ malloced_pointers[n_malloced_pointers] = fp;
+ malloced_len[n_malloced_pointers] = nbytes;
+ n_malloced_pointers++;
+
+ offset = ( fp2 - (f_int *) x);
+ *ixmem = (long long) (( fp2 - (f_int *) x) / (*element_size/sizeof(f_int)) + 1);
+ /* printf("malloc_wrapper: fp = %x %ld, address of x = %x %ld, ixmem = %ld\n",fp,fp,x,x,*ixmem); */
+
+ *ierr = 0;
+}
+
+void F77_NAME(free_mem_alloc, FREE_MEM_ALLOC) ()
+{
+ /* Frees all memory allocated by calls to mem_alloc */
+ int i;
+
+ for (i = 0; i < n_malloced_pointers; i++)
+ {
+ free( malloced_pointers[i] );
+ }
+
+ n_malloced_pointers = 0;
+}
+
+long long F77_NAME(c_loc64, C_LOC64)(char *base, long long *ix, f_int *size)
+{
+ long long addr;
+
+ addr = (long long) base + (*ix-1)*(*size);
+ /* printf("C_LOC64: base address %x %ld, ix %ld, size %d, addr %x %ld\n",
+ base,base,*ix,*size,addr,addr); */
+ return addr;
+}
+
+long long F77_NAME(c_loc64p, C_LOC64P)(char *base, long long *ix, f_int *size)
+{
+ long long addr;
+
+ addr = (long long) base + (*ix-1)*(*size);
+ return addr;
+}
+
+
|