This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

New changes in arrays


I've checked in a minor change to how arrays work. This probably won't
break any scripts, but it might. You should also be aware of the change
because it can make some scripts simpler.

In the past setting an array element to 0 or "" internally deleted it.
Now it keeps the element and simply sets its value. The only difference
this makes to scripts is when "foreach" is used to iterate through the
elements of a list or when testing for membership.

Examples:

for (i=0;i<11;i++)
  foo[i] = i*i
foreach (i in foo)
  printf("foo[%d] = %d\n", i, foo[i])

This previously would have printed "foo[1] = 1 ..." but now it starts
with "foo[0] = 0 ..."

To remove an element from an array and free up its memory, you must use
"delete". That has always worked, but you used to also be able to set
the element to 0 or an empty string. If you see code that sets array
elements to 0 or "", you probably want to update it.

Martin





Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]