Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- #include <X11/Xlib.h>
- static Window** box; /* box (NYxNX) window array address */
- static Window* row; /* NY row window box containe array */
- static unsigned NX=4; /* Default Boxes' number in each row */
- static unsigned NY=2; /* Default Row's number in game desk */
- /* dynamic memory allocation for all game desk array */
- int alloc() {
- void* r; /* row array pointer */
- void** b; /* box array pointer */
- int i; /* row array index */
- r = calloc(NY, sizeof(unsigned long));
- b = calloc(NY, sizeof(void*));
- for(i=0; i < NY; i++) {
- b[i] = calloc(NX, sizeof(unsigned long));
- }
- row = (Window* ) r;
- box = (Window**) b;
- return(0);
- }
- /* free allocated memory */
- int dealloc(Window** b, Window* r) {
- int i; /* row index */
- for(i=0; i < NY; i++) {
- free(b[i]);
- }
- free(b); free(r);
- return(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement