[Xcb-commit] xcb-demo/tests lissajoux.c,1.5,1.6
Bart Massey
xcb-commit at lists.freedesktop.org
Sat Dec 17 20:24:04 PST 2005
Update of /cvs/xcb/xcb-demo/tests
In directory gabe:/tmp/cvs-serv32163/tests
Modified Files:
lissajoux.c
Log Message:
Minor cleanups for readability etc
Index: lissajoux.c
===================================================================
RCS file: /cvs/xcb/xcb-demo/tests/lissajoux.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- lissajoux.c 11 Dec 2005 22:30:17 -0000 1.5
+++ lissajoux.c 18 Dec 2005 04:24:01 -0000 1.6
@@ -1,3 +1,5 @@
+#include <assert.h>
+
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
@@ -44,14 +46,20 @@
double x, y;
if (do_shm)
- XCBImageSHMGet (data.conn, data.draw,
- data.image, shminfo,
- 0, 0,
- AllPlanes);
+ {
+ i = XCBImageSHMGet (data.conn, data.draw,
+ data.image, shminfo,
+ 0, 0,
+ AllPlanes);
+ assert(i);
+ }
else
- data.image = XCBImageGet (data.conn, data.draw,
- 0, 0, W_W, W_H,
- AllPlanes, data.format);
+ {
+ data.image = XCBImageGet (data.conn, data.draw,
+ 0, 0, W_W, W_H,
+ AllPlanes, data.format);
+ assert(data.image);
+ }
pi = 3.1415926535897;
period = 2.0 * pi;
@@ -92,7 +100,7 @@
}
void
-loop (Data data)
+step (Data data)
{
loop_count++;
t = get_time () - time_start;
@@ -130,17 +138,20 @@
format = 0;
data.image = XCBImageSHMCreate (data.conn, data.depth,
format, NULL, W_W, W_H);
+ assert(data.image);
shminfo.shmid = shmget (IPC_PRIVATE,
data.image->bytes_per_line*data.image->height,
IPC_CREAT | 0777);
+ assert(shminfo.shmid != -1);
shminfo.shmaddr = shmat (shminfo.shmid, 0, 0);
+ assert(shminfo.shmaddr);
data.image->data = shminfo.shmaddr;
shminfo.shmseg = XCBShmSEGNew (data.conn);
XCBShmAttach (data.conn, shminfo.shmseg,
shminfo.shmid, 0);
- shmctl(shminfo.shmid, IPC_RMID, 0);
+ assert(shmctl(shminfo.shmid, IPC_RMID, 0) != -1);
}
if (data.image)
@@ -227,8 +238,6 @@
W_W, W_H);
XCBPolyFillRectangle(data.conn, rect, bgcolor, 1, &rect_coord);
- XCBMapWindow (data.conn, data.draw.window);
-
data.format = ZPixmap;
XCBSync (data.conn, 0);
@@ -243,21 +252,18 @@
if (e)
{
switch (e->response_type)
- {
+ {
case XCBExpose:
- {
- XCBCopyArea(data.conn, rect, data.draw, bgcolor,
- 0, 0, 0, 0, W_W, W_H);
- XCBSync (data.conn, 0);
- break;
- }
+ XCBCopyArea(data.conn, rect, data.draw, bgcolor,
+ 0, 0, 0, 0, W_W, W_H);
+ XCBSync (data.conn, 0);
+ break;
}
free (e);
- }
- loop (data);
+ }
+ step (data);
XCBFlush (data.conn);
t_previous = t;
}
-
- return 1;
+ /*NOTREACHED*/
}
More information about the xcb-commit
mailing list