Gracefully handle constructor failure rather than SEGV

This commit is contained in:
Paul LeoNerd Evans 2008-10-09 22:41:07 +01:00
parent 05639c4773
commit 247fae6a72
1 changed files with 5 additions and 0 deletions

5
demo.c
View File

@ -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;