check if malloc return \!null

This commit is contained in:
_N3m0 2023-12-30 22:09:59 +01:00
parent 4660e36790
commit 10f68191ec
1 changed files with 6 additions and 2 deletions

8
main.c
View File

@ -59,6 +59,12 @@ size_t save_chunk(char* buffer, size_t itemsize, size_t nitems, void* ignore){
}
void getPage(void){
pageChunk = malloc(sizeof(*pageChunk) * DEFAULT_PAGE_LEN);
if (pageChunk == NULL){
perror("ERROR: Buy more ram.\n");
exit(1);
}
CURL* curl = curl_easy_init();
if (curl == NULL){
perror("ERROR: curl init failed.\n");
@ -83,10 +89,8 @@ void printPage(void){
}
int main(int argc, char* argv[]){
pageChunk = malloc(sizeof(*pageChunk) * DEFAULT_PAGE_LEN);
getUserConfig(argc, argv);
getPage();
printPage();