void credential_init(struct credential *c)
{
- memset(c, 0, sizeof(*c));
- c->helpers.strdup_strings = 1;
+ struct credential blank = CREDENTIAL_INIT;
+ memcpy(c, &blank, sizeof(*c));
}
void credential_clear(struct credential *c)
void jw_init(struct json_writer *jw)
{
- strbuf_init(&jw->json, 0);
- strbuf_init(&jw->open_stack, 0);
- jw->need_comma = 0;
- jw->pretty = 0;
+ struct json_writer blank = JSON_WRITER_INIT;
+ memcpy(jw, &blank, sizeof(*jw));;
}
void jw_release(struct json_writer *jw)
void child_process_init(struct child_process *child)
{
- memset(child, 0, sizeof(*child));
- strvec_init(&child->args);
- strvec_init(&child->env_array);
+ struct child_process blank = CHILD_PROCESS_INIT;
+ memcpy(child, &blank, sizeof(*child));
}
void child_process_clear(struct child_process *child)
void strbuf_init(struct strbuf *sb, size_t hint)
{
- sb->alloc = sb->len = 0;
- sb->buf = strbuf_slopbuf;
+ struct strbuf blank = STRBUF_INIT;
+ memcpy(sb, &blank, sizeof(*sb));
if (hint)
strbuf_grow(sb, hint);
}
void strmap_init(struct strmap *map)
{
- strmap_init_with_options(map, NULL, 1);
+ struct strmap blank = STRMAP_INIT;
+ memcpy(map, &blank, sizeof(*map));
}
void strmap_init_with_options(struct strmap *map,
void strvec_init(struct strvec *array)
{
- array->v = empty_strvec;
- array->nr = 0;
- array->alloc = 0;
+ struct strvec blank = STRVEC_INIT;
+ memcpy(array, &blank, sizeof(*array));
}
static void strvec_push_nodup(struct strvec *array, const char *value)