memalloc.c (8832864298b522bb2b4b3d2fdb1fa0443bedd681) | memalloc.c (7cfe69417cad6dc797729aaa60dc538aa194e1ba) |
---|---|
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 --- 281 unchanged lines hidden (view full) --- 290 * the string, the user should use grabstack to allocate the space, and 291 * then call ungrabstr(p) to return to the previous mode of operation. 292 * 293 * USTPUTC is like STPUTC except that it doesn't check for overflow. 294 * CHECKSTACKSPACE can be called before USTPUTC to ensure that there 295 * is space for at least one character. 296 */ 297 | 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 --- 281 unchanged lines hidden (view full) --- 290 * the string, the user should use grabstack to allocate the space, and 291 * then call ungrabstr(p) to return to the previous mode of operation. 292 * 293 * USTPUTC is like STPUTC except that it doesn't check for overflow. 294 * CHECKSTACKSPACE can be called before USTPUTC to ensure that there 295 * is space for at least one character. 296 */ 297 |
298static char * 299growstrstackblock(int n) 300{ 301 growstackblock(); 302 sstrnleft = stackblocksize() - n; 303 return stackblock() + n; 304} |
|
298 299char * 300growstackstr(void) 301{ 302 int len; 303 304 len = stackblocksize(); 305 if (herefd >= 0 && len >= 1024) { 306 xwrite(herefd, stackblock(), len); | 305 306char * 307growstackstr(void) 308{ 309 int len; 310 311 len = stackblocksize(); 312 if (herefd >= 0 && len >= 1024) { 313 xwrite(herefd, stackblock(), len); |
307 sstrnleft = len - 1; | 314 sstrnleft = len; |
308 return stackblock(); 309 } | 315 return stackblock(); 316 } |
310 growstackblock(); 311 sstrnleft = stackblocksize() - len - 1; 312 return stackblock() + len; | 317 return growstrstackblock(len); |
313} 314 315 316/* 317 * Called from CHECKSTRSPACE. 318 */ 319 320char * 321makestrspace(void) 322{ 323 int len; 324 325 len = stackblocksize() - sstrnleft; | 318} 319 320 321/* 322 * Called from CHECKSTRSPACE. 323 */ 324 325char * 326makestrspace(void) 327{ 328 int len; 329 330 len = stackblocksize() - sstrnleft; |
326 growstackblock(); 327 sstrnleft = stackblocksize() - len; 328 return stackblock() + len; | 331 return growstrstackblock(len); |
329} 330 331 332 333void 334ungrabstackstr(char *s, char *p) 335{ 336 stacknleft += stacknxt - s; 337 stacknxt = s; 338 sstrnleft = stacknleft - (p - s); 339} | 332} 333 334 335 336void 337ungrabstackstr(char *s, char *p) 338{ 339 stacknleft += stacknxt - s; 340 stacknxt = s; 341 sstrnleft = stacknleft - (p - s); 342} |