I know it's not nice (I wrote a lot of broken code myself) but still can't stop laughing. Here's the reason, I hope writing this here will help me get to my senses (because as you know uncontrollable solitary laughing can be a sign of madness):
From the comment, it is supposed to turn class_name into all capital letters
But I think it has another problem also, so I need some feedback, because I don't know what to do with it. In my testing case class_name is part, so the problematic line translates into
Code:
s1 = class_name;
for (; *s1 != '\0'; s1++)
*s1 = tolower(*s1);
gclass_name = malloc(strlen(class_name) + 1);
if (gclass_name == NULL)
errx(EXIT_FAILURE, "No memory");
s1 = gclass_name;
s2 = class_name;
for (; *s2 != '\0'; s2++)
*s1++ = toupper(*s2);
*s1 = '\0';
But I think it has another problem also, so I need some feedback, because I don't know what to do with it. In my testing case class_name is part, so the problematic line translates into
gclass_name = malloc(5)
. This single line allocates 4100008 (sic! Almost 4 MiB) bytes of memory! Can it be considered a bug or is it intentional (but I can't even imagine any gclass_name 4MiB long)? With whom I should talk about it? (I filled another bug in gpart, but no one have responded even to dismiss it, so I guess that after the info from FreeBSD wiki I should contact some developer directly, but don't know exactly whom). Thanks in advance for any advice.