summaryrefslogtreecommitdiffstats
path: root/OpenFilesScreen.c
diff options
context:
space:
mode:
authorHisham <hisham@gobolinux.org>2016-02-02 15:53:02 +0100
committerHisham <hisham@gobolinux.org>2016-02-02 15:53:02 +0100
commitb54d2dde407921caa7561dde6b45831ba93d0840 (patch)
treecd81eea35dd65e46d22f2801ea403e1efc06eb59 /OpenFilesScreen.c
parenta1f7f2869ec2bd860d5b4e4b39736ca877afdf6f (diff)
Check for failure in allocations.
Diffstat (limited to 'OpenFilesScreen.c')
-rw-r--r--OpenFilesScreen.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/OpenFilesScreen.c b/OpenFilesScreen.c
index 096ed939..1eda3731 100644
--- a/OpenFilesScreen.c
+++ b/OpenFilesScreen.c
@@ -58,7 +58,7 @@ InfoScreenClass OpenFilesScreen_class = {
};
OpenFilesScreen* OpenFilesScreen_new(Process* process) {
- OpenFilesScreen* this = malloc(sizeof(OpenFilesScreen));
+ OpenFilesScreen* this = xMalloc(sizeof(OpenFilesScreen));
Object_setClass(this, Class(OpenFilesScreen));
if (Process_isThread(process))
this->pid = process->tgid;
@@ -79,7 +79,7 @@ static OpenFiles_ProcessData* OpenFilesScreen_getProcessData(pid_t pid) {
char command[1025];
snprintf(command, 1024, "lsof -P -p %d -F 2> /dev/null", pid);
FILE* fd = popen(command, "r");
- OpenFiles_ProcessData* pdata = calloc(1, sizeof(OpenFiles_ProcessData));
+ OpenFiles_ProcessData* pdata = xCalloc(1, sizeof(OpenFiles_ProcessData));
OpenFiles_FileData* fdata = NULL;
OpenFiles_Data* item = &(pdata->data);
if (!fd) {
@@ -90,7 +90,7 @@ static OpenFiles_ProcessData* OpenFilesScreen_getProcessData(pid_t pid) {
int cmd = fgetc(fd);
if (cmd == EOF)
break;
- char* entry = malloc(1024);
+ char* entry = xMalloc(1024);
if (!fgets(entry, 1024, fd)) {
free(entry);
break;
@@ -98,7 +98,7 @@ static OpenFiles_ProcessData* OpenFilesScreen_getProcessData(pid_t pid) {
char* newline = strrchr(entry, '\n');
*newline = '\0';
if (cmd == 'f') {
- OpenFiles_FileData* nextFile = calloc(1, sizeof(OpenFiles_FileData));
+ OpenFiles_FileData* nextFile = xCalloc(1, sizeof(OpenFiles_FileData));
if (fdata == NULL) {
pdata->files = nextFile;
} else {

© 2014-2024 Faster IT GmbH | imprint | privacy policy