grady@postgres (Steven Grady) (04/09/88)
Many people have pointed out my stupid mistake in the bounce program I posted a couple days ago. I had just changed the code to allow an abitrary number of windows, rather then a fixed maximum, but I forgot to cast the result of the malloc. The stupid thing is that I somehow missed the warnings from the compiler. Anyway, here's the patch: *** bounce.c.old Fri Apr 8 12:08:08 1988 --- bounce.c Fri Apr 8 12:09:33 1988 *************** *** 145,152 **** XQueryTree(dpy, DefaultRootWindow(dpy), &root, &par, &children, &n); /* Malloc() never fails. Heh heh.. */ ! windows = malloc(n * sizeof(*windows)); ! savedwins = malloc(n * sizeof(*savedwins)); for (i = 0, j = 0; i < n; i++) { XGetWindowAttributes(dpy, children[i], &winf); if (winf.map_state == IsViewable) { --- 145,152 ---- XQueryTree(dpy, DefaultRootWindow(dpy), &root, &par, &children, &n); /* Malloc() never fails. Heh heh.. */ ! windows = (struct window *) malloc(n * sizeof(*windows)); ! savedwins = (struct window *) malloc(n * sizeof(*savedwins)); for (i = 0, j = 0; i < n; i++) { XGetWindowAttributes(dpy, children[i], &winf); if (winf.map_state == IsViewable) { Steven grady@postgres.berkeley.edu ...!ucbvax!grady