---

> >>> I can at least imagine cases where quitting on allocation failure is not
> >>> good.  For example dwm is running, a new client starting up, but there is
> >>> no memory left for the client struct. In this case dwm should just print
> >>> an error, but not quit to give the user the chance to fix the problem
> >>> without losing all their work in the other clients (which would die as
> >>> well, if dwm dies and the X-Server quits).
> >>
> >> I agree it should either die completely or give a very clear error message.
> >
> > I'll make a patch for dwm.
> 
> No need anymore :)

Heyho Hiltjo,

that is what I meant. I'm not sure if it's the best idea to just ignore the new
client. Maybe there is a way we can tell the X-Server that we refuse to manage
this client?

--Markus


 dwm.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/dwm.c b/dwm.c
index 0afd630..47aaf3c 100644
--- a/dwm.c
+++ b/dwm.c
@@ -1024,7 +1024,10 @@ manage(Window w, XWindowAttributes *wa)
        Window trans = None;
        XWindowChanges wc;
 
-       c = ecalloc(1, sizeof(Client));
+       if (!(c = calloc(1, sizeof(Client)))) {
+               perror("dwm: calloc in manage()");
+               return;
+       }
        c->win = w;
        /* geometry */
        c->x = c->oldx = wa->x;
-- 
2.7.3


Reply via email to