MCPcopy Create free account
hub / github.com/codr7/hacktical-c / hc_error_new

Function hc_error_new

error/error.c:51–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49}
50
51struct hc_error *hc_error_new(const char *message, ...) {
52 va_list args;
53 va_start(args, message);
54
55 va_list tmp_args;
56 va_copy(tmp_args, args);
57 int len = vsnprintf(NULL, 0, message, tmp_args);
58 va_end(tmp_args);
59
60 if (len < 0) {
61 vfprintf(stderr, message, args);
62 abort();
63 }
64
65 len++;
66 struct hc_error *e = malloc(sizeof(struct hc_error));
67 e->message = malloc(len);
68 vsnprintf(e->message, len, message, args);
69 va_end(args);
70 return e;
71}
72
73void hc_error_free(struct hc_error *e) {
74 free(e->message);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected