libi3: change scalloc() signature to match calloc()
shdown
8 years ago
391 | 391 | } |
392 | 392 | } |
393 | 393 | if (walk != beginning) { |
394 | char *str = scalloc(walk - beginning + 1); | |
394 | char *str = scalloc(walk - beginning + 1, 1); | |
395 | 395 | /* We copy manually to handle escaping of characters. */ |
396 | 396 | int inpos, outpos; |
397 | 397 | for (inpos = 0, outpos = 0; |
76 | 76 | } |
77 | 77 | |
78 | 78 | static int reply_string_cb(void *params, const unsigned char *val, size_t len) { |
79 | char *str = scalloc(len + 1); | |
79 | char *str = scalloc(len + 1, 1); | |
80 | 80 | strncpy(str, (const char *)val, len); |
81 | 81 | if (strcmp(last_key, "error") == 0) |
82 | 82 | last_reply.error = str; |
104 | 104 | |
105 | 105 | static int reply_map_key_cb(void *params, const unsigned char *keyVal, size_t keyLen) { |
106 | 106 | free(last_key); |
107 | last_key = scalloc(keyLen + 1); | |
107 | last_key = scalloc(keyLen + 1, 1); | |
108 | 108 | strncpy(last_key, (const char *)keyVal, keyLen); |
109 | 109 | return 1; |
110 | 110 | } |
104 | 104 | va_start(args, format); |
105 | 105 | (void)vasprintf(&message, format, args); |
106 | 106 | |
107 | struct status_block *err_block = scalloc(sizeof(struct status_block)); | |
107 | struct status_block *err_block = scalloc(1, sizeof(struct status_block)); | |
108 | 108 | err_block->full_text = i3string_from_utf8("Error: "); |
109 | 109 | err_block->name = sstrdup("error"); |
110 | 110 | err_block->color = sstrdup("red"); |
111 | 111 | err_block->no_separator = true; |
112 | 112 | |
113 | struct status_block *message_block = scalloc(sizeof(struct status_block)); | |
113 | struct status_block *message_block = scalloc(1, sizeof(struct status_block)); | |
114 | 114 | message_block->full_text = i3string_from_utf8(message); |
115 | 115 | message_block->name = sstrdup("error_message"); |
116 | 116 | message_block->color = sstrdup("red"); |
432 | 432 | } else { |
433 | 433 | /* In case of plaintext, we just add a single block and change its |
434 | 434 | * full_text pointer later. */ |
435 | struct status_block *new_block = scalloc(sizeof(struct status_block)); | |
435 | struct status_block *new_block = scalloc(1, sizeof(struct status_block)); | |
436 | 436 | TAILQ_INSERT_TAIL(&statusline_head, new_block, blocks); |
437 | 437 | read_flat_input((char *)buffer, rec); |
438 | 438 | } |
145 | 145 | * users updating from that version and restarting i3bar before i3. */ |
146 | 146 | if (!strcmp(cur_key, "wheel_up_cmd")) { |
147 | 147 | DLOG("wheel_up_cmd = %.*s\n", len, val); |
148 | binding_t *binding = scalloc(sizeof(binding_t)); | |
148 | binding_t *binding = scalloc(1, sizeof(binding_t)); | |
149 | 149 | binding->input_code = 4; |
150 | 150 | sasprintf(&(binding->command), "%.*s", len, val); |
151 | 151 | TAILQ_INSERT_TAIL(&(config.bindings), binding, bindings); |
156 | 156 | * users updating from that version and restarting i3bar before i3. */ |
157 | 157 | if (!strcmp(cur_key, "wheel_down_cmd")) { |
158 | 158 | DLOG("wheel_down_cmd = %.*s\n", len, val); |
159 | binding_t *binding = scalloc(sizeof(binding_t)); | |
159 | binding_t *binding = scalloc(1, sizeof(binding_t)); | |
160 | 160 | binding->input_code = 5; |
161 | 161 | sasprintf(&(binding->command), "%.*s", len, val); |
162 | 162 | TAILQ_INSERT_TAIL(&(config.bindings), binding, bindings); |
276 | 276 | static int config_integer_cb(void *params_, long long val) { |
277 | 277 | if (parsing_bindings) { |
278 | 278 | if (strcmp(cur_key, "input_code") == 0) { |
279 | binding_t *binding = scalloc(sizeof(binding_t)); | |
279 | binding_t *binding = scalloc(1, sizeof(binding_t)); | |
280 | 280 | binding->input_code = val; |
281 | 281 | TAILQ_INSERT_TAIL(&(config.bindings), binding, bindings); |
282 | 282 |
532 | 532 | } |
533 | 533 | |
534 | 534 | const size_t len = namelen + strlen("workspace \"\"") + 1; |
535 | char *buffer = scalloc(len + num_quotes); | |
535 | char *buffer = scalloc(len + num_quotes, 1); | |
536 | 536 | strncpy(buffer, "workspace \"", strlen("workspace \"")); |
537 | 537 | size_t inpos, outpos; |
538 | 538 | for (inpos = 0, outpos = strlen("workspace \""); |
729 | 729 | values); |
730 | 730 | |
731 | 731 | /* send the XEMBED_EMBEDDED_NOTIFY message */ |
732 | void *event = scalloc(32); | |
732 | void *event = scalloc(32, 1); | |
733 | 733 | xcb_client_message_event_t *ev = event; |
734 | 734 | ev->response_type = XCB_CLIENT_MESSAGE; |
735 | 735 | ev->window = client; |
110 | 110 | * there is no more memory available) |
111 | 111 | * |
112 | 112 | */ |
113 | void *scalloc(size_t size); | |
113 | void *scalloc(size_t num, size_t size); | |
114 | 114 | |
115 | 115 | /** |
116 | 116 | * Safe-wrapper around realloc which exits if realloc returns NULL (meaning |
22 | 22 | /* Every X11 event is 32 bytes long. Therefore, XCB will copy 32 bytes. |
23 | 23 | * In order to properly initialize these bytes, we allocate 32 bytes even |
24 | 24 | * though we only need less for an xcb_configure_notify_event_t */ |
25 | void *event = scalloc(32); | |
25 | void *event = scalloc(32, 1); | |
26 | 26 | xcb_configure_notify_event_t *generated_event = event; |
27 | 27 | |
28 | 28 | generated_event->event = window; |
33 | 33 | err(EXIT_FAILURE, "glob() failed"); |
34 | 34 | } else { |
35 | 35 | head = globbuf.gl_pathv[0]; |
36 | result = scalloc(strlen(head) + (tail ? strlen(tail) : 0) + 1); | |
36 | result = scalloc(strlen(head) + (tail ? strlen(tail) : 0) + 1, 1); | |
37 | 37 | strncpy(result, head, strlen(head)); |
38 | 38 | if (tail) |
39 | 39 | strncat(result, tail, strlen(tail)); |
26 | 26 | return result; |
27 | 27 | } |
28 | 28 | |
29 | void *scalloc(size_t size) { | |
30 | void *result = calloc(size, 1); | |
29 | void *scalloc(size_t num, size_t size) { | |
30 | void *result = calloc(num, size); | |
31 | 31 | if (result == NULL) |
32 | err(EXIT_FAILURE, "calloc(%zd)", size); | |
32 | err(EXIT_FAILURE, "calloc(%zd, %zd)", num, size); | |
33 | 33 | return result; |
34 | 34 | } |
35 | 35 |
32 | 32 | * |
33 | 33 | */ |
34 | 34 | i3String *i3string_from_utf8(const char *from_utf8) { |
35 | i3String *str = scalloc(sizeof(i3String)); | |
35 | i3String *str = scalloc(1, sizeof(i3String)); | |
36 | 36 | |
37 | 37 | /* Get the text */ |
38 | 38 | str->utf8 = sstrdup(from_utf8); |
63 | 63 | * |
64 | 64 | */ |
65 | 65 | i3String *i3string_from_utf8_with_length(const char *from_utf8, size_t num_bytes) { |
66 | i3String *str = scalloc(sizeof(i3String)); | |
66 | i3String *str = scalloc(1, sizeof(i3String)); | |
67 | 67 | |
68 | 68 | /* Copy the actual text to our i3String */ |
69 | str->utf8 = scalloc(sizeof(char) * (num_bytes + 1)); | |
69 | str->utf8 = scalloc(num_bytes + 1, 1); | |
70 | 70 | strncpy(str->utf8, from_utf8, num_bytes); |
71 | 71 | str->utf8[num_bytes] = '\0'; |
72 | 72 | |
96 | 96 | * |
97 | 97 | */ |
98 | 98 | i3String *i3string_from_ucs2(const xcb_char2b_t *from_ucs2, size_t num_glyphs) { |
99 | i3String *str = scalloc(sizeof(i3String)); | |
99 | i3String *str = scalloc(1, sizeof(i3String)); | |
100 | 100 | |
101 | 101 | /* Copy the actual text to our i3String */ |
102 | size_t num_bytes = num_glyphs * sizeof(xcb_char2b_t); | |
103 | str->ucs2 = scalloc(num_bytes); | |
104 | memcpy(str->ucs2, from_ucs2, num_bytes); | |
102 | str->ucs2 = scalloc(num_glyphs, sizeof(xcb_char2b_t)); | |
103 | memcpy(str->ucs2, from_ucs2, num_glyphs * sizeof(xcb_char2b_t)); | |
105 | 104 | |
106 | 105 | /* Store the length */ |
107 | 106 | str->num_glyphs = num_glyphs; |
22 | 22 | */ |
23 | 23 | char *convert_ucs2_to_utf8(xcb_char2b_t *text, size_t num_glyphs) { |
24 | 24 | /* Allocate the output buffer (UTF-8 is at most 4 bytes per glyph) */ |
25 | size_t buffer_size = num_glyphs * 4 * sizeof(char) + 1; | |
26 | char *buffer = scalloc(buffer_size); | |
25 | size_t buffer_size = num_glyphs * 4 + 1; | |
26 | char *buffer = scalloc(buffer_size, 1); | |
27 | 27 | |
28 | 28 | /* We need to use an additional pointer, because iconv() modifies it */ |
29 | 29 | char *output = buffer; |
32 | 32 | } |
33 | 33 | |
34 | 34 | /* If the mode was not found, create a new one */ |
35 | mode = scalloc(sizeof(struct Mode)); | |
35 | mode = scalloc(1, sizeof(struct Mode)); | |
36 | 36 | mode->name = sstrdup(name); |
37 | mode->bindings = scalloc(sizeof(struct bindings_head)); | |
37 | mode->bindings = scalloc(1, sizeof(struct bindings_head)); | |
38 | 38 | TAILQ_INIT(mode->bindings); |
39 | 39 | SLIST_INSERT_HEAD(&modes, mode, modes); |
40 | 40 | |
50 | 50 | Binding *configure_binding(const char *bindtype, const char *modifiers, const char *input_code, |
51 | 51 | const char *release, const char *border, const char *whole_window, |
52 | 52 | const char *command, const char *modename) { |
53 | Binding *new_binding = scalloc(sizeof(Binding)); | |
53 | Binding *new_binding = scalloc(1, sizeof(Binding)); | |
54 | 54 | DLOG("bindtype %s, modifiers %s, input code %s, release %s\n", bindtype, modifiers, input_code, release); |
55 | 55 | new_binding->release = (release != NULL ? B_UPON_KEYRELEASE : B_UPON_KEYPRESS); |
56 | 56 | new_binding->border = (border != NULL); |
242 | 242 | if (*walk == beginning) |
243 | 243 | return NULL; |
244 | 244 | |
245 | char *str = scalloc(*walk - beginning + 1); | |
245 | char *str = scalloc(*walk - beginning + 1, 1); | |
246 | 246 | /* We copy manually to handle escaping of characters. */ |
247 | 247 | int inpos, outpos; |
248 | 248 | for (inpos = 0, outpos = 0; |
269 | 269 | CommandResult *parse_command(const char *input, yajl_gen gen) { |
270 | 270 | DLOG("COMMAND: *%s*\n", input); |
271 | 271 | state = INITIAL; |
272 | CommandResult *result = scalloc(sizeof(CommandResult)); | |
272 | CommandResult *result = scalloc(1, sizeof(CommandResult)); | |
273 | 273 | |
274 | 274 | /* A YAJL JSON generator used for formatting replies. */ |
275 | 275 | command_output.json_gen = gen; |
35 | 35 | * |
36 | 36 | */ |
37 | 37 | Con *con_new_skeleton(Con *parent, i3Window *window) { |
38 | Con *new = scalloc(sizeof(Con)); | |
38 | Con *new = scalloc(1, sizeof(Con)); | |
39 | 39 | new->on_remove_child = con_on_remove_child; |
40 | 40 | TAILQ_INSERT_TAIL(&all_cons, new, all_cons); |
41 | 41 | new->aspect_ratio = 0.0; |
57 | 57 | |
58 | 58 | /* initialize default bindings if we're just validating the config file */ |
59 | 59 | if (!use_nagbar && bindings == NULL) { |
60 | bindings = scalloc(sizeof(struct bindings_head)); | |
60 | bindings = scalloc(1, sizeof(struct bindings_head)); | |
61 | 61 | TAILQ_INIT(bindings); |
62 | 62 | } |
63 | 63 | |
154 | 154 | |
155 | 155 | SLIST_INIT(&modes); |
156 | 156 | |
157 | struct Mode *default_mode = scalloc(sizeof(struct Mode)); | |
157 | struct Mode *default_mode = scalloc(1, sizeof(struct Mode)); | |
158 | 158 | default_mode->name = sstrdup("default"); |
159 | default_mode->bindings = scalloc(sizeof(struct bindings_head)); | |
159 | default_mode->bindings = scalloc(1, sizeof(struct bindings_head)); | |
160 | 160 | TAILQ_INIT(default_mode->bindings); |
161 | 161 | SLIST_INSERT_HEAD(&modes, default_mode, modes); |
162 | 162 |
241 | 241 | return; |
242 | 242 | } |
243 | 243 | DLOG("\t should execute command %s for the criteria mentioned above\n", command); |
244 | Assignment *assignment = scalloc(sizeof(Assignment)); | |
244 | Assignment *assignment = scalloc(1, sizeof(Assignment)); | |
245 | 245 | assignment->type = A_COMMAND; |
246 | 246 | match_copy(&(assignment->match), current_match); |
247 | 247 | assignment->dest.command = sstrdup(command); |
399 | 399 | } |
400 | 400 | } |
401 | 401 | if (!duplicate) { |
402 | assignment = scalloc(sizeof(struct Workspace_Assignment)); | |
402 | assignment = scalloc(1, sizeof(struct Workspace_Assignment)); | |
403 | 403 | assignment->name = sstrdup(workspace); |
404 | 404 | assignment->output = sstrdup(output); |
405 | 405 | TAILQ_INSERT_TAIL(&ws_assignments, assignment, ws_assignments); |
457 | 457 | return; |
458 | 458 | } |
459 | 459 | DLOG("New assignment, using above criteria, to workspace \"%s\".\n", workspace); |
460 | Assignment *assignment = scalloc(sizeof(Assignment)); | |
460 | Assignment *assignment = scalloc(1, sizeof(Assignment)); | |
461 | 461 | match_copy(&(assignment->match), current_match); |
462 | 462 | assignment->type = A_TO_WORKSPACE; |
463 | 463 | assignment->dest.workspace = sstrdup(workspace); |
471 | 471 | } |
472 | 472 | |
473 | 473 | DLOG("New assignment, using above criteria, to ignore focus on manage.\n"); |
474 | Assignment *assignment = scalloc(sizeof(Assignment)); | |
474 | Assignment *assignment = scalloc(1, sizeof(Assignment)); | |
475 | 475 | match_copy(&(assignment->match), current_match); |
476 | 476 | assignment->type = A_NO_FOCUS; |
477 | 477 | TAILQ_INSERT_TAIL(&assignments, assignment, assignments); |
554 | 554 | } |
555 | 555 | } |
556 | 556 | |
557 | struct Barbinding *new_binding = scalloc(sizeof(struct Barbinding)); | |
557 | struct Barbinding *new_binding = scalloc(1, sizeof(struct Barbinding)); | |
558 | 558 | new_binding->input_code = input_code; |
559 | 559 | new_binding->command = sstrdup(command); |
560 | 560 | TAILQ_INSERT_TAIL(&(current_bar.bar_bindings), new_binding, bindings); |
668 | 668 | |
669 | 669 | /* Copy the current (static) structure into a dynamically allocated |
670 | 670 | * one, then cleanup our static one. */ |
671 | Barconfig *bar_config = scalloc(sizeof(Barconfig)); | |
671 | Barconfig *bar_config = scalloc(1, sizeof(Barconfig)); | |
672 | 672 | memcpy(bar_config, ¤t_bar, sizeof(Barconfig)); |
673 | 673 | TAILQ_INSERT_TAIL(&barconfigs, bar_config, configs); |
674 | 674 |
413 | 413 | } |
414 | 414 | } |
415 | 415 | if (walk != beginning) { |
416 | char *str = scalloc(walk - beginning + 1); | |
416 | char *str = scalloc(walk - beginning + 1, 1); | |
417 | 417 | /* We copy manually to handle escaping of characters. */ |
418 | 418 | int inpos, outpos; |
419 | 419 | for (inpos = 0, outpos = 0; |
518 | 518 | |
519 | 519 | /* Contains the same amount of characters as 'input' has, but with |
520 | 520 | * the unparseable part highlighted using ^ characters. */ |
521 | char *position = scalloc(strlen(error_line) + 1); | |
521 | char *position = scalloc(strlen(error_line) + 1, 1); | |
522 | 522 | const char *copywalk; |
523 | 523 | for (copywalk = error_line; |
524 | 524 | *copywalk != '\n' && *copywalk != '\r' && *copywalk != '\0'; |
848 | 848 | if (fstat(fd, &stbuf) == -1) |
849 | 849 | die("Could not fstat file: %s\n", strerror(errno)); |
850 | 850 | |
851 | buf = scalloc((stbuf.st_size + 1) * sizeof(char)); | |
851 | buf = scalloc(stbuf.st_size + 1, 1); | |
852 | 852 | |
853 | 853 | if ((fstr = fdopen(fd, "r")) == NULL) |
854 | 854 | die("Could not fdopen: %s\n", strerror(errno)); |
896 | 896 | while (*v_value == '\t' || *v_value == ' ') |
897 | 897 | v_value++; |
898 | 898 | |
899 | struct Variable *new = scalloc(sizeof(struct Variable)); | |
899 | struct Variable *new = scalloc(1, sizeof(struct Variable)); | |
900 | 900 | new->key = sstrdup(v_key); |
901 | 901 | new->value = sstrdup(v_value); |
902 | 902 | SLIST_INSERT_HEAD(&variables, new, variables); |
989 | 989 | } |
990 | 990 | } |
991 | 991 | |
992 | context = scalloc(sizeof(struct context)); | |
992 | context = scalloc(1, sizeof(struct context)); | |
993 | 993 | context->filename = f; |
994 | 994 | |
995 | 995 | struct ConfigResultIR *config_output = parse_config(new, context); |
48 | 48 | new_output->rect.width = min(new_output->rect.width, width); |
49 | 49 | new_output->rect.height = min(new_output->rect.height, height); |
50 | 50 | } else { |
51 | new_output = scalloc(sizeof(Output)); | |
51 | new_output = scalloc(1, sizeof(Output)); | |
52 | 52 | sasprintf(&(new_output->name), "fake-%d", num_screens); |
53 | 53 | DLOG("Created new fake output %s (%p)\n", new_output->name, new_output); |
54 | 54 | new_output->active = true; |
759 | 759 | uint32_t rnd = event->data.data32[1]; |
760 | 760 | DLOG("[i3 sync protocol] Sending random value %d back to X11 window 0x%08x\n", rnd, window); |
761 | 761 | |
762 | void *reply = scalloc(32); | |
762 | void *reply = scalloc(32, 1); | |
763 | 763 | xcb_client_message_event_t *ev = reply; |
764 | 764 | |
765 | 765 | ev->response_type = XCB_CLIENT_MESSAGE; |
83 | 83 | IPC_HANDLER(command) { |
84 | 84 | /* To get a properly terminated buffer, we copy |
85 | 85 | * message_size bytes out of the buffer */ |
86 | char *command = scalloc(message_size + 1); | |
86 | char *command = scalloc(message_size + 1, 1); | |
87 | 87 | strncpy(command, (const char *)message, message_size); |
88 | 88 | LOG("IPC: received: *%s*\n", command); |
89 | 89 | yajl_gen gen = yajl_gen_alloc(NULL); |
854 | 854 | |
855 | 855 | /* To get a properly terminated buffer, we copy |
856 | 856 | * message_size bytes out of the buffer */ |
857 | char *bar_id = scalloc(message_size + 1); | |
857 | char *bar_id = scalloc(message_size + 1, 1); | |
858 | 858 | strncpy(bar_id, (const char *)message, message_size); |
859 | 859 | LOG("IPC: looking for config for bar ID \"%s\"\n", bar_id); |
860 | 860 | Barconfig *current, *config = NULL; |
902 | 902 | client->events = realloc(client->events, client->num_events * sizeof(char *)); |
903 | 903 | /* We copy the string because it is not null-terminated and strndup() |
904 | 904 | * is missing on some BSD systems */ |
905 | client->events[event] = scalloc(len + 1); | |
905 | client->events[event] = scalloc(len + 1, 1); | |
906 | 906 | memcpy(client->events[event], s, len); |
907 | 907 | |
908 | 908 | DLOG("client is now subscribed to:\n"); |
1059 | 1059 | |
1060 | 1060 | set_nonblock(client); |
1061 | 1061 | |
1062 | struct ev_io *package = scalloc(sizeof(struct ev_io)); | |
1062 | struct ev_io *package = scalloc(1, sizeof(struct ev_io)); | |
1063 | 1063 | ev_io_init(package, ipc_receive_message, client, EV_READ); |
1064 | 1064 | ev_io_start(EV_A_ package); |
1065 | 1065 | |
1066 | 1066 | DLOG("IPC: new client connected on fd %d\n", w->fd); |
1067 | 1067 | |
1068 | ipc_client *new = scalloc(sizeof(ipc_client)); | |
1068 | ipc_client *new = scalloc(1, sizeof(ipc_client)); | |
1069 | 1069 | new->fd = client; |
1070 | 1070 | |
1071 | 1071 | TAILQ_INSERT_TAIL(&all_clients, new, clients); |
166 | 166 | static int json_key(void *ctx, const unsigned char *val, size_t len) { |
167 | 167 | LOG("key: %.*s\n", (int)len, val); |
168 | 168 | FREE(last_key); |
169 | last_key = scalloc((len + 1) * sizeof(char)); | |
169 | last_key = scalloc(len + 1, 1); | |
170 | 170 | memcpy(last_key, val, len); |
171 | 171 | if (strcasecmp(last_key, "swallows") == 0) |
172 | 172 | parsing_swallows = true; |
208 | 208 | free(sval); |
209 | 209 | } else { |
210 | 210 | if (strcasecmp(last_key, "name") == 0) { |
211 | json_node->name = scalloc((len + 1) * sizeof(char)); | |
211 | json_node->name = scalloc(len + 1, 1); | |
212 | 212 | memcpy(json_node->name, val, len); |
213 | 213 | } else if (strcasecmp(last_key, "sticky_group") == 0) { |
214 | json_node->sticky_group = scalloc((len + 1) * sizeof(char)); | |
214 | json_node->sticky_group = scalloc(len + 1, 1); | |
215 | 215 | memcpy(json_node->sticky_group, val, len); |
216 | 216 | LOG("sticky_group of this container is %s\n", json_node->sticky_group); |
217 | 217 | } else if (strcasecmp(last_key, "orientation") == 0) { |
360 | 360 | json_node->old_id = val; |
361 | 361 | |
362 | 362 | if (parsing_focus) { |
363 | struct focus_mapping *focus_mapping = scalloc(sizeof(struct focus_mapping)); | |
363 | struct focus_mapping *focus_mapping = scalloc(1, sizeof(struct focus_mapping)); | |
364 | 364 | focus_mapping->old_id = val; |
365 | 365 | TAILQ_INSERT_TAIL(&focus_mappings, focus_mapping, focus_mappings); |
366 | 366 | } |
634 | 634 | if (ipc_socket == -1) { |
635 | 635 | ELOG("Could not create the IPC socket, IPC disabled\n"); |
636 | 636 | } else { |
637 | struct ev_io *ipc_io = scalloc(sizeof(struct ev_io)); | |
637 | struct ev_io *ipc_io = scalloc(1, sizeof(struct ev_io)); | |
638 | 638 | ev_io_init(ipc_io, ipc_new_client, ipc_socket, EV_READ); |
639 | 639 | ev_io_start(main_loop, ipc_io); |
640 | 640 | } |
662 | 662 | ELOG("Could not disable FD_CLOEXEC on fd %d\n", fd); |
663 | 663 | } |
664 | 664 | |
665 | struct ev_io *ipc_io = scalloc(sizeof(struct ev_io)); | |
665 | struct ev_io *ipc_io = scalloc(1, sizeof(struct ev_io)); | |
666 | 666 | ev_io_init(ipc_io, ipc_new_client, fd, EV_READ); |
667 | 667 | ev_io_start(main_loop, ipc_io); |
668 | 668 | } |
678 | 678 | ewmh_update_desktop_names(); |
679 | 679 | ewmh_update_desktop_viewport(); |
680 | 680 | |
681 | struct ev_io *xcb_watcher = scalloc(sizeof(struct ev_io)); | |
682 | xcb_check = scalloc(sizeof(struct ev_check)); | |
683 | struct ev_prepare *xcb_prepare = scalloc(sizeof(struct ev_prepare)); | |
681 | struct ev_io *xcb_watcher = scalloc(1, sizeof(struct ev_io)); | |
682 | xcb_check = scalloc(1, sizeof(struct ev_check)); | |
683 | struct ev_prepare *xcb_prepare = scalloc(1, sizeof(struct ev_prepare)); | |
684 | 684 | |
685 | 685 | ev_io_init(xcb_watcher, xcb_got_event, xcb_get_file_descriptor(conn), EV_READ); |
686 | 686 | ev_io_start(main_loop, xcb_watcher); |
163 | 163 | |
164 | 164 | DLOG("Managing window 0x%08x\n", window); |
165 | 165 | |
166 | i3Window *cwindow = scalloc(sizeof(i3Window)); | |
166 | i3Window *cwindow = scalloc(1, sizeof(i3Window)); | |
167 | 167 | cwindow->id = window; |
168 | 168 | cwindow->depth = get_visual_depth(attr->visual); |
169 | 169 |
226 | 226 | void disable_randr(xcb_connection_t *conn) { |
227 | 227 | DLOG("RandR extension unusable, disabling.\n"); |
228 | 228 | |
229 | Output *s = scalloc(sizeof(Output)); | |
229 | Output *s = scalloc(1, sizeof(Output)); | |
230 | 230 | |
231 | 231 | s->active = true; |
232 | 232 | s->rect.x = 0; |
291 | 291 | topdock->type = CT_DOCKAREA; |
292 | 292 | topdock->layout = L_DOCKAREA; |
293 | 293 | /* this container swallows dock clients */ |
294 | Match *match = scalloc(sizeof(Match)); | |
294 | Match *match = scalloc(1, sizeof(Match)); | |
295 | 295 | match_init(match); |
296 | 296 | match->dock = M_DOCK_TOP; |
297 | 297 | match->insert_where = M_BELOW; |
325 | 325 | bottomdock->type = CT_DOCKAREA; |
326 | 326 | bottomdock->layout = L_DOCKAREA; |
327 | 327 | /* this container swallows dock clients */ |
328 | match = scalloc(sizeof(Match)); | |
328 | match = scalloc(1, sizeof(Match)); | |
329 | 329 | match_init(match); |
330 | 330 | match->dock = M_DOCK_BOTTOM; |
331 | 331 | match->insert_where = M_BELOW; |
521 | 521 | Output *new = get_output_by_id(id); |
522 | 522 | bool existing = (new != NULL); |
523 | 523 | if (!existing) |
524 | new = scalloc(sizeof(Output)); | |
524 | new = scalloc(1, sizeof(Output)); | |
525 | 525 | new->id = id; |
526 | 526 | new->primary = (primary && primary->output == id); |
527 | 527 | FREE(new->name); |
24 | 24 | const char *error; |
25 | 25 | int errorcode, offset; |
26 | 26 | |
27 | struct regex *re = scalloc(sizeof(struct regex)); | |
27 | struct regex *re = scalloc(1, sizeof(struct regex)); | |
28 | 28 | re->pattern = sstrdup(pattern); |
29 | 29 | int options = PCRE_UTF8; |
30 | 30 | #ifdef PCRE_HAS_UCP |
108 | 108 | if (restore_conn == NULL || xcb_connection_has_error(restore_conn)) |
109 | 109 | errx(EXIT_FAILURE, "Cannot open display\n"); |
110 | 110 | |
111 | xcb_watcher = scalloc(sizeof(struct ev_io)); | |
112 | xcb_check = scalloc(sizeof(struct ev_check)); | |
113 | xcb_prepare = scalloc(sizeof(struct ev_prepare)); | |
111 | xcb_watcher = scalloc(1, sizeof(struct ev_io)); | |
112 | xcb_check = scalloc(1, sizeof(struct ev_check)); | |
113 | xcb_prepare = scalloc(1, sizeof(struct ev_prepare)); | |
114 | 114 | |
115 | 115 | ev_io_init(xcb_watcher, restore_xcb_got_event, xcb_get_file_descriptor(restore_conn), EV_READ); |
116 | 116 | ev_io_start(main_loop, xcb_watcher); |
209 | 209 | DLOG("Created placeholder window 0x%08x for leaf container %p / %s\n", |
210 | 210 | placeholder, con, con->name); |
211 | 211 | |
212 | placeholder_state *state = scalloc(sizeof(placeholder_state)); | |
212 | placeholder_state *state = scalloc(1, sizeof(placeholder_state)); | |
213 | 213 | state->window = placeholder; |
214 | 214 | state->con = con; |
215 | 215 | state->rect = con->rect; |
148 | 148 | free(first_word); |
149 | 149 | |
150 | 150 | /* Trigger a timeout after 60 seconds */ |
151 | struct ev_timer *timeout = scalloc(sizeof(struct ev_timer)); | |
151 | struct ev_timer *timeout = scalloc(1, sizeof(struct ev_timer)); | |
152 | 152 | ev_timer_init(timeout, startup_timeout, 60.0, 0.); |
153 | 153 | timeout->data = context; |
154 | 154 | ev_timer_start(main_loop, timeout); |
158 | 158 | /* Save the ID and current workspace in our internal list of startup |
159 | 159 | * sequences */ |
160 | 160 | Con *ws = con_get_workspace(focused); |
161 | struct Startup_Sequence *sequence = scalloc(sizeof(struct Startup_Sequence)); | |
161 | struct Startup_Sequence *sequence = scalloc(1, sizeof(struct Startup_Sequence)); | |
162 | 162 | sequence->id = sstrdup(sn_launcher_context_get_startup_id(context)); |
163 | 163 | sequence->workspace = sstrdup(ws->name); |
164 | 164 | sequence->context = context; |
275 | 275 | int num_args; |
276 | 276 | for (num_args = 0; start_argv[num_args] != NULL; num_args++) |
277 | 277 | ; |
278 | char **new_argv = scalloc((num_args + 3) * sizeof(char *)); | |
278 | char **new_argv = scalloc(num_args + 3, sizeof(char *)); | |
279 | 279 | |
280 | 280 | /* copy the arguments, but skip the ones we'll replace */ |
281 | 281 | int write_index = 0; |
396 | 396 | if (focused->urgency_timer == NULL) { |
397 | 397 | DLOG("Deferring reset of urgency flag of con %p on newly shown workspace %p\n", |
398 | 398 | focused, workspace); |
399 | focused->urgency_timer = scalloc(sizeof(struct ev_timer)); | |
399 | focused->urgency_timer = scalloc(1, sizeof(struct ev_timer)); | |
400 | 400 | /* use a repeating timer to allow for easy resets */ |
401 | 401 | ev_timer_init(focused->urgency_timer, workspace_defer_update_urgent_hint_cb, |
402 | 402 | config.workspace_urgency_timer, config.workspace_urgency_timer); |
146 | 146 | if (win_colormap != XCB_NONE) |
147 | 147 | xcb_free_colormap(conn, win_colormap); |
148 | 148 | |
149 | struct con_state *state = scalloc(sizeof(struct con_state)); | |
149 | struct con_state *state = scalloc(1, sizeof(struct con_state)); | |
150 | 150 | state->id = con->frame; |
151 | 151 | state->mapped = false; |
152 | 152 | state->initial = true; |
285 | 285 | /* Every X11 event is 32 bytes long. Therefore, XCB will copy 32 bytes. |
286 | 286 | * In order to properly initialize these bytes, we allocate 32 bytes even |
287 | 287 | * though we only need less for an xcb_configure_notify_event_t */ |
288 | void *event = scalloc(32); | |
288 | void *event = scalloc(32, 1); | |
289 | 289 | xcb_client_message_event_t *ev = event; |
290 | 290 | |
291 | 291 | ev->response_type = XCB_CLIENT_MESSAGE; |
375 | 375 | return; |
376 | 376 | |
377 | 377 | /* 1: build deco_params and compare with cache */ |
378 | struct deco_render_params *p = scalloc(sizeof(struct deco_render_params)); | |
378 | struct deco_render_params *p = scalloc(1, sizeof(struct deco_render_params)); | |
379 | 379 | |
380 | 380 | /* find out which colors to use */ |
381 | 381 | if (con->urgent) |
113 | 113 | /* Every X11 event is 32 bytes long. Therefore, XCB will copy 32 bytes. |
114 | 114 | * In order to properly initialize these bytes, we allocate 32 bytes even |
115 | 115 | * though we only need less for an xcb_configure_notify_event_t */ |
116 | void *event = scalloc(32); | |
116 | void *event = scalloc(32, 1); | |
117 | 117 | xcb_client_message_event_t *ev = event; |
118 | 118 | |
119 | 119 | ev->response_type = XCB_CLIENT_MESSAGE; |
55 | 55 | s->rect.width = min(s->rect.width, screen_info[screen].width); |
56 | 56 | s->rect.height = min(s->rect.height, screen_info[screen].height); |
57 | 57 | } else { |
58 | s = scalloc(sizeof(Output)); | |
58 | s = scalloc(1, sizeof(Output)); | |
59 | 59 | sasprintf(&(s->name), "xinerama-%d", num_screens); |
60 | 60 | DLOG("Created new Xinerama screen %s (%p)\n", s->name, s); |
61 | 61 | s->active = true; |