home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
misc
/
volume36
/
formes
/
part01
/
assoc.c
next >
Wrap
C/C++ Source or Header
|
1993-04-01
|
2KB
|
104 lines
/*
* Copyright (C) 1992-1993 Jeffrey Chilton
*
* Permission is granted to anyone to make or distribute copies of
* this program, in any medium, provided that the copyright notice
* and permission notice are preserved, and that the distributor
* grants the recipient permission for further redistribution as
* permitted by this notice.
*
* Author's E-mail address: 172-9221@mcimail.com
*
*/
static char *whatstring = "@(#)assoc.c 2.2 JWC";
#include <stdio.h>
#include <malloc.h>
#include "class.h"
#include "assoc.h"
/* Association_new - Create an empty association */
Association *
Association_new()
{
Association *self;
self = (Association *)malloc(sizeof (Association));
if (!self)
{
fprintf(stderr, "Association_new: malloc fails\n");
goto out;
}
self->key = (void *)0;
self->value = (void *)0;
out:
return self;
}
/* Association_newWithKey - Create a half-empty association */
Association *
Association_newWithKey(key)
void *key;
{
Association *self;
self = (Association *)malloc(sizeof (Association));
if (!self)
{
fprintf(stderr, "Association_new: malloc fails\n");
goto out;
}
self->key = key;
self->value = (void *)0;
out:
return self;
}
/* Association_newWithPair - Create a full association */
Association *
Association_newWithPair(key, value)
void *key;
void *value;
{
Association *self;
self = (Association *)malloc(sizeof (Association));
if (!self)
{
fprintf(stderr, "Association_new: malloc fails\n");
goto out;
}
self->key = key;
self->value = value;
out:
return self;
}
/* Association_destroy */
void
Association_destroy(self)
Association *self;
{
free(self);
}