summaryrefslogtreecommitdiffstats
path: root/darwin
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 /darwin
parenta1f7f2869ec2bd860d5b4e4b39736ca877afdf6f (diff)
Check for failure in allocations.
Diffstat (limited to 'darwin')
-rw-r--r--darwin/DarwinProcess.c8
-rw-r--r--darwin/DarwinProcessList.c4
-rw-r--r--darwin/Platform.c4
3 files changed, 8 insertions, 8 deletions
diff --git a/darwin/DarwinProcess.c b/darwin/DarwinProcess.c
index 83e9d828..9c460469 100644
--- a/darwin/DarwinProcess.c
+++ b/darwin/DarwinProcess.c
@@ -39,7 +39,7 @@ ProcessClass DarwinProcess_class = {
};
DarwinProcess* DarwinProcess_new(Settings* settings) {
- DarwinProcess* this = calloc(1, sizeof(DarwinProcess));
+ DarwinProcess* this = xCalloc(1, sizeof(DarwinProcess));
Object_setClass(this, Class(DarwinProcess));
Process_init(&this->super, settings);
@@ -85,7 +85,7 @@ char *DarwinProcess_getCmdLine(struct kinfo_proc* k, int show_args ) {
}
/* Allocate space for the arguments. */
- procargs = ( char * ) malloc( argmax );
+ procargs = ( char * ) xMalloc( argmax );
if ( procargs == NULL ) {
goto ERROR_A;
}
@@ -237,7 +237,7 @@ char *DarwinProcess_getCmdLine(struct kinfo_proc* k, int show_args ) {
}
/* Make a copy of the string. */
- retval = strdup(sp);
+ retval = xStrdup(sp);
/* Clean up. */
free( procargs );
@@ -247,7 +247,7 @@ char *DarwinProcess_getCmdLine(struct kinfo_proc* k, int show_args ) {
ERROR_B:
free( procargs );
ERROR_A:
- retval = strdup(k->kp_proc.p_comm);
+ retval = xStrdup(k->kp_proc.p_comm);
return retval;
}
diff --git a/darwin/DarwinProcessList.c b/darwin/DarwinProcessList.c
index deafc5f3..7ea89d9f 100644
--- a/darwin/DarwinProcessList.c
+++ b/darwin/DarwinProcessList.c
@@ -87,7 +87,7 @@ struct kinfo_proc *ProcessList_getKInfoProcs(size_t *count) {
if (sysctl(mib, 4, NULL, count, NULL, 0) < 0)
CRT_fatalError("Unable to get size of kproc_infos");
- processes = malloc(*count);
+ processes = xMalloc(*count);
if (processes == NULL)
CRT_fatalError("Out of memory for kproc_infos");
@@ -101,7 +101,7 @@ struct kinfo_proc *ProcessList_getKInfoProcs(size_t *count) {
ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId) {
- DarwinProcessList* this = calloc(1, sizeof(DarwinProcessList));
+ DarwinProcessList* this = xCalloc(1, sizeof(DarwinProcessList));
ProcessList_init(&this->super, Class(Process), usersTable, pidWhiteList, userId);
diff --git a/darwin/Platform.c b/darwin/Platform.c
index 22a18774..303b6c15 100644
--- a/darwin/Platform.c
+++ b/darwin/Platform.c
@@ -251,7 +251,7 @@ char* Platform_getProcessEnv(pid_t pid) {
mib[0] = CTL_KERN;
mib[1] = KERN_ARGMAX;
if (sysctl(mib, 2, &argmax, &bufsz, 0, 0) == 0) {
- char* buf = malloc(argmax);
+ char* buf = xMalloc(argmax);
if (buf) {
mib[0] = CTL_KERN;
mib[1] = KERN_PROCARGS2;
@@ -279,7 +279,7 @@ char* Platform_getProcessEnv(pid_t pid) {
++p;
size_t size = endp - p;
- env = malloc(size+2);
+ env = xMalloc(size+2);
if (env) {
memcpy(env, p, size);
env[size] = 0;

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