Minor on hb_blob_create_from_file

Add one more "unlikely" annotation and use explicit nullptr check for more consistency.
This commit is contained in:
Ebrahim Byagowi 2018-06-26 10:46:10 +04:30 committed by GitHub
parent 4f8753464a
commit 7db2e9ea38
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -597,7 +597,7 @@ fail_without_close:
int len = 0; int len = 0;
int allocated = BUFSIZ * 16; int allocated = BUFSIZ * 16;
char *blob = (char *) malloc (allocated); char *blob = (char *) malloc (allocated);
if (blob == nullptr) return hb_blob_get_empty (); if (unlikely (blob == nullptr)) return hb_blob_get_empty ();
FILE *fp = fopen (file_name, "rb"); FILE *fp = fopen (file_name, "rb");
if (unlikely (fp == nullptr)) goto fread_fail_without_close; if (unlikely (fp == nullptr)) goto fread_fail_without_close;
@ -611,7 +611,7 @@ fail_without_close:
// can cover files like that but lets limit our fallback reader // can cover files like that but lets limit our fallback reader
if (unlikely (allocated > 200000000)) goto fread_fail; if (unlikely (allocated > 200000000)) goto fread_fail;
char *new_blob = (char *) realloc (blob, allocated); char *new_blob = (char *) realloc (blob, allocated);
if (unlikely (!new_blob)) goto fread_fail; if (unlikely (new_blob == nullptr)) goto fread_fail;
blob = new_blob; blob = new_blob;
} }