alloc.c revision 1.4
11.4Schristos/* $NetBSD: alloc.c,v 1.4 1997/10/19 16:56:47 christos Exp $ */ 21.4Schristos#include <sys/cdefs.h> 31.2Smycroft#ifndef lint 41.4Schristos__RCSID("$NetBSD: alloc.c,v 1.4 1997/10/19 16:56:47 christos Exp $"); 51.4Schristos#endif /* not lint */ 61.4Schristos 71.4Schristos#include <stdlib.h> 81.4Schristos#include "hack.h" 91.4Schristos#include "extern.h" 101.2Smycroft 111.1Scgd#ifdef LINT 121.1Scgd 131.1Scgd/* 141.1Scgd a ridiculous definition, suppressing 151.1Scgd "possible pointer alignment problem" for (long *) malloc() 161.1Scgd "enlarg defined but never used" 171.1Scgd "ftell defined (in <stdio.h>) but never used" 181.1Scgd from lint 191.1Scgd*/ 201.1Scgdlong * 211.4Schristosalloc(n) 221.4Schristos unsigned n; 231.4Schristos{ 241.4Schristos long dummy = ftell(stderr); 251.4Schristos if (n) 261.4Schristos dummy = 0; /* make sure arg is used */ 271.4Schristos return (&dummy); 281.1Scgd} 291.1Scgd 301.1Scgd#else 311.1Scgd 321.1Scgdlong * 331.1Scgdalloc(lth) 341.4Schristos unsigned lth; 351.1Scgd{ 361.4Schristos char *ptr; 371.1Scgd 381.4Schristos if (!(ptr = malloc(lth))) 391.1Scgd panic("Cannot get %d bytes", lth); 401.4Schristos return ((long *) ptr); 411.1Scgd} 421.1Scgd 431.1Scgdlong * 441.4Schristosenlarge(ptr, lth) 451.4Schristos char *ptr; 461.4Schristos unsigned lth; 471.1Scgd{ 481.4Schristos char *nptr; 491.1Scgd 501.4Schristos if (!(nptr = realloc(ptr, lth))) 511.1Scgd panic("Cannot reallocate %d bytes", lth); 521.4Schristos return ((long *) nptr); 531.1Scgd} 541.1Scgd 551.4Schristos#endif /* LINT */ 56