home *** CD-ROM | disk | FTP | other *** search
- /*
- oakalloc.c
-
- % 'oakland' insulated alloc functions
-
- OWL 1.2
- Copyright (c) 1986, 1987, 1988 by Oakland Group, Inc.
- ALL RIGHTS RESERVED.
-
- Revision History:
- -----------------
- 3/28/90 jmd ansi-fied
- 5/03/90 jmd added fix for Turbo/Rational realloc bug
- 10/10/90 ted added support for TCP Turbo C++ flag.
- */
-
- #include "oakhead.h"
- /* -------------------------------------------------------------------------- */
-
- VOID *omalloc(int tag, SIZE_T size)
- /*
- Call malloc with the given size.
- Return the result.
- If malloc fails, sets oak_errno to tag
- */
- {
- VOID *m;
-
- if ((m = (VOID *)malloc(size)) == NULL) {
- oak_SetErrno(tag);
- }
-
- return(m);
- }
- /* -------------------------------------------------------------------------- */
-
- VOID *ocalloc(int tag, SIZE_T n, SIZE_T size)
- /*
- Call calloc with the given size.
- Return the result.
- If calloc fails, sets oak_errno to tag
- */
- {
- VOID *m;
-
- if ((m = (VOID *)calloc(n, size)) == NULL) {
- oak_SetErrno(tag);
- }
-
- return(m);
- }
- /* -------------------------------------------------------------------------- */
-
- VOID *orealloc(int tag, VOID *buffer, SIZE_T size)
- /*
- Call realloc with the given size and buffer.
- Return the result.
- If realloc fails, sets oak_errno to tag
- */
- {
- VOID *m;
-
- #ifdef OAK_RATIONAL
- # ifdef TC
- # define REALLOC_BUG
- # endif
- # ifdef TCP
- # define REALLOC_BUG
- # endif
- #endif
-
- #ifdef REALLOC_BUG
-
- /* compensate for Turbo/Rational realloc bug */
-
- if ((m = (VOID *)malloc(size)) == NULL) {
- oak_SetErrno(tag);
- }
- else {
- memcpy(m, buffer, size);
- free(buffer);
- }
-
- #else
-
- if ((m = (VOID *)realloc(buffer, size)) == NULL) {
- oak_SetErrno(tag);
- }
-
- #endif
-
- return(m);
- }
- /* -------------------------------------------------------------------------- */
-
- void ofree(int tag, VOID *buffer)
- /*
- Call free with the given buffer.
- Return the result.
- */
- {
- free(buffer);
- /* tag not used in this version */ oak_notused(tag);
- }
- /* -------------------------------------------------------------------------- */
-