diff options
author | obrien <obrien@FreeBSD.org> | 2001-07-24 14:15:51 +0000 |
---|---|---|
committer | obrien <obrien@FreeBSD.org> | 2001-07-24 14:15:51 +0000 |
commit | ee6fd791db08e5c6c71916978b0b7a7434725f7d (patch) | |
tree | 231183bf6a2a2e31e819307d46beff2a2319d6d7 /usr.bin/at | |
parent | 6a671f268436112bbf62eda34eaddc7b6ac68b90 (diff) | |
download | FreeBSD-src-ee6fd791db08e5c6c71916978b0b7a7434725f7d.zip FreeBSD-src-ee6fd791db08e5c6c71916978b0b7a7434725f7d.tar.gz |
Expland `mymalloc' with malloc + error checking.
Diffstat (limited to 'usr.bin/at')
-rw-r--r-- | usr.bin/at/at.c | 17 | ||||
-rw-r--r-- | usr.bin/at/at.h | 4 | ||||
-rw-r--r-- | usr.bin/at/parsetime.c | 3 | ||||
-rw-r--r-- | usr.bin/at/perm.c | 3 |
4 files changed, 10 insertions, 17 deletions
diff --git a/usr.bin/at/at.c b/usr.bin/at/at.c index 909207a..cad2e49 100644 --- a/usr.bin/at/at.c +++ b/usr.bin/at/at.c @@ -156,7 +156,8 @@ static char *cwdname(void) static size_t size = SIZE; if (ptr == NULL) - ptr = (char *) mymalloc(size); + if ((ptr = malloc(size)) == NULL) + errx(EXIT_FAILURE, "virtual memory exhausted"); while (1) { @@ -171,7 +172,8 @@ static char *cwdname(void) free (ptr); size += SIZE; - ptr = (char *) mymalloc(size); + if ((ptr = malloc(size)) == NULL) + errx(EXIT_FAILURE, "virtual memory exhausted"); } } @@ -586,17 +588,6 @@ process_jobs(int argc, char **argv, int what) } } /* delete_jobs */ -/* Global functions */ - -void * -mymalloc(size_t n) -{ - void *p; - if ((p=malloc(n))==(void *)0) - errx(EXIT_FAILURE, "virtual memory exhausted"); - return p; -} - int main(int argc, char **argv) { diff --git a/usr.bin/at/at.h b/usr.bin/at/at.h index 40a5a6f..3d72bbb 100644 --- a/usr.bin/at/at.h +++ b/usr.bin/at/at.h @@ -21,11 +21,11 @@ * THEORY OF LIABILITY, WETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ */ extern int fcreated; extern char *namep; extern char atfile[]; extern char atverify; - -void *mymalloc(size_t n); diff --git a/usr.bin/at/parsetime.c b/usr.bin/at/parsetime.c index 26e559e..d4e8a40 100644 --- a/usr.bin/at/parsetime.c +++ b/usr.bin/at/parsetime.c @@ -185,7 +185,8 @@ init_scanner(int argc, char **argv) while (argc-- > 0) sc_len += strlen(*argv++); - sc_token = (char *) mymalloc(sc_len); + if ((sc_token = malloc(sc_len)) == NULL) + errx(EXIT_FAILURE, "virtual memory exhausted"); } /* init_scanner */ /* diff --git a/usr.bin/at/perm.c b/usr.bin/at/perm.c index e7bb9b1..6380f46 100644 --- a/usr.bin/at/perm.c +++ b/usr.bin/at/perm.c @@ -64,7 +64,8 @@ static int check_for_user(FILE *fp,const char *name) int found = 0; len = strlen(name); - buffer = mymalloc(len+2); + if ((buffer = malloc(len+2)) == NULL) + errx(EXIT_FAILURE, "virtual memory exhausted"); while(fgets(buffer, len+2, fp) != NULL) { |