Example #1
0
char *stringcat(char *s1, char *s2){
	int i=0, c=0, len1 = strlen(s1), len2 = strlen(s2);
	char *result = GC_alloc((len1 + len2 + 1), false);
	for(i=0; i<len1; i++){
		result[c++] = s1[i];
	}
	for(i=0; i<len2; i++){
		result[c++] = s2[i];
	}
	result[c] = '\0';
	return result;
}
Example #2
0
Vector Vector_new(int x, int y)
{
	Vector vect = GC_alloc(vectorsGC);

	if(vect == NULL)
	{
		LOGERR("Couldn't allocate vector.");
		return NULL;
	}

	vect->x = x;
	vect->y = y;

	return vect;
}
Example #3
0
static Node Node_new()
{
	Node node = GC_alloc(nodesGC);

	if(node == NULL)
	{
		LOGERR("Couldn't allocate node.");
		return NULL;
	}

	node->ptr = NULL;
	node->next = NULL;
	node->prev = NULL;

	return node;
}
Example #4
0
Vector Vector_copy(Vector vect)
{
	Vector newVect;

	assert(vect);

	newVect = GC_alloc(vectorsGC);

	if(newVect == NULL)
	{
		LOGERR("Couldn't allocate copy of vector.");
		return NULL;
	}

	newVect->x = vect->x;
	newVect->y = vect->y;

	return newVect;
}