Christian Mauderer commented on a discussion on misc/bin2c/rtems-bin2c.c: 
https://gitlab.rtems.org/rtems/tools/rtems-tools/-/merge_requests/58#note_121520

 >        exit(1);
 >      }
 >    }
 > +  
 > +  /* Read license header if specified */
 > +  char *license_header = NULL;
 > +  if (licensefile) {
 > +    license_header = read_license_file(licensefile);
 > +  } else if (usebsdlicense) {
 > +    license_header = strdup(

Sorry, I haven't been clear here. It was more a question than a request to 
change something. If you assign the constant string, the `free(license_header)` 
will make problems later. So the original solution was better than the change.

There are at least three possible solutions:

- Using `strdup` like you did in your original approach.
- Using a constant string and only `free` the pointer if it is not pointing to 
that string.
- Keeping the `license_header` on NULL and decide later to write a constant 
string instead of the `license_header`.

All have advantages and disadvantages. I just wanted to know why you picked the 
approach that you did.

-- 
View it on GitLab: 
https://gitlab.rtems.org/rtems/tools/rtems-tools/-/merge_requests/58#note_121520
You're receiving this email because of your account on gitlab.rtems.org.


_______________________________________________
bugs mailing list
bugs@rtems.org
http://lists.rtems.org/mailman/listinfo/bugs

Reply via email to