|
|
1.1 ! root 1: /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- ! 2: * ! 3: * The contents of this file are subject to the Netscape Public ! 4: * License Version 1.1 (the "License"); you may not use this file ! 5: * except in compliance with the License. You may obtain a copy of ! 6: * the License at http://www.mozilla.org/NPL/ ! 7: * ! 8: * Software distributed under the License is distributed on an "AS ! 9: * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or ! 10: * implied. See the License for the specific language governing ! 11: * rights and limitations under the License. ! 12: * ! 13: * The Original Code is Mozilla Communicator client code, released ! 14: * March 31, 1998. ! 15: * ! 16: * The Initial Developer of the Original Code is Netscape ! 17: * Communications Corporation. Portions created by Netscape are ! 18: * Copyright (C) 1998 Netscape Communications Corporation. All ! 19: * Rights Reserved. ! 20: * ! 21: * Contributor(s): ! 22: * ! 23: * Alternatively, the contents of this file may be used under the ! 24: * terms of the GNU Public License (the "GPL"), in which case the ! 25: * provisions of the GPL are applicable instead of those above. ! 26: * If you wish to allow use of your version of this file only ! 27: * under the terms of the GPL and not to allow others to use your ! 28: * version of this file under the NPL, indicate your decision by ! 29: * deleting the provisions above and replace them with the notice ! 30: * and other provisions required by the GPL. If you do not delete ! 31: * the provisions above, a recipient may use your version of this ! 32: * file under either the NPL or the GPL. ! 33: */ ! 34: ! 35: /* ! 36: * PR assertion checker. ! 37: */ ! 38: ! 39: #ifndef jsutil_h___ ! 40: #define jsutil_h___ ! 41: ! 42: JS_BEGIN_EXTERN_C ! 43: ! 44: /*********************************************************************** ! 45: ** FUNCTION: JS_MALLOC() ! 46: ** DESCRIPTION: ! 47: ** JS_NEW() allocates an untyped item of size _size from the heap. ! 48: ** INPUTS: _size: size in bytes of item to be allocated ! 49: ** OUTPUTS: untyped pointer to the node allocated ! 50: ** RETURN: pointer to node or error returned from malloc(). ! 51: ***********************************************************************/ ! 52: #define JS_MALLOC(_bytes) (malloc((_bytes))) ! 53: ! 54: /*********************************************************************** ! 55: ** FUNCTION: JS_DELETE() ! 56: ** DESCRIPTION: ! 57: ** JS_DELETE() unallocates an object previosly allocated via JS_NEW() ! 58: ** or JS_NEWZAP() to the heap. ! 59: ** INPUTS: pointer to previously allocated object ! 60: ** OUTPUTS: the referenced object is returned to the heap ! 61: ** RETURN: void ! 62: ***********************************************************************/ ! 63: #define JS_DELETE(_ptr) { free(_ptr); (_ptr) = NULL; } ! 64: ! 65: /*********************************************************************** ! 66: ** FUNCTION: JS_NEW() ! 67: ** DESCRIPTION: ! 68: ** JS_NEW() allocates an item of type _struct from the heap. ! 69: ** INPUTS: _struct: a data type ! 70: ** OUTPUTS: pointer to _struct ! 71: ** RETURN: pointer to _struct or error returns from malloc(). ! 72: ***********************************************************************/ ! 73: #define JS_NEW(_struct) ((_struct *) JS_MALLOC(sizeof(_struct))) ! 74: ! 75: #ifdef DEBUG ! 76: ! 77: extern JS_PUBLIC_API(void) ! 78: JS_Assert(const char *s, const char *file, JSIntn ln); ! 79: #define JS_ASSERT(_expr) \ ! 80: ((_expr)?((void)0):JS_Assert(# _expr,__FILE__,__LINE__)) ! 81: ! 82: #define JS_NOT_REACHED(_reasonStr) \ ! 83: JS_Assert(_reasonStr,__FILE__,__LINE__) ! 84: ! 85: #else ! 86: ! 87: #define JS_ASSERT(expr) ((void) 0) ! 88: #define JS_NOT_REACHED(reasonStr) ! 89: ! 90: #endif /* defined(DEBUG) */ ! 91: ! 92: /* ! 93: ** Abort the process in a non-graceful manner. This will cause a core file, ! 94: ** call to the debugger or other moral equivalent as well as causing the ! 95: ** entire process to stop. ! 96: */ ! 97: extern JS_PUBLIC_API(void) JS_Abort(void); ! 98: ! 99: JS_END_EXTERN_C ! 100: ! 101: #endif /* jsutil_h___ */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.