Skip to content

Instantly share code, notes, and snippets.

@maasha
Created December 12, 2014 11:44
Show Gist options
  • Save maasha/0520ce4ff6a319387de2 to your computer and use it in GitHub Desktop.
Save maasha/0520ce4ff6a319387de2 to your computer and use it in GitHub Desktop.
builder.c %{
void increment_C(
VALUE _count_ary, // Count ary.
VALUE _nodes_ary, // Nodes ary.
VALUE _length // Nodes ary length.
)
{
int *count_ary = (int *) StringValuePtr(_count_ary);
int *nodes_ary = (int *) StringValuePtr(_nodes_ary);
int length = FIX2INT(_length);
int i = 0;
for (i = length - 1; i >= 0; i--)
{
count_ary[nodes_ary[i]]++;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment