-/* $NetBSD: alloc.c,v 1.6 2009/06/07 18:30:39 dholland Exp $ */
+/* $NetBSD: alloc.c,v 1.9 2011/08/06 20:18:26 dholland Exp $ */
/*
* Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: alloc.c,v 1.6 2009/06/07 18:30:39 dholland Exp $");
+__RCSID("$NetBSD: alloc.c,v 1.9 2011/08/06 20:18:26 dholland Exp $");
#endif /* not lint */
#include <stdlib.h>
#include "hack.h"
#include "extern.h"
-#ifdef LINT
-
-/*
- a ridiculous definition, suppressing
- "possible pointer alignment problem" for (long *) malloc()
- "enlarg defined but never used"
- "ftell defined (in <stdio.h>) but never used"
- from lint
-*/
-long *
-alloc(unsigned n)
+void *
+alloc(size_t len)
{
- long dummy = ftell(stderr);
- if (n)
- dummy = 0; /* make sure arg is used */
- return (&dummy);
-}
-
-#else
+ void *ptr;
-long *
-alloc(unsigned lth)
-{
- char *ptr;
-
- if (!(ptr = malloc(lth)))
- panic("Cannot get %d bytes", lth);
- return ((long *) ptr);
+ ptr = malloc(len);
+ if (ptr == NULL)
+ panic("Cannot get %zu bytes", len);
+ return ptr;
}
-long *
+#if 0 /* unused */
+static long *
enlarge(char *ptr, unsigned lth)
{
char *nptr;
panic("Cannot reallocate %d bytes", lth);
return ((long *) nptr);
}
-
-#endif /* LINT */
+#endif