summaryrefslogtreecommitdiff
path: root/usr.bin/make/job.c
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2008-11-11 09:32:21 +0000
committerMarc Espie <espie@cvs.openbsd.org>2008-11-11 09:32:21 +0000
commitc768c9692097404ab30b81722012d085e68876b5 (patch)
treefaf1092bec997eda4c374851a99d281e7c9bb252 /usr.bin/make/job.c
parent3c3644d7cffbdf8bc997e8aa69c6b8e09e1fc046 (diff)
allocate job only when it's needed.
okay otto@
Diffstat (limited to 'usr.bin/make/job.c')
-rw-r--r--usr.bin/make/job.c40
1 files changed, 18 insertions, 22 deletions
diff --git a/usr.bin/make/job.c b/usr.bin/make/job.c
index e769b0e91eb..77efc00f437 100644
--- a/usr.bin/make/job.c
+++ b/usr.bin/make/job.c
@@ -1,5 +1,5 @@
/* $OpenPackages$ */
-/* $OpenBSD: job.c,v 1.114 2008/11/04 07:22:35 espie Exp $ */
+/* $OpenBSD: job.c,v 1.115 2008/11/11 09:32:20 espie Exp $ */
/* $NetBSD: job.c,v 1.16 1996/11/06 17:59:08 christos Exp $ */
/*
@@ -901,24 +901,9 @@ JobRestart(Job *job)
static Job *
prepare_job(GNode *gn, int flags)
{
- Job *job; /* new job descriptor */
bool cmdsOK; /* true if the nodes commands were all right */
bool noExec; /* Set true if we decide not to run the job */
- job = emalloc(sizeof(Job));
- if (job == NULL) {
- Punt("JobStart out of memory");
- }
-
- job->node = gn;
-
- /*
- * Set the initial value of the flags for this job based on the global
- * ones and the node's attributes... Any flags supplied by the caller
- * are also added to the field.
- */
- job->flags = flags;
-
/*
* Check the commands now so any attributes from .DEFAULT have a chance
* to migrate to the node
@@ -963,15 +948,26 @@ prepare_job(GNode *gn, int flags)
* We only want to work our way up the graph if we aren't here
* because the commands for the job were no good.
*/
- if (cmdsOK) {
- if (aborting == 0) {
- job->node->built_status = MADE;
- Make_Update(job->node);
- }
+ if (cmdsOK && !aborting) {
+ gn->built_status = MADE;
+ Make_Update(gn);
}
- free(job);
return NULL;
} else {
+ Job *job; /* new job descriptor */
+ job = emalloc(sizeof(Job));
+ if (job == NULL)
+ Punt("JobStart out of memory");
+
+ job->node = gn;
+
+ /*
+ * Set the initial value of the flags for this job based on the
+ * global ones and the node's attributes... Any flags supplied
+ * by the caller are also added to the field.
+ */
+ job->flags = flags;
+
return job;
}
}