Codebase list i3-gaps / bc52fae
libi3: change scalloc() signature to match calloc() shdown 8 years ago
32 changed file(s) with 80 addition(s) and 81 deletion(s). Raw diff Collapse all Expand all
391391 }
392392 }
393393 if (walk != beginning) {
394 char *str = scalloc(walk - beginning + 1);
394 char *str = scalloc(walk - beginning + 1, 1);
395395 /* We copy manually to handle escaping of characters. */
396396 int inpos, outpos;
397397 for (inpos = 0, outpos = 0;
7676 }
7777
7878 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);
8080 strncpy(str, (const char *)val, len);
8181 if (strcmp(last_key, "error") == 0)
8282 last_reply.error = str;
104104
105105 static int reply_map_key_cb(void *params, const unsigned char *keyVal, size_t keyLen) {
106106 free(last_key);
107 last_key = scalloc(keyLen + 1);
107 last_key = scalloc(keyLen + 1, 1);
108108 strncpy(last_key, (const char *)keyVal, keyLen);
109109 return 1;
110110 }
104104 va_start(args, format);
105105 (void)vasprintf(&message, format, args);
106106
107 struct status_block *err_block = scalloc(sizeof(struct status_block));
107 struct status_block *err_block = scalloc(1, sizeof(struct status_block));
108108 err_block->full_text = i3string_from_utf8("Error: ");
109109 err_block->name = sstrdup("error");
110110 err_block->color = sstrdup("red");
111111 err_block->no_separator = true;
112112
113 struct status_block *message_block = scalloc(sizeof(struct status_block));
113 struct status_block *message_block = scalloc(1, sizeof(struct status_block));
114114 message_block->full_text = i3string_from_utf8(message);
115115 message_block->name = sstrdup("error_message");
116116 message_block->color = sstrdup("red");
432432 } else {
433433 /* In case of plaintext, we just add a single block and change its
434434 * 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));
436436 TAILQ_INSERT_TAIL(&statusline_head, new_block, blocks);
437437 read_flat_input((char *)buffer, rec);
438438 }
145145 * users updating from that version and restarting i3bar before i3. */
146146 if (!strcmp(cur_key, "wheel_up_cmd")) {
147147 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));
149149 binding->input_code = 4;
150150 sasprintf(&(binding->command), "%.*s", len, val);
151151 TAILQ_INSERT_TAIL(&(config.bindings), binding, bindings);
156156 * users updating from that version and restarting i3bar before i3. */
157157 if (!strcmp(cur_key, "wheel_down_cmd")) {
158158 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));
160160 binding->input_code = 5;
161161 sasprintf(&(binding->command), "%.*s", len, val);
162162 TAILQ_INSERT_TAIL(&(config.bindings), binding, bindings);
276276 static int config_integer_cb(void *params_, long long val) {
277277 if (parsing_bindings) {
278278 if (strcmp(cur_key, "input_code") == 0) {
279 binding_t *binding = scalloc(sizeof(binding_t));
279 binding_t *binding = scalloc(1, sizeof(binding_t));
280280 binding->input_code = val;
281281 TAILQ_INSERT_TAIL(&(config.bindings), binding, bindings);
282282
532532 }
533533
534534 const size_t len = namelen + strlen("workspace \"\"") + 1;
535 char *buffer = scalloc(len + num_quotes);
535 char *buffer = scalloc(len + num_quotes, 1);
536536 strncpy(buffer, "workspace \"", strlen("workspace \""));
537537 size_t inpos, outpos;
538538 for (inpos = 0, outpos = strlen("workspace \"");
729729 values);
730730
731731 /* send the XEMBED_EMBEDDED_NOTIFY message */
732 void *event = scalloc(32);
732 void *event = scalloc(32, 1);
733733 xcb_client_message_event_t *ev = event;
734734 ev->response_type = XCB_CLIENT_MESSAGE;
735735 ev->window = client;
110110 * there is no more memory available)
111111 *
112112 */
113 void *scalloc(size_t size);
113 void *scalloc(size_t num, size_t size);
114114
115115 /**
116116 * Safe-wrapper around realloc which exits if realloc returns NULL (meaning
2222 /* Every X11 event is 32 bytes long. Therefore, XCB will copy 32 bytes.
2323 * In order to properly initialize these bytes, we allocate 32 bytes even
2424 * though we only need less for an xcb_configure_notify_event_t */
25 void *event = scalloc(32);
25 void *event = scalloc(32, 1);
2626 xcb_configure_notify_event_t *generated_event = event;
2727
2828 generated_event->event = window;
3333 err(EXIT_FAILURE, "glob() failed");
3434 } else {
3535 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);
3737 strncpy(result, head, strlen(head));
3838 if (tail)
3939 strncat(result, tail, strlen(tail));
2626 return result;
2727 }
2828
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);
3131 if (result == NULL)
32 err(EXIT_FAILURE, "calloc(%zd)", size);
32 err(EXIT_FAILURE, "calloc(%zd, %zd)", num, size);
3333 return result;
3434 }
3535
3232 *
3333 */
3434 i3String *i3string_from_utf8(const char *from_utf8) {
35 i3String *str = scalloc(sizeof(i3String));
35 i3String *str = scalloc(1, sizeof(i3String));
3636
3737 /* Get the text */
3838 str->utf8 = sstrdup(from_utf8);
6363 *
6464 */
6565 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));
6767
6868 /* Copy the actual text to our i3String */
69 str->utf8 = scalloc(sizeof(char) * (num_bytes + 1));
69 str->utf8 = scalloc(num_bytes + 1, 1);
7070 strncpy(str->utf8, from_utf8, num_bytes);
7171 str->utf8[num_bytes] = '\0';
7272
9696 *
9797 */
9898 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));
100100
101101 /* 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));
105104
106105 /* Store the length */
107106 str->num_glyphs = num_glyphs;
2222 */
2323 char *convert_ucs2_to_utf8(xcb_char2b_t *text, size_t num_glyphs) {
2424 /* 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);
2727
2828 /* We need to use an additional pointer, because iconv() modifies it */
2929 char *output = buffer;
3232 }
3333
3434 /* If the mode was not found, create a new one */
35 mode = scalloc(sizeof(struct Mode));
35 mode = scalloc(1, sizeof(struct Mode));
3636 mode->name = sstrdup(name);
37 mode->bindings = scalloc(sizeof(struct bindings_head));
37 mode->bindings = scalloc(1, sizeof(struct bindings_head));
3838 TAILQ_INIT(mode->bindings);
3939 SLIST_INSERT_HEAD(&modes, mode, modes);
4040
5050 Binding *configure_binding(const char *bindtype, const char *modifiers, const char *input_code,
5151 const char *release, const char *border, const char *whole_window,
5252 const char *command, const char *modename) {
53 Binding *new_binding = scalloc(sizeof(Binding));
53 Binding *new_binding = scalloc(1, sizeof(Binding));
5454 DLOG("bindtype %s, modifiers %s, input code %s, release %s\n", bindtype, modifiers, input_code, release);
5555 new_binding->release = (release != NULL ? B_UPON_KEYRELEASE : B_UPON_KEYPRESS);
5656 new_binding->border = (border != NULL);
242242 if (*walk == beginning)
243243 return NULL;
244244
245 char *str = scalloc(*walk - beginning + 1);
245 char *str = scalloc(*walk - beginning + 1, 1);
246246 /* We copy manually to handle escaping of characters. */
247247 int inpos, outpos;
248248 for (inpos = 0, outpos = 0;
269269 CommandResult *parse_command(const char *input, yajl_gen gen) {
270270 DLOG("COMMAND: *%s*\n", input);
271271 state = INITIAL;
272 CommandResult *result = scalloc(sizeof(CommandResult));
272 CommandResult *result = scalloc(1, sizeof(CommandResult));
273273
274274 /* A YAJL JSON generator used for formatting replies. */
275275 command_output.json_gen = gen;
3535 *
3636 */
3737 Con *con_new_skeleton(Con *parent, i3Window *window) {
38 Con *new = scalloc(sizeof(Con));
38 Con *new = scalloc(1, sizeof(Con));
3939 new->on_remove_child = con_on_remove_child;
4040 TAILQ_INSERT_TAIL(&all_cons, new, all_cons);
4141 new->aspect_ratio = 0.0;
5757
5858 /* initialize default bindings if we're just validating the config file */
5959 if (!use_nagbar && bindings == NULL) {
60 bindings = scalloc(sizeof(struct bindings_head));
60 bindings = scalloc(1, sizeof(struct bindings_head));
6161 TAILQ_INIT(bindings);
6262 }
6363
154154
155155 SLIST_INIT(&modes);
156156
157 struct Mode *default_mode = scalloc(sizeof(struct Mode));
157 struct Mode *default_mode = scalloc(1, sizeof(struct Mode));
158158 default_mode->name = sstrdup("default");
159 default_mode->bindings = scalloc(sizeof(struct bindings_head));
159 default_mode->bindings = scalloc(1, sizeof(struct bindings_head));
160160 TAILQ_INIT(default_mode->bindings);
161161 SLIST_INSERT_HEAD(&modes, default_mode, modes);
162162
241241 return;
242242 }
243243 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));
245245 assignment->type = A_COMMAND;
246246 match_copy(&(assignment->match), current_match);
247247 assignment->dest.command = sstrdup(command);
399399 }
400400 }
401401 if (!duplicate) {
402 assignment = scalloc(sizeof(struct Workspace_Assignment));
402 assignment = scalloc(1, sizeof(struct Workspace_Assignment));
403403 assignment->name = sstrdup(workspace);
404404 assignment->output = sstrdup(output);
405405 TAILQ_INSERT_TAIL(&ws_assignments, assignment, ws_assignments);
457457 return;
458458 }
459459 DLOG("New assignment, using above criteria, to workspace \"%s\".\n", workspace);
460 Assignment *assignment = scalloc(sizeof(Assignment));
460 Assignment *assignment = scalloc(1, sizeof(Assignment));
461461 match_copy(&(assignment->match), current_match);
462462 assignment->type = A_TO_WORKSPACE;
463463 assignment->dest.workspace = sstrdup(workspace);
471471 }
472472
473473 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));
475475 match_copy(&(assignment->match), current_match);
476476 assignment->type = A_NO_FOCUS;
477477 TAILQ_INSERT_TAIL(&assignments, assignment, assignments);
554554 }
555555 }
556556
557 struct Barbinding *new_binding = scalloc(sizeof(struct Barbinding));
557 struct Barbinding *new_binding = scalloc(1, sizeof(struct Barbinding));
558558 new_binding->input_code = input_code;
559559 new_binding->command = sstrdup(command);
560560 TAILQ_INSERT_TAIL(&(current_bar.bar_bindings), new_binding, bindings);
668668
669669 /* Copy the current (static) structure into a dynamically allocated
670670 * one, then cleanup our static one. */
671 Barconfig *bar_config = scalloc(sizeof(Barconfig));
671 Barconfig *bar_config = scalloc(1, sizeof(Barconfig));
672672 memcpy(bar_config, &current_bar, sizeof(Barconfig));
673673 TAILQ_INSERT_TAIL(&barconfigs, bar_config, configs);
674674
413413 }
414414 }
415415 if (walk != beginning) {
416 char *str = scalloc(walk - beginning + 1);
416 char *str = scalloc(walk - beginning + 1, 1);
417417 /* We copy manually to handle escaping of characters. */
418418 int inpos, outpos;
419419 for (inpos = 0, outpos = 0;
518518
519519 /* Contains the same amount of characters as 'input' has, but with
520520 * the unparseable part highlighted using ^ characters. */
521 char *position = scalloc(strlen(error_line) + 1);
521 char *position = scalloc(strlen(error_line) + 1, 1);
522522 const char *copywalk;
523523 for (copywalk = error_line;
524524 *copywalk != '\n' && *copywalk != '\r' && *copywalk != '\0';
848848 if (fstat(fd, &stbuf) == -1)
849849 die("Could not fstat file: %s\n", strerror(errno));
850850
851 buf = scalloc((stbuf.st_size + 1) * sizeof(char));
851 buf = scalloc(stbuf.st_size + 1, 1);
852852
853853 if ((fstr = fdopen(fd, "r")) == NULL)
854854 die("Could not fdopen: %s\n", strerror(errno));
896896 while (*v_value == '\t' || *v_value == ' ')
897897 v_value++;
898898
899 struct Variable *new = scalloc(sizeof(struct Variable));
899 struct Variable *new = scalloc(1, sizeof(struct Variable));
900900 new->key = sstrdup(v_key);
901901 new->value = sstrdup(v_value);
902902 SLIST_INSERT_HEAD(&variables, new, variables);
989989 }
990990 }
991991
992 context = scalloc(sizeof(struct context));
992 context = scalloc(1, sizeof(struct context));
993993 context->filename = f;
994994
995995 struct ConfigResultIR *config_output = parse_config(new, context);
4848 new_output->rect.width = min(new_output->rect.width, width);
4949 new_output->rect.height = min(new_output->rect.height, height);
5050 } else {
51 new_output = scalloc(sizeof(Output));
51 new_output = scalloc(1, sizeof(Output));
5252 sasprintf(&(new_output->name), "fake-%d", num_screens);
5353 DLOG("Created new fake output %s (%p)\n", new_output->name, new_output);
5454 new_output->active = true;
759759 uint32_t rnd = event->data.data32[1];
760760 DLOG("[i3 sync protocol] Sending random value %d back to X11 window 0x%08x\n", rnd, window);
761761
762 void *reply = scalloc(32);
762 void *reply = scalloc(32, 1);
763763 xcb_client_message_event_t *ev = reply;
764764
765765 ev->response_type = XCB_CLIENT_MESSAGE;
8383 IPC_HANDLER(command) {
8484 /* To get a properly terminated buffer, we copy
8585 * message_size bytes out of the buffer */
86 char *command = scalloc(message_size + 1);
86 char *command = scalloc(message_size + 1, 1);
8787 strncpy(command, (const char *)message, message_size);
8888 LOG("IPC: received: *%s*\n", command);
8989 yajl_gen gen = yajl_gen_alloc(NULL);
854854
855855 /* To get a properly terminated buffer, we copy
856856 * message_size bytes out of the buffer */
857 char *bar_id = scalloc(message_size + 1);
857 char *bar_id = scalloc(message_size + 1, 1);
858858 strncpy(bar_id, (const char *)message, message_size);
859859 LOG("IPC: looking for config for bar ID \"%s\"\n", bar_id);
860860 Barconfig *current, *config = NULL;
902902 client->events = realloc(client->events, client->num_events * sizeof(char *));
903903 /* We copy the string because it is not null-terminated and strndup()
904904 * is missing on some BSD systems */
905 client->events[event] = scalloc(len + 1);
905 client->events[event] = scalloc(len + 1, 1);
906906 memcpy(client->events[event], s, len);
907907
908908 DLOG("client is now subscribed to:\n");
10591059
10601060 set_nonblock(client);
10611061
1062 struct ev_io *package = scalloc(sizeof(struct ev_io));
1062 struct ev_io *package = scalloc(1, sizeof(struct ev_io));
10631063 ev_io_init(package, ipc_receive_message, client, EV_READ);
10641064 ev_io_start(EV_A_ package);
10651065
10661066 DLOG("IPC: new client connected on fd %d\n", w->fd);
10671067
1068 ipc_client *new = scalloc(sizeof(ipc_client));
1068 ipc_client *new = scalloc(1, sizeof(ipc_client));
10691069 new->fd = client;
10701070
10711071 TAILQ_INSERT_TAIL(&all_clients, new, clients);
166166 static int json_key(void *ctx, const unsigned char *val, size_t len) {
167167 LOG("key: %.*s\n", (int)len, val);
168168 FREE(last_key);
169 last_key = scalloc((len + 1) * sizeof(char));
169 last_key = scalloc(len + 1, 1);
170170 memcpy(last_key, val, len);
171171 if (strcasecmp(last_key, "swallows") == 0)
172172 parsing_swallows = true;
208208 free(sval);
209209 } else {
210210 if (strcasecmp(last_key, "name") == 0) {
211 json_node->name = scalloc((len + 1) * sizeof(char));
211 json_node->name = scalloc(len + 1, 1);
212212 memcpy(json_node->name, val, len);
213213 } 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);
215215 memcpy(json_node->sticky_group, val, len);
216216 LOG("sticky_group of this container is %s\n", json_node->sticky_group);
217217 } else if (strcasecmp(last_key, "orientation") == 0) {
360360 json_node->old_id = val;
361361
362362 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));
364364 focus_mapping->old_id = val;
365365 TAILQ_INSERT_TAIL(&focus_mappings, focus_mapping, focus_mappings);
366366 }
634634 if (ipc_socket == -1) {
635635 ELOG("Could not create the IPC socket, IPC disabled\n");
636636 } else {
637 struct ev_io *ipc_io = scalloc(sizeof(struct ev_io));
637 struct ev_io *ipc_io = scalloc(1, sizeof(struct ev_io));
638638 ev_io_init(ipc_io, ipc_new_client, ipc_socket, EV_READ);
639639 ev_io_start(main_loop, ipc_io);
640640 }
662662 ELOG("Could not disable FD_CLOEXEC on fd %d\n", fd);
663663 }
664664
665 struct ev_io *ipc_io = scalloc(sizeof(struct ev_io));
665 struct ev_io *ipc_io = scalloc(1, sizeof(struct ev_io));
666666 ev_io_init(ipc_io, ipc_new_client, fd, EV_READ);
667667 ev_io_start(main_loop, ipc_io);
668668 }
678678 ewmh_update_desktop_names();
679679 ewmh_update_desktop_viewport();
680680
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));
684684
685685 ev_io_init(xcb_watcher, xcb_got_event, xcb_get_file_descriptor(conn), EV_READ);
686686 ev_io_start(main_loop, xcb_watcher);
163163
164164 DLOG("Managing window 0x%08x\n", window);
165165
166 i3Window *cwindow = scalloc(sizeof(i3Window));
166 i3Window *cwindow = scalloc(1, sizeof(i3Window));
167167 cwindow->id = window;
168168 cwindow->depth = get_visual_depth(attr->visual);
169169
226226 void disable_randr(xcb_connection_t *conn) {
227227 DLOG("RandR extension unusable, disabling.\n");
228228
229 Output *s = scalloc(sizeof(Output));
229 Output *s = scalloc(1, sizeof(Output));
230230
231231 s->active = true;
232232 s->rect.x = 0;
291291 topdock->type = CT_DOCKAREA;
292292 topdock->layout = L_DOCKAREA;
293293 /* this container swallows dock clients */
294 Match *match = scalloc(sizeof(Match));
294 Match *match = scalloc(1, sizeof(Match));
295295 match_init(match);
296296 match->dock = M_DOCK_TOP;
297297 match->insert_where = M_BELOW;
325325 bottomdock->type = CT_DOCKAREA;
326326 bottomdock->layout = L_DOCKAREA;
327327 /* this container swallows dock clients */
328 match = scalloc(sizeof(Match));
328 match = scalloc(1, sizeof(Match));
329329 match_init(match);
330330 match->dock = M_DOCK_BOTTOM;
331331 match->insert_where = M_BELOW;
521521 Output *new = get_output_by_id(id);
522522 bool existing = (new != NULL);
523523 if (!existing)
524 new = scalloc(sizeof(Output));
524 new = scalloc(1, sizeof(Output));
525525 new->id = id;
526526 new->primary = (primary && primary->output == id);
527527 FREE(new->name);
2424 const char *error;
2525 int errorcode, offset;
2626
27 struct regex *re = scalloc(sizeof(struct regex));
27 struct regex *re = scalloc(1, sizeof(struct regex));
2828 re->pattern = sstrdup(pattern);
2929 int options = PCRE_UTF8;
3030 #ifdef PCRE_HAS_UCP
108108 if (restore_conn == NULL || xcb_connection_has_error(restore_conn))
109109 errx(EXIT_FAILURE, "Cannot open display\n");
110110
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));
114114
115115 ev_io_init(xcb_watcher, restore_xcb_got_event, xcb_get_file_descriptor(restore_conn), EV_READ);
116116 ev_io_start(main_loop, xcb_watcher);
209209 DLOG("Created placeholder window 0x%08x for leaf container %p / %s\n",
210210 placeholder, con, con->name);
211211
212 placeholder_state *state = scalloc(sizeof(placeholder_state));
212 placeholder_state *state = scalloc(1, sizeof(placeholder_state));
213213 state->window = placeholder;
214214 state->con = con;
215215 state->rect = con->rect;
148148 free(first_word);
149149
150150 /* 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));
152152 ev_timer_init(timeout, startup_timeout, 60.0, 0.);
153153 timeout->data = context;
154154 ev_timer_start(main_loop, timeout);
158158 /* Save the ID and current workspace in our internal list of startup
159159 * sequences */
160160 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));
162162 sequence->id = sstrdup(sn_launcher_context_get_startup_id(context));
163163 sequence->workspace = sstrdup(ws->name);
164164 sequence->context = context;
275275 int num_args;
276276 for (num_args = 0; start_argv[num_args] != NULL; num_args++)
277277 ;
278 char **new_argv = scalloc((num_args + 3) * sizeof(char *));
278 char **new_argv = scalloc(num_args + 3, sizeof(char *));
279279
280280 /* copy the arguments, but skip the ones we'll replace */
281281 int write_index = 0;
396396 if (focused->urgency_timer == NULL) {
397397 DLOG("Deferring reset of urgency flag of con %p on newly shown workspace %p\n",
398398 focused, workspace);
399 focused->urgency_timer = scalloc(sizeof(struct ev_timer));
399 focused->urgency_timer = scalloc(1, sizeof(struct ev_timer));
400400 /* use a repeating timer to allow for easy resets */
401401 ev_timer_init(focused->urgency_timer, workspace_defer_update_urgent_hint_cb,
402402 config.workspace_urgency_timer, config.workspace_urgency_timer);
146146 if (win_colormap != XCB_NONE)
147147 xcb_free_colormap(conn, win_colormap);
148148
149 struct con_state *state = scalloc(sizeof(struct con_state));
149 struct con_state *state = scalloc(1, sizeof(struct con_state));
150150 state->id = con->frame;
151151 state->mapped = false;
152152 state->initial = true;
285285 /* Every X11 event is 32 bytes long. Therefore, XCB will copy 32 bytes.
286286 * In order to properly initialize these bytes, we allocate 32 bytes even
287287 * though we only need less for an xcb_configure_notify_event_t */
288 void *event = scalloc(32);
288 void *event = scalloc(32, 1);
289289 xcb_client_message_event_t *ev = event;
290290
291291 ev->response_type = XCB_CLIENT_MESSAGE;
375375 return;
376376
377377 /* 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));
379379
380380 /* find out which colors to use */
381381 if (con->urgent)
113113 /* Every X11 event is 32 bytes long. Therefore, XCB will copy 32 bytes.
114114 * In order to properly initialize these bytes, we allocate 32 bytes even
115115 * though we only need less for an xcb_configure_notify_event_t */
116 void *event = scalloc(32);
116 void *event = scalloc(32, 1);
117117 xcb_client_message_event_t *ev = event;
118118
119119 ev->response_type = XCB_CLIENT_MESSAGE;
5555 s->rect.width = min(s->rect.width, screen_info[screen].width);
5656 s->rect.height = min(s->rect.height, screen_info[screen].height);
5757 } else {
58 s = scalloc(sizeof(Output));
58 s = scalloc(1, sizeof(Output));
5959 sasprintf(&(s->name), "xinerama-%d", num_screens);
6060 DLOG("Created new Xinerama screen %s (%p)\n", s->name, s);
6161 s->active = true;