memalloc.c (217209) | memalloc.c (248980) |
---|---|
1/*- 2 * Copyright (c) 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Kenneth Almquist. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 22 unchanged lines hidden (view full) --- 31 */ 32 33#ifndef lint 34#if 0 35static char sccsid[] = "@(#)memalloc.c 8.3 (Berkeley) 5/4/95"; 36#endif 37#endif /* not lint */ 38#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Kenneth Almquist. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 22 unchanged lines hidden (view full) --- 31 */ 32 33#ifndef lint 34#if 0 35static char sccsid[] = "@(#)memalloc.c 8.3 (Berkeley) 5/4/95"; 36#endif 37#endif /* not lint */ 38#include <sys/cdefs.h> |
39__FBSDID("$FreeBSD: head/bin/sh/memalloc.c 217209 2011-01-09 22:47:58Z jilles $"); | 39__FBSDID("$FreeBSD: head/bin/sh/memalloc.c 248980 2013-04-01 17:18:22Z jilles $"); |
40 41#include <sys/param.h> 42#include "shell.h" 43#include "output.h" 44#include "memalloc.h" 45#include "error.h" 46#include "mystring.h" 47#include "expand.h" --- 180 unchanged lines hidden (view full) --- 228 char *oldspace; 229 int oldlen; 230 struct stack_block *sp; 231 struct stack_block *oldstackp; 232 struct stackmark *xmark; 233 234 if (min < stacknleft) 235 min = stacknleft; | 40 41#include <sys/param.h> 42#include "shell.h" 43#include "output.h" 44#include "memalloc.h" 45#include "error.h" 46#include "mystring.h" 47#include "expand.h" --- 180 unchanged lines hidden (view full) --- 228 char *oldspace; 229 int oldlen; 230 struct stack_block *sp; 231 struct stack_block *oldstackp; 232 struct stackmark *xmark; 233 234 if (min < stacknleft) 235 min = stacknleft; |
236 if (min >= INT_MAX / 2 - ALIGN(sizeof(struct stack_block))) | 236 if ((unsigned int)min >= 237 INT_MAX / 2 - ALIGN(sizeof(struct stack_block))) |
237 error("Out of space"); 238 min += stacknleft; 239 min += ALIGN(sizeof(struct stack_block)); 240 newlen = 512; 241 while (newlen < min) 242 newlen <<= 1; 243 oldspace = stacknxt; 244 oldlen = stacknleft; --- 77 unchanged lines hidden (view full) --- 322 int len; 323 324 len = p - stackblock(); 325 return (growstrstackblock(len, min)); 326} 327 328 329char * | 238 error("Out of space"); 239 min += stacknleft; 240 min += ALIGN(sizeof(struct stack_block)); 241 newlen = 512; 242 while (newlen < min) 243 newlen <<= 1; 244 oldspace = stacknxt; 245 oldlen = stacknleft; --- 77 unchanged lines hidden (view full) --- 323 int len; 324 325 len = p - stackblock(); 326 return (growstrstackblock(len, min)); 327} 328 329 330char * |
330stputbin(const char *data, int len, char *p) | 331stputbin(const char *data, size_t len, char *p) |
331{ 332 CHECKSTRSPACE(len, p); 333 memcpy(p, data, len); 334 return (p + len); 335} 336 337char * 338stputs(const char *data, char *p) 339{ 340 return (stputbin(data, strlen(data), p)); 341} | 332{ 333 CHECKSTRSPACE(len, p); 334 memcpy(p, data, len); 335 return (p + len); 336} 337 338char * 339stputs(const char *data, char *p) 340{ 341 return (stputbin(data, strlen(data), p)); 342} |