memalloc.h (ff802dc7bbf970a8cd17c40600c49b29540f4f58) | memalloc.h (33a8413363fd2057d99166b6254edd6c34b0224b) |
---|---|
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 --- 41 unchanged lines hidden (view full) --- 50pointer ckmalloc(size_t); 51pointer ckrealloc(pointer, int); 52void ckfree(pointer); 53char *savestr(const char *); 54pointer stalloc(int); 55void stunalloc(pointer); 56void setstackmark(struct stackmark *); 57void popstackmark(struct stackmark *); | 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 --- 41 unchanged lines hidden (view full) --- 50pointer ckmalloc(size_t); 51pointer ckrealloc(pointer, int); 52void ckfree(pointer); 53char *savestr(const char *); 54pointer stalloc(int); 55void stunalloc(pointer); 56void setstackmark(struct stackmark *); 57void popstackmark(struct stackmark *); |
58void grabstackblock(int); | |
59char *growstackstr(void); 60char *makestrspace(int, char *); 61char *stputbin(const char *data, int len, char *p); 62char *stputs(const char *data, char *p); 63 64 65 66#define stackblock() stacknxt 67#define stackblocksize() stacknleft | 58char *growstackstr(void); 59char *makestrspace(int, char *); 60char *stputbin(const char *data, int len, char *p); 61char *stputs(const char *data, char *p); 62 63 64 65#define stackblock() stacknxt 66#define stackblocksize() stacknleft |
67#define grabstackblock(n) stalloc(n) |
|
68#define STARTSTACKSTR(p) p = stackblock() 69#define STPUTC(c, p) do { if (p == sstrend) p = growstackstr(); *p++ = (c); } while(0) 70#define CHECKSTRSPACE(n, p) { if (sstrend - p < n) p = makestrspace(n, p); } 71#define USTPUTC(c, p) (*p++ = (c)) 72/* 73 * STACKSTRNUL's use is where we want to be able to turn a stack 74 * (non-sentinel, character counting string) into a C string, 75 * and later pretend the NUL is not there. 76 * Note: Because of STACKSTRNUL's semantics, STACKSTRNUL cannot be used 77 * on a stack that will grabstackstr()ed. 78 */ 79#define STACKSTRNUL(p) (p == sstrend ? (p = growstackstr(), *p = '\0') : (*p = '\0')) 80#define STUNPUTC(p) (--p) 81#define STTOPC(p) p[-1] 82#define STADJUST(amount, p) (p += (amount)) 83#define grabstackstr(p) stalloc((char *)p - stackblock()) 84#define ungrabstackstr(s, p) stunalloc((s)) 85#define STPUTBIN(s, len, p) p = stputbin((s), (len), p) 86#define STPUTS(s, p) p = stputs((s), p) | 68#define STARTSTACKSTR(p) p = stackblock() 69#define STPUTC(c, p) do { if (p == sstrend) p = growstackstr(); *p++ = (c); } while(0) 70#define CHECKSTRSPACE(n, p) { if (sstrend - p < n) p = makestrspace(n, p); } 71#define USTPUTC(c, p) (*p++ = (c)) 72/* 73 * STACKSTRNUL's use is where we want to be able to turn a stack 74 * (non-sentinel, character counting string) into a C string, 75 * and later pretend the NUL is not there. 76 * Note: Because of STACKSTRNUL's semantics, STACKSTRNUL cannot be used 77 * on a stack that will grabstackstr()ed. 78 */ 79#define STACKSTRNUL(p) (p == sstrend ? (p = growstackstr(), *p = '\0') : (*p = '\0')) 80#define STUNPUTC(p) (--p) 81#define STTOPC(p) p[-1] 82#define STADJUST(amount, p) (p += (amount)) 83#define grabstackstr(p) stalloc((char *)p - stackblock()) 84#define ungrabstackstr(s, p) stunalloc((s)) 85#define STPUTBIN(s, len, p) p = stputbin((s), (len), p) 86#define STPUTS(s, p) p = stputs((s), p) |