testing
This commit is contained in:
@@ -1,28 +0,0 @@
|
||||
#
|
||||
# Makefile for big integer test
|
||||
#
|
||||
|
||||
BUILD = ../build
|
||||
|
||||
CC = gcc
|
||||
CFLAGS = -g -Wall -I$(BUILD)/include
|
||||
LDFLAGS = -g -Wall -L$(BUILD)/lib
|
||||
LDLIBS = -lbigint
|
||||
|
||||
all: testbip
|
||||
|
||||
install: all
|
||||
mkdir -p $(BUILD)/bin
|
||||
cp testbip $(BUILD)/bin
|
||||
|
||||
testbip: testbip.o support.o
|
||||
$(CC) $(LDFLAGS) -o testbip testbip.o support.o $(LDLIBS)
|
||||
|
||||
testbip.o: testbip.c
|
||||
$(CC) $(CFLAGS) -o testbip.o -c testbip.c
|
||||
|
||||
support.o: support.c
|
||||
$(CC) $(CFLAGS) -o support.o -c support.c
|
||||
|
||||
clean:
|
||||
rm -f *~ testbip.o support.o testbip
|
||||
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
* support.c -- support functions for big integer library
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "support.h"
|
||||
|
||||
typedef struct ObjRef{
|
||||
bool brokenHeart;
|
||||
struct ObjRef *forward_pointer;
|
||||
unsigned int size;
|
||||
unsigned char data[1];
|
||||
} *ObjRef;
|
||||
|
||||
|
||||
/*
|
||||
* This routine is called in case a fatal error has occurred.
|
||||
* It should print the error message and terminate the program.
|
||||
*/
|
||||
void fatalError(char *msg) {
|
||||
printf("Fatal error: %s\n", msg);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* This function is called whenever a new primitive object with
|
||||
* a certain amount of internal memory is needed. It should return
|
||||
* an object reference to a regular object, which contains a freely
|
||||
* usable memory area of at least the requested size (measured in
|
||||
* bytes). The memory area need not be initialized in any way.
|
||||
*
|
||||
* Note that this function may move all objects in memory at will
|
||||
* (due to, e.g., garbage collection), as long as the pointers in
|
||||
* the global "bip" structure point to the correct objects when
|
||||
* the function returns.
|
||||
*/
|
||||
void * newPrimObject(int dataSize) {
|
||||
ObjRef bigObjRef;
|
||||
int size = sizeof(unsigned int) + dataSize * sizeof(unsigned char);
|
||||
bigObjRef = malloc(size);
|
||||
bigObjRef->size = size;
|
||||
if (bigObjRef == NULL) {
|
||||
fatalError("newPrimObject() got no memory");
|
||||
}
|
||||
bigObjRef->size = size;
|
||||
return bigObjRef;
|
||||
}
|
||||
|
||||
void * getPrimObjectDataPointer(void * obj){
|
||||
ObjRef oo = ((ObjRef) (obj));
|
||||
return oo->data;
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
1253
bigint/tst/testbip.c
1253
bigint/tst/testbip.c
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Reference in New Issue
Block a user