c084f9f224
standard library, because they never worked and come from an achingly old version of the Pascal specification. Fix the implementations of New() and Dispose() to use the standard C memory allocator rather than rolling their own (also in C). Write test!
20 lines
260 B
C
20 lines
260 B
C
#include <stdlib.h>
|
|
#include <em_abs.h>
|
|
#include <pc_err.h>
|
|
|
|
extern void _trp(int); /* called on error */
|
|
|
|
void _new(int n, void** ptr)
|
|
{
|
|
void* p = malloc(n);
|
|
if (!p)
|
|
_trp(EHEAP);
|
|
|
|
*ptr = p;
|
|
}
|
|
|
|
void _dis(int n, void** ptr)
|
|
{
|
|
free(*ptr);
|
|
*ptr = NULL;
|
|
} |