- if (pin_names[namestr] != NULL)
- free(pin_names[namestr]);
- memset(pin_names, 0, sizeof(pin_names));
- pin_names_width = 0;
-
-/* TODO: enters endless loop on wron parameters */
-
- if ((lp = getenv(PSTR(ENV_PINALIAS))) != NULL) {
- pin_names[namestr] = strdup(lp);
- ptr = strtok_P(pin_names[namestr], delim1);
- while (ptr != NULL) {
- if (((i = strtoul(ptr, &lp, 10)) < GPIO_MAX) &&
- lp != ptr &&
- (ptr = strtok_P(NULL, delim2)) != NULL ) {
- pin_names[i] = ptr;
- ptr = strtok_P(NULL, delim1);
+ memset(pin_names, 0, (GPIO_MAX+1) * sizeof(char *));
+
+/* TODO: enters endless loop on wrong parameters */
+
+ lp = getenv_str(PSTR(ENV_PINALIAS));
+ if (lp != NULL) {
+ pin_names[GPIO_MAX] = strdup(lp);
+ if (pin_names[GPIO_MAX] != NULL) {
+ char *ptr = strtok_P(pin_names[GPIO_MAX], delim1);
+ while (ptr != NULL) {
+ if (((i = strtoul(ptr, &lp, 10)) < GPIO_MAX) &&
+ lp != ptr &&
+ (ptr = strtok_P(NULL, delim2)) != NULL ) {
+ pin_names[i] = ptr;
+ ptr = strtok_P(NULL, delim1);
+ }