This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
New changes in arrays
- From: Martin Hunt <hunt at redhat dot com>
- To: "systemtap at sources dot redhat dot com" <systemtap at sources dot redhat dot com>
- Date: Wed, 10 Jan 2007 10:38:36 -0500
- Subject: New changes in arrays
- Organization: Red Hat Inc.
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