(COS_Object)
= { cos_release_string,
cos_release_symbol,
+ cos_release_cons,
cos_release_container,
cos_release_sexp,
cos_release_binary,
COS_Object
cos_retain_object (COS_Object obj)
{
- obj->header.reference_count++;
-
+ if (COS_OBJECT_P (obj))
+ obj->header.reference_count++;
return obj;
}
int
cos_release_object (COS_object obj)
{
- ((COS_Object)obj)->header.reference_count--;
+ if (COS_OBJECT_P (obj))
+ {
+ ((COS_Object)obj)->header.reference_count--;
- if ( ((COS_Object)obj)->header.reference_count <= 0 )
- return (*COS_Object_release_function_table
- [((COS_Object)obj)->header.type
- - COS_FAT_OBJECT_TYPE_MIN])(obj);
- else
- return 0;
+ if ( ((COS_Object)obj)->header.reference_count <= 0 )
+ return (*COS_Object_release_function_table
+ [((COS_Object)obj)->header.type
+ - COS_FAT_OBJECT_TYPE_MIN])(obj);
+ }
+ return 0;
}
}
+COS_Cons
+cos_cons (COS_object car, COS_object cdr)
+{
+ COS_Cons obj = COS_ALLOCATE_OBJECT (Cons);
+
+ if (obj == NULL)
+ return NULL;
+
+ obj->car = car;
+ obj->cdr = cdr;
+ cos_retain_object (car);
+ cos_retain_object (cdr);
+
+ return obj;
+}
+
+int
+cos_release_cons (COS_Object obj)
+{
+ if (obj == NULL)
+ return 0;
+
+ cos_release_object (COS_CAR (obj));
+ cos_release_object (COS_CDR (obj));
+ free (obj);
+ return 0;
+}
+
+COS_object
+cos_car (COS_Cons pair)
+{
+ if (COS_OBJECT_CONS_P (pair))
+ return COS_CAR (pair);
+ else
+ return NULL;
+}
+
+COS_object
+cos_cdr (COS_Cons pair)
+{
+ if (COS_OBJECT_CONS_P (pair))
+ return COS_CDR (pair);
+ else
+ return NULL;
+}
+
+
int
cos_release_container (COS_Object obj)
{