-
Notifications
You must be signed in to change notification settings - Fork 935
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add utstring_release #95
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -121,6 +121,25 @@ do { \ | |
|
||
#define utstring_body(s) ((s)->d) | ||
|
||
#define utstring_adopt(s,b,l) \ | ||
do { \ | ||
if (s) { \ | ||
(s)->d = (b); \ | ||
(s)->n = (l); \ | ||
(s)->i = (l); \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @troydhanson, in the codebases where you've needed this function in the past, would this have sufficed? Or should it be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It needs a tweak. The other "put" functions ( One way to preserve that notion, is to switch s->i = strlen(d); s->n = s->i +1 ; The problem with the current three-parameter adopt is that the caller can pass a non-terminated string, breaking the expectation that utstring always has a We can switch to the four-parameter version There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @tbeu: Sorry! I think what happened here was that the feedback I was awaiting on 2016-12-15 did arrive, in the form of Troy's comment on 2016-12-16. And then I never explicitly said "@tbeu please address this," but I also never really bothered (AFAIR) to figure out whether I even agreed with what Troy said, either. I suggest that at this point, with many outdated review comments and some pieces of this patch merged already, the best thing to do would be to close this PR and (if you still want the feature merged) open a fresh PR. Do you have any thoughts on the desirability of |
||
} \ | ||
} while(0) | ||
|
||
#define utstring_disown(s,b) \ | ||
do { \ | ||
if (s) { \ | ||
(b) = (s)->d; \ | ||
(s)->d = NULL; \ | ||
(s)->i = 0; \ | ||
(s)->n = 0; \ | ||
} \ | ||
} while(0) | ||
|
||
_UNUSED_ static void utstring_printf_va(UT_string *s, const char *fmt, va_list ap) { | ||
int n; | ||
va_list cp; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I'll take these diffs to the existing docs upstream right now (hopefully in a way that merges cleanly with this PR).