[PATCH V2]: Re: [PATCH 1/1] Don't check for NULL before xfree()

2012-06-03 Thread Thomas Adam
On Sun, Jun 03, 2012 at 01:21:47PM +0100, Thomas Adam wrote: The C standard dictates that calling free(NULL) is a no-op. So we can safely assume this to be OK. I'm a disaster. I forgot to include some files. Oops. Here's V2, attached. -- Thomas Adam -- Deep in my heart I wish I was

[PATCH 03/14] Convert choose-session to use window_choose_ctx()

2012-06-03 Thread Thomas Adam
Switch the callback of this command to use the centralised window_choose_ctx function. --- trunk/cmd-choose-session.c | 40 ++-- 1 file changed, 6 insertions(+), 34 deletions(-) diff --git a/trunk/cmd-choose-session.c b/trunk/cmd-choose-session.c index

[PATCH 10/14] Convert choose-buffer to use window_choose_data

2012-06-03 Thread Thomas Adam
--- trunk/cmd-choose-buffer.c | 47 + 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/trunk/cmd-choose-buffer.c b/trunk/cmd-choose-buffer.c index 3e803f8..f55e565 100644 --- a/trunk/cmd-choose-buffer.c +++ b/trunk/cmd-choose-buffer.c

[PATCH 04/14] Convert choose-window to use window_choose_ctx()

2012-06-03 Thread Thomas Adam
Switch the callback of this command to use the centralised window_choose_ctx function. --- trunk/cmd-choose-window.c | 44 ++-- 1 file changed, 6 insertions(+), 38 deletions(-) diff --git a/trunk/cmd-choose-window.c b/trunk/cmd-choose-window.c index

[PATCH 13/14] Convert choose-window to use window_choose_data

2012-06-03 Thread Thomas Adam
--- trunk/cmd-choose-window.c | 63 +++-- 1 file changed, 32 insertions(+), 31 deletions(-) diff --git a/trunk/cmd-choose-window.c b/trunk/cmd-choose-window.c index 8ac0f0c..c4c 100644 --- a/trunk/cmd-choose-window.c +++ b/trunk/cmd-choose-window.c

[PATCH 12/14] Convert choose-session to use window_choose_data

2012-06-03 Thread Thomas Adam
--- trunk/cmd-choose-session.c | 56 +++- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/trunk/cmd-choose-session.c b/trunk/cmd-choose-session.c index 1a7fc12..8931141 100644 --- a/trunk/cmd-choose-session.c +++

[PATCH 00/14] Rework choose-mode internals.

2012-06-03 Thread Thomas Adam
This patch series reworks the choose-mode internals to stop using a literal u_int for identifying chosen elements to some data structure, and instead returns a pointer to a struct. Currently the choose-* commands are returned a u_int representing either a window or session or some other index

[PATCH 14/14] Convert find-window to use window_choose_data

2012-06-03 Thread Thomas Adam
--- trunk/cmd-find-window.c | 56 ++- 1 file changed, 26 insertions(+), 30 deletions(-) diff --git a/trunk/cmd-find-window.c b/trunk/cmd-find-window.c index ff8405f..88f84e7 100644 --- a/trunk/cmd-find-window.c +++ b/trunk/cmd-find-window.c @@ -30,8

[PATCH 02/14] Convert choose-buffer to use window_choose_ctx()

2012-06-03 Thread Thomas Adam
Switch the callback of this command to use the centralised window_choose_ctx function. --- trunk/cmd-choose-buffer.c | 37 ++--- 1 file changed, 6 insertions(+), 31 deletions(-) diff --git a/trunk/cmd-choose-buffer.c b/trunk/cmd-choose-buffer.c index

[PATCH 11/14] Convert choose-client to use window_choose_data

2012-06-03 Thread Thomas Adam
--- trunk/cmd-choose-client.c | 87 + 1 file changed, 32 insertions(+), 55 deletions(-) diff --git a/trunk/cmd-choose-client.c b/trunk/cmd-choose-client.c index 5ae882d..7ca4346 100644 --- a/trunk/cmd-choose-client.c +++ b/trunk/cmd-choose-client.c

Re: [PATCH 0/1] xfree(NULL) is a no-op when calling free(NULL)

2012-06-03 Thread Thomas Adam
Hi, On 3 June 2012 19:44, Nicholas Marriott nicholas.marri...@gmail.com wrote: It isn't there to be defensive, free(NULL) of course is always guaranteed to be safe. It's a deliberate aid to writing correct code, you should know where your null pointers are. Whether it actually helps or not is

Re: [PATCH 0/1] xfree(NULL) is a no-op when calling free(NULL)

2012-06-03 Thread Nicholas Marriott
There are 300-odd calls to xfree in tmux and it looks like only about 50 have a check. Those are the ones where we explicitly know that NULL is a possibility. I don't think it adds much work to do this, I just don't know if it actually helps to catch bugs or document anything. On Sun, Jun 03,

Re: [PATCH 0/1] xfree(NULL) is a no-op when calling free(NULL)

2012-06-03 Thread Thomas Adam
Hi, On 3 June 2012 20:19, Nicholas Marriott nicholas.marri...@gmail.com wrote: There are 300-odd calls to xfree in tmux and it looks like only about 50 have a check. Those are the ones where we explicitly know that NULL is a possibility. I don't think it adds much work to do this, I just don't

Re: [PATCH 0/1] xfree(NULL) is a no-op when calling free(NULL)

2012-06-03 Thread Nicholas Marriott
It forces you to think about the lifetime of what you are freeing rather than just doing it. Remembering to add them in is not a problem, because it is a fatal error if you forget... that's an easy bug to spot :-). On Sun, Jun 03, 2012 at 08:23:46PM +0100, Thomas Adam wrote: Hi, On 3 June

Re: [PATCH 0/1] xfree(NULL) is a no-op when calling free(NULL)

2012-06-03 Thread Nicholas Marriott
Also it's handy to be able to instrument free without a lot of faffing around (I used to have code to instrument it). Still, none of the advantages are particularly compelling so I'm leaning towards making this change, let me think about it... On Sun, Jun 03, 2012 at 09:13:53PM +0100, Nicholas