Gracefully handle constructor failure rather than SEGV
This commit is contained in:
parent
05639c4773
commit
247fae6a72
5
demo.c
5
demo.c
|
@ -6,6 +6,11 @@ int main(int argc, char *argv[]) {
|
||||||
char buffer[50];
|
char buffer[50];
|
||||||
termkey_t *tk = termkey_new(0, 0);
|
termkey_t *tk = termkey_new(0, 0);
|
||||||
|
|
||||||
|
if(!tk) {
|
||||||
|
fprintf(stderr, "Cannot allocate termkey instance\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
termkey_result ret;
|
termkey_result ret;
|
||||||
termkey_key key;
|
termkey_key key;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue