##- # Author: Brian Tiffin # Dedicated to the public domain # # Date started: January 2017 # Modified: 2017-01-08/13:12-0500 ##+ # # unilist.icn, demonstrate heterogeneous lists from loadfunc # # tectonics: # gcc -o unilist.so -shared -fPIC unilist.c # procedure main() allocated() unilist := loadfunc("./unilist.so", "unilist") # pass in an empty list, and limit on random string length L := [] limit := 32 # do a reasonably fat pass every i := 1 to 1000 do { rc := unilist(L, limit) L := put(L, rc) } write(i, " ", image(L)) # dump out the first 10 triplets every i := 1 to 30 by 3 do write(left(L[i+2], 3), left(":" || L[i] || ":", limit+2), L[i + 1]) allocated() end # Display current memory region allocations procedure allocated() local allocs allocs := [] ; every put(allocs, &allocated) write() write("&allocated") write("----------") write("Heap : ", allocs[1]) write("Static : ", allocs[2]) write("String : ", allocs[3]) write("Block : ", allocs[4]) write() end