Prevent crash when registering a toggle.

It was counting one too many arguments, which would lead to a segfault
when parsing the last command.
Plug memory leak when removing a toggle.
It's valid to pass a NULL pointer to realloc.

According to ANSI C it will behave like malloc. Take advantage of this
and save a few lines.