Esempio n. 1
0
ArrayList registryGetAllChildsOfNode(Registry registry,Node nodeObject ,int dept){
	ArrayList result=arrayListCreate();
	if(dept==0){
		return result;
	}
	if(nodeObject==NULL){
		return result;
	}
	NodeInternal* node=(NodeInternal*)nodeObject;
	if(node!=NULL){
		Array array;
		stringHashmapToArray(node->children,&array);
		int length=arrayGetLength(array);
		int i;
		for(i=0;i<length;i++){
			Arc arc=arrayGetObject(array,i);
			arrayListAddLast(result,arc->child);
                        ArrayList list=registryGetAllChildsOfNode(registry,arc->child,dept-1);
			arrayListAddAll(result,list);
                        arrayListFree(list);
		}
                arrayFree(array);
	}
	return result;
}
Esempio n. 2
0
void tcpConnectionWriterRunThread(TcpConnection tcpConnection){
    TcpConnectionInternal* internal=(TcpConnectionInternal*)tcpConnection;
    ArrayList tempList;
	  while(internal->active==TRUE){
                 environmentThreadLock(internal->thread);    
                 tempList=internal->commands;
                 internal->commands=arrayListCreate();
                 environmentThreadUnlock(internal->thread);
                 int i;
                 int length=arrayListSize(tempList);
                 Command command;
                 for(i=0; i < length;i++){
                       command=arrayListGetValueAt(tempList,i);
                       int result=tcpConnectionSend(tcpConnection,command);
                       if(result<0){
                              internal->active=FALSE;
                              distributionManagerHandleTcpConnectionListenerFailure(internal->distributionManager,internal,internal->coreManagerId);  
                              //TODO Free the commands
                              return;
                       }
                       commandFree(command);
                 }
                 arrayListFree(tempList);
                 // Lock to synchronize
                 environmentThreadLock(internal->thread);
                 if(arrayListSize(internal->commands)==0){
                    environmentThreadWait(internal->thread);
                 }
                 environmentThreadUnlock(internal->thread);
        }
    internal->readyForCleanup+=WRITER_READY_FOR_CLEANUP;
}
Esempio n. 3
0
/**
 * breakPointFree:
 *
 * Free all memory used by breakPoints 
 */
void
breakPointFree(void)
{
    if (breakList)
        arrayListFree(breakList);
    breakList = NULL;
}
Esempio n. 4
0
int validationManagerValidateOnCoreExecute(ValidationManager validationManager,Command command,ArrayList commands,int atomic){
	int administrator=commandGetInt(command,MARKED_AS_ADMINISTRATOR);
	if(atomic==TRUE){
		return validationManagerValidateOnCoreExecuteInternalRecurcive(validationManager,commands,administrator,0);
	}else{
            commands =arrayListCreate();
            arrayListAddLast(commands,command);
            int result=validationManagerValidateOnCoreExecuteInternalRecurcive(validationManager,commands,administrator,0);
            arrayListFree(commands);
            return result;
	}
}
Esempio n. 5
0
/*
 * serialize Node;
 */
int nodeSerialize( Node node,char ** result){

        NodeInternal* internal=(NodeInternal*)node;
        Array attributes;
        stringHashmapToArray(node->attributes,&attributes);
        void* attributeBuffer;
        int attributeLength;
	int size=SIZE_OF_INT*4;
	int numberOfAttributes=arrayGetLength(attributes);
        int i;
        Attribute attribute;
        for(i=0;i<numberOfAttributes;i++){
            attribute=arrayGetObject(attributes,i);
            size+=attributeSerializeLocal(attribute,&attributeBuffer);
            memoryFree(attributeBuffer);
        }
        stringHashmapIterate(internal->children,registryUpdateNodeBufferSize,(Object)&size);
	
	char * buffer=memoryAlloc(size);
        *result=buffer;
       	memcpy(buffer+SIZE_OF_INT*0,&(internal->schemaId),SIZE_OF_INT);
        memcpy(buffer+SIZE_OF_INT*1,&(internal->id),SIZE_OF_INT);
        memcpy(buffer+SIZE_OF_INT*2,&numberOfAttributes,SIZE_OF_INT);
        buffer+=SIZE_OF_INT*3;
        for(i=0;i<numberOfAttributes;i++){
            attribute=arrayGetObject(attributes,i);
            attributeLength=attributeSerializeLocal(attribute,&attributeBuffer);
            memcpy(buffer,attributeBuffer,attributeLength);
            buffer+=attributeLength;
            memoryFree(attributeBuffer);
        }
        arrayFree(attributes);
        ArrayList list=arrayListCreate();
        stringHashmapIterate(internal->children,registryCreateChildrenBufferElemrnts,list);
	int numberOfChildren=arrayListSize(list);
	memcpy(buffer,&numberOfChildren,SIZE_OF_INT);
        buffer+=SIZE_OF_INT;
	int j;
        for(j=0;j<numberOfChildren;j++){
            void* bufferElement=arrayListGetValueAt(list,j);
            int bufferSize;
            memcpy(&bufferSize,bufferElement+SIZE_OF_INT,SIZE_OF_INT);
            memcpy(buffer,bufferElement,SIZE_OF_INT*2+bufferSize);
            buffer+=SIZE_OF_INT*2+bufferSize;
            memoryFree(bufferElement);
	}
        arrayListFree(list);
	return size;
}