#include <stdio.h>
#include <stdlib.h>
+#include "tlog.h"
+#include "tmalloc.h"
#include "psort.h"
#define LENARR (1<<10)
int inserted=0;
EXMPL **aptr;
+ opentlog( TL_OPEN_STDERR, TL_DEBUG, NULL);
+
if ( PS_init( &sobj, LIMIT, exstr_cmp, exstr_free ) ) {
fprintf(stderr,"No memory\n");
return 1;
printf("Test insert:\n");
for(i=0;i<LENARR;i++) {
if ( ! ptr ) {
- ptr = (EXMPL*)malloc( sizeof(EXMPL) );
- if ( ! ptr ) {
- fprintf(stderr,"No memory\n");
- return 1;
- }
- ptr->value=(char*)malloc( 64 );
- if ( ! ptr->value ) {
- fprintf(stderr,"No memory\n");
- return 1;
- }
+ ptr = (EXMPL*)tmalloc( sizeof(EXMPL) );
+ ptr->value=(char*)tmalloc( 64 );
}
ptr->id = random() % LENARR;
sprintf( ptr->value, "Value: %d, startnum: %d", ptr->id, i );
srandom(1);
printf("Test bulk insert:\n");
- aptr = (EXMPL**)malloc( sizeof(EXMPL*) * LENARR );
- if ( ! aptr ) {
- fprintf(stderr,"No memory\n");
- return 1;
- }
+ aptr = (EXMPL**)tmalloc( sizeof(EXMPL*) * LENARR );
for(i=0;i<LENARR;i++) {
- aptr[i] = (EXMPL*)malloc( sizeof(EXMPL) );
- if ( ! aptr[i] ) {
- fprintf(stderr,"No memory\n");
- return 1;
- }
- aptr[i]->value = (char*)malloc( 64 );
- if ( ! aptr[i]->value ) {
- fprintf(stderr,"No memory\n");
- return 1;
- }
+ aptr[i] = (EXMPL*)tmalloc( sizeof(EXMPL) );
+ aptr[i]->value = (char*)tmalloc( 64 );
aptr[i]->id = random() % LENARR;
sprintf( aptr[i]->value, "Value: %d, startnum: %d", aptr[i]->id, i );
}
fprintf(stderr,"No memory\n");
return 1;
}
- ptr = (EXMPL*)malloc( sizeof(EXMPL) * LENARR );
- if ( ! ptr ) {
- fprintf(stderr,"No memory\n");
- return 1;
- }
+ ptr = (EXMPL*)tmalloc( sizeof(EXMPL) * LENARR );
for(i=0;i<LENARR;i++) {
- ptr[i].value = (char*)malloc( 64 );
- if ( ! ptr[i].value ) {
- fprintf(stderr,"No memory\n");
- return 1;
- }
+ ptr[i].value = (char*)tmalloc( 64 );
ptr[i].id = random() % LENARR;
sprintf( ptr[i].value, "Value: %d, startnum: %d", ptr[i].id, i );
}