Exemple #1
0
void _step_complete_msg_proc(slurm_msg_t* msg)
{
	slurm_send_rc_msg(msg, SLURM_SUCCESS);
	step_complete_msg_t *complete = (step_complete_msg_t*) msg->data;

	/* get the job id */
	char str_job_id[20] = { 0 };
	sprintf(str_job_id, "%u", complete->job_id);
	/* lookup for the origin controller id of this job */
	char *origin_ctrlid = c_calloc(30);
	c_zht_lookup(str_job_id, origin_ctrlid);

	pthread_mutex_lock(&lookup_msg_mutex);
	num_lookup_msg++;
	pthread_mutex_unlock(&lookup_msg_mutex);

	/* concat to get the jobid+origin_ctrlid */
	char *jobid_origin_ctrlid = c_calloc(strlen(origin_ctrlid) + 30 + 2);
	strcat(jobid_origin_ctrlid, str_job_id);
	strcat(jobid_origin_ctrlid, origin_ctrlid);

	/* create the job resource from looking up zht */
	job_resource *a_job_res = _create_job_resource(jobid_origin_ctrlid);
	release_res(a_job_res);
	free_job_resource(a_job_res);

	/* check to see whether this job belongs to the controller */
	if (!strcmp(self_id, origin_ctrlid))
	{
		pthread_mutex_lock(&num_job_fin_mutex);
		num_job_fin++;
		pthread_mutex_unlock(&num_job_fin_mutex);
		unsigned long time_in_micros = get_current_time();
		pthread_mutex_lock(&job_output_mutex);
		fprintf(job_output_file, "%u\tend time\t%lu\n", complete->job_id, time_in_micros);
		pthread_mutex_unlock(&job_output_mutex);
	}
	else	// if it is not, then insert a notification message
	{
		char *key = c_calloc(strlen(jobid_origin_ctrlid) + 5);
		strcat(key, jobid_origin_ctrlid);
		strcat(key, "Fin");
		c_zht_insert(key, "Finished");
		pthread_mutex_lock(&insert_msg_mutex);
		num_insert_msg++;
		pthread_mutex_unlock(&insert_msg_mutex);
		c_free(key);
	}
	c_free(origin_ctrlid);
	c_free(jobid_origin_ctrlid);
	/*pthread_mutex_lock(&lookup_msg_mutex);
	num_lookup_msg += num_lookup_msg_local;
	pthread_mutex_unlock(&lookup_msg_mutex);
	pthread_mutex_lock(&insert_msg_mutex);
	num_insert_msg += num_insert_msg_local;
	pthread_mutex_unlock(&insert_msg_mutex);
	pthread_mutex_lock(&cswap_msg_mutex);
	num_cswap_msg += num_comswap_msg_local;
	pthread_mutex_unlock(&cswap_msg_mutex);*/
}
Exemple #2
0
void _initialize(char* argv[])
{
	slurm_conf_reinit(argv[1]); //load the slurm configuration file
	self_id = strdup(slurmctld_conf.control_machine); //get the controller id

	num_ctrl = str_to_int(argv[2]); // get the number of controllers
	mem_list = c_calloc_2(num_ctrl, 30);

	_read_memlist(argv[3]); // read the controller membership list

	part_size = str_to_int(argv[4]); //get the partition size
	source = c_calloc_2(part_size + 1, 30);

	/* fill the node list of the controller (part_size, node_1, node_2, ...) */
	resource = c_calloc((part_size + 1) * 30);
	strcat(resource, argv[4]); strcat(resource, ",");

	/* read workload and fill it in the job queue*/
	job_queue = init_queue();
	_read_workload(argv[5]);
	num_job = job_queue->queue_length;

	c_zht_init(argv[6], argv[7]); // initialize the controller as a ZHT client

	max_proc_thread = str_to_int(argv[8]);

	char *job_output_path = c_calloc(100);
	strcpy(job_output_path, "./job_output_");
	strcat(job_output_path, argv[9]);
	job_output_file = fopen(job_output_path, "w");
	c_free(job_output_path);
}
Exemple #3
0
extern void append_queue(queue* q, char* job_description)
{
	queue_item *new_item = (queue_item*)malloc(sizeof(queue_item));
	if(new_item == NULL)
	{
		printf("malloc() failed when adding element to the queue!\n");
		return;
	}
	new_item->job_description = c_calloc(100);
	strcpy(new_item->job_description, job_description);
	new_item->next = NULL;
	if(q == NULL)
	{
		printf("Queue has not yet been initialized!\n");
		return;
	}
	else if(q->head == NULL && q->tail == NULL)
	{
		q->head = new_item;
		q->tail = new_item;
		q->queue_length += 1;
		return;
	}
	else if(q->head == NULL || q->tail == NULL)
	{
		printf("The queue is not in the correct format, please check!\n");
		return;
	}
	else
	{
		q->tail->next = new_item;
		q->tail = new_item;
		q->queue_length += 1;
	}
}
Exemple #4
0
void *c_malloc(size_t size) {
  if (size == 0) {
    return NULL;
  }
#undef malloc
  return c_calloc(1, size);
#define malloc(x) DO_NOT_CALL_MALLOC__USE_XMALLOC_INSTEAD
}
Exemple #5
0
extern char* _allocate_node(char* key, char* seen_value, char** seen_value_array,
		int num_node_allocate, int num_node_before, char** query_value)
{
	int i = 0;
	char* nodelist = c_calloc(100 * 100);
	char* new_value = c_calloc(100 * 100);
	int num_node_left = num_node_before - num_node_allocate;
	char *_num_node_left = int_to_str(num_node_left);
	//usleep(1000);
	pthread_mutex_lock(&time_mutex);
	ntime++;
	pthread_mutex_unlock(&time_mutex);
	strcat(new_value, _num_node_left);
	free(_num_node_left);
	strcat(new_value, ",");
	for (i = 0; i < num_node_allocate; i++)
	{
		strcat(nodelist, seen_value_array[i]);
		if (i != num_node_allocate - 1)
		{
			strcat(nodelist, ",");
		}
	}
	for (i = 0; i < num_node_left; i++)
	{
		strcat(new_value, seen_value_array[i + num_node_allocate]);
		if (i != num_node_left - 1)
		{
			strcat(new_value, ",");
		}
	}
	int res = c_zht_compare_and_swap(key, seen_value, new_value, query_value);
	free(new_value);
	if (res)
	{
		return nodelist;
	}
	else
	{
		free(nodelist);
		printf("OK, compare and swap failed!\n");
		return NULL;
	}
}
Exemple #6
0
extern void c_memset(char *str, int size)
{
    if (!str)
    {
	str = c_calloc(size);
    }
    else
    {
	memset(str, '\0', size);
    }
}
Exemple #7
0
void xscCreateBuffer(txMachine* the)
{
	xsBuffer* aBuffer;
	
	aBuffer = c_calloc(1, sizeof(xsBuffer));
	xsElseError(aBuffer);
	aBuffer->bottom = c_malloc(1024);
	xsElseError(aBuffer->bottom);
	aBuffer->current = aBuffer->bottom;
	aBuffer->top = aBuffer->bottom + 1024;
	aBuffer->symbols = NULL;
	aBuffer->symbolsSize = 0;
	xsSetContext(the, aBuffer);
}
Exemple #8
0
job_resource *_create_job_resource(char* jobid_origin_ctrlid)
{
	long num_lookup_msg_local = 0L;
	job_resource *a_job_res = init_job_resource();

	/* get the involved controller list in one dimension array*/
	char *jobid_origin_ctrlid_ctrls = c_calloc(strlen(jobid_origin_ctrlid) + 7);
	strcat(jobid_origin_ctrlid_ctrls, jobid_origin_ctrlid);
	strcat(jobid_origin_ctrlid_ctrls, "ctrls");
	c_zht_lookup(jobid_origin_ctrlid_ctrls, a_job_res->ctrl_ids_1);
	num_lookup_msg_local++;
	c_free(jobid_origin_ctrlid_ctrls);

	/* split the one dimension of involved controller list to two dimension */
	char *ctrl_ids_1_backup = strdup(a_job_res->ctrl_ids_1);
	a_job_res->num_ctrl = split_str(ctrl_ids_1_backup, ",", a_job_res->ctrl_ids_2);

	/* get the allocated nodelist for each involved controller*/
	char *jobid_origin_ctrlid_invid = c_calloc(strlen(jobid_origin_ctrlid) + 30 + 2);

	int i = 0;
	for (; i < a_job_res->num_ctrl; i++)
	{
		strcat(jobid_origin_ctrlid_invid, jobid_origin_ctrlid);
		strcat(jobid_origin_ctrlid_invid, a_job_res->ctrl_ids_2[i]);
		c_zht_lookup(jobid_origin_ctrlid_invid, a_job_res->node_alloc[i]);
		num_lookup_msg_local++;
		c_memset(jobid_origin_ctrlid_invid, strlen(jobid_origin_ctrlid_invid));
	}

	pthread_mutex_lock(&lookup_msg_mutex);
	num_lookup_msg += num_lookup_msg_local;
	pthread_mutex_unlock(&lookup_msg_mutex);

	return a_job_res;
}
Exemple #9
0
txMachine* fxCloneMachine(txCreation* theCreation, txMachine* theMachine, txString theName, void* theContext)
{
	txMachine* the = (txMachine *)c_calloc(sizeof(txMachine), 1);
	if (the) {
		txJump aJump;

		aJump.nextJump = C_NULL;
		aJump.stack = C_NULL;
		aJump.scope = C_NULL;
		aJump.frame = C_NULL;
		aJump.code = C_NULL;
		aJump.flag = 0;
		the->firstJump = &aJump;
		if (c_setjmp(aJump.buffer) == 0) {
			txInteger anIndex;
			txSlot* aSlot;
			txSlot** aSlotAddress;
			txSlot* aSharedSlot;
			txSlot* aTemporarySlot;
			txID anID;

		#if __FSK_LAYER__
			FskInstrumentedItemNew(the, theName, &gXSTypeInstrumentation);
		#endif

		#ifdef mxDebug
			the->echoSize = 1 * 1024;
			the->echoBuffer = (txString)c_malloc(the->echoSize);
			if (!the->echoBuffer)
				fxJump(the);
			//fxConnect(the);
			the->name = theName;
			the->sorter = (txSlot**)c_malloc(theCreation->keyCount * sizeof(txSlot*));
			if (!the->sorter)
				fxJump(the);
			the->breakOnExceptionFlag = 1;
		#endif
		#ifdef mxProfile
			the->profileID = theMachine->profileID;
			the->profileBottom = c_malloc(XS_PROFILE_COUNT * sizeof(txProfileRecord));
			if (!the->profileBottom)
				fxJump(the);
			the->profileCurrent = the->profileBottom;
			the->profileTop = the->profileBottom + XS_PROFILE_COUNT;
		#endif

			the->archive = theMachine->archive;

			the->dtoa = fxNew_dtoa();
			if (!the->dtoa)
				fxJump(the);
			theCreation->keyCount = theMachine->keyCount;
			theCreation->nameModulo = theMachine->nameModulo;
			theCreation->symbolModulo = theMachine->symbolModulo;

			fxAllocate(the, theCreation);

			the->sharedMachine = theMachine;

            c_memcpy(the->nameTable, theMachine->nameTable, the->nameModulo * sizeof(txSlot *));
			c_memcpy(the->symbolTable, theMachine->symbolTable, the->symbolModulo * sizeof(txSlot *));
			c_memcpy(the->keyArray, theMachine->keyArray, the->keyCount * sizeof(txSlot *));
			the->keyIndex = theMachine->keyIndex;
			the->keyOffset = the->keyIndex;
		
			the->aliasCount = theMachine->aliasCount;
			the->aliasArray = (txSlot **)c_calloc(the->aliasCount, sizeof(txSlot*));
			if (!the->aliasArray)
				fxJump(the);

			/* mxGlobal */
			fxNewInstance(the);
			aSlot = the->stack->value.reference;
			aSlot->flag = XS_VALUE_FLAG;
			aSlot->next = fxNewSlot(the);
			aSlot = aSlot->next;
			aSlot->value.table.address = (txSlot**)fxNewChunk(the, theCreation->keyCount * sizeof(txSlot*));
			aSlot->value.table.length = theCreation->keyCount;
			aSlot->kind = XS_GLOBAL_KIND;
			c_memset(aSlot->value.table.address, 0, theCreation->keyCount * sizeof(txSlot*));
			aSlotAddress = aSlot->value.table.address;
			aSharedSlot = theMachine->stackTop[-1].value.reference->next->next;
			while (aSharedSlot) {
				aSlot->next = aTemporarySlot = fxDuplicateSlot(the, aSharedSlot);
				anID = aTemporarySlot->ID & 0x7FFF;
				aSlotAddress[anID] = aTemporarySlot;
				aSharedSlot = aSharedSlot->next;
				aSlot = aSlot->next;
			}
			/* mxException */
			mxPushUndefined();
			for (anIndex = mxObjectPrototypeStackIndex; anIndex < mxModulePathsStackIndex; anIndex++)
				*(--the->stack) = theMachine->stackTop[-1 - anIndex];
			
			/* mxModulePaths */
			mxPushUndefined();
			/* mxImportingModules */
			fxNewInstance(the);
			/* mxLoadingModules */
			fxNewInstance(the);
			/* mxLoadedModules */
			fxNewInstance(the);
			/* mxResolvingModules */
			fxNewInstance(the);
			/* mxRunningModules */
			fxNewInstance(the);
			/* mxRequiredModules */
			fxNewInstance(the);
			/* mxModules */
			mxPushUndefined();
			/* mxPendingJobs */
			fxNewInstance(the);
			/* mxRunningJobs */
			fxNewInstance(the);
			/* mxFiles */
			mxPushList();
		#ifdef mxDebug
			aSharedSlot = theMachine->stackTop[-1 - mxFilesStackIndex].value.list.first;
			aSlotAddress = &(the->stack->value.list.first);
			while (aSharedSlot) {
				*aSlotAddress = fxDuplicateSlot(the, aSharedSlot);
				aSharedSlot = aSharedSlot->next;
				aSlotAddress = &((*aSlotAddress)->next);
			}
		#endif
			/* mxBreakpoints */
			mxPushList();
			/* shared */
			for (anIndex = mxHostsStackIndex; anIndex < mxStackIndexCount; anIndex++)
				*(--the->stack) = theMachine->stackTop[-1 - anIndex];
			
			mxPush(mxSetPrototype);
			fxNewSetInstance(the);
			mxPull(mxModulePaths);
			
			mxPush(mxObjectPrototype);
			fxNewWeakSetInstance(the);
			mxPull(mxModules);

			the->collectFlag = XS_COLLECTING_FLAG;
			the->context = theContext;

		#ifdef mxDebug
			if (fxGetAutomatic(the))
				fxLogin(the);
		#endif

			the->firstJump = C_NULL;

		}
		else {
		#if __FSK_LAYER__
			FskInstrumentedItemDispose(the);
		#endif

			fxFree(the);
			c_free(the);
			the = NULL;
		}
	}
	return the;
}
Exemple #10
0
txMachine* fxCreateMachine(txCreation* theCreation, void* theArchive, txString theName, void* theContext)
{
	txMachine* the = (txMachine* )c_calloc(sizeof(txMachine), 1);
	if (the) {
		txJump aJump;

		aJump.nextJump = C_NULL;
		aJump.stack = C_NULL;
		aJump.scope = C_NULL;
		aJump.frame = C_NULL;
		aJump.code = C_NULL;
		aJump.flag = 0;
		the->firstJump = &aJump;
		if (c_setjmp(aJump.buffer) == 0) {
			txInteger anIndex;

		#if __FSK_LAYER__
			FskInstrumentedItemNew(the, NULL, &gXSTypeInstrumentation);
		#endif

		#ifdef mxDebug
			the->echoSize = 1 * 1024;
			the->echoBuffer = (txString)c_malloc(the->echoSize);
			if (!the->echoBuffer)
				fxJump(the);
			//fxConnect(the);
			the->connection = mxNoSocket;
			the->name = theName;
			the->sorter = (txSlot**)c_malloc(theCreation->keyCount * sizeof(txSlot*));
			if (!the->sorter)
				fxJump(the);
			the->breakOnExceptionFlag = 1;
		#endif
		#ifdef mxProfile
			the->profileID = 1;
			the->profileBottom = c_malloc(XS_PROFILE_COUNT * sizeof(txProfileRecord));
			if (!the->profileBottom)
				fxJump(the);
			the->profileCurrent = the->profileBottom;
			the->profileTop = the->profileBottom + XS_PROFILE_COUNT;
		#endif

			the->archive = theArchive;
			
			the->dtoa = fxNew_dtoa();
			if (!the->dtoa)
				fxJump(the);
				
			fxAllocate(the, theCreation);

			/* mxGLobal */
			mxPushUndefined();
			/* mxException */
			mxPushUndefined();
			for (anIndex = mxObjectPrototypeStackIndex; anIndex < mxModulePathsStackIndex; anIndex++)
				mxPushUndefined();
			/* mxModulePaths */
			mxPushUndefined();
			/* mxImportingModules */
			fxNewInstance(the);
			/* mxLoadingModules */
			fxNewInstance(the);
			/* mxLoadedModules */
			fxNewInstance(the);
			/* mxResolvingModules */
			fxNewInstance(the);
			/* mxRunningModules */
			fxNewInstance(the);
			/* mxRequiredModules */
			fxNewInstance(the);
			/* mxModules */
			mxPushUndefined();
			/* mxPendingJobs */
			fxNewInstance(the);
			/* mxRunningJobs */
			fxNewInstance(the);
			/* mxFiles */
			mxPushList();
			/* mxBreakpoints */
			mxPushList();
			
			/* mxHosts */
			mxPushUndefined();
			/* mxIDs */
			mxPushUndefined();
			/* mxEmptyCode */
			mxPushUndefined();
			the->stack->value.code = (txByte *)fxNewChunk(the, sizeof(gxNoCode));
			c_memcpy(the->stack->value.code, gxNoCode, sizeof(gxNoCode));
			the->stack->kind = XS_CODE_KIND;	
			/* mxEmptyString */
			mxPushStringC("");
			/* mxBooleanString */
			mxPushStringC("boolean");
			/* mxDefaultString */
			mxPushStringC("default");
			/* mxFunctionString */
			mxPushStringC("function");
			/* mxNumberString */
			mxPushStringC("number");
			/* mxObjectString */
			mxPushStringC("object");
			/* mxStringString */
			mxPushStringC("string");
			/* mxSymbolString */
			mxPushStringC("symbol");
			/* mxUndefinedString */
			mxPushStringC("undefined");
			for (anIndex = mxGetArgumentFunctionStackIndex; anIndex < mxStackIndexCount; anIndex++) 
				mxPushUndefined();
			
			fxBuildKeys(the);
			fxBuildGlobal(the);
			fxBuildObject(the);
			fxBuildFunction(the);
			fxBuildGenerator(the);
			fxBuildArray(the);
			fxBuildString(the);
			fxBuildBoolean(the);
			fxBuildNumber(the);
			fxBuildDate(the);
			fxBuildMath(the);
			fxBuildRegExp(the);
			fxBuildError(the);
			fxBuildJSON(the);
			fxBuildDataView(the);
			fxBuildPromise(the);
			fxBuildSymbol(the);
			fxBuildProxy(the);
			fxBuildMapSet(the);
			fxBuildModule(the);
			fxBuildHost(the);
			
			mxPush(mxSetPrototype);
			fxNewSetInstance(the);
			mxPull(mxModulePaths);
			
			mxPush(mxObjectPrototype);
			fxNewWeakSetInstance(the);
			mxPull(mxModules);
			
            the->collectFlag = XS_COLLECTING_FLAG;
			
            /*{
				int c = 32;
				while (--c)
					fxCollectGarbage(the);
			}*/
			the->context = theContext;

		#ifdef mxDebug
			if (fxGetAutomatic(the))
				fxLogin(the);
		#endif

			the->firstJump = C_NULL;
		}
		else {
		#if __FSK_LAYER__
			FskInstrumentedItemDispose(the);
		#endif
			fxFree(the);
			c_free(the);
			the = NULL;
		}
	}
	return the;
}
Exemple #11
0
void xscBuildSymbols(txMachine* the)
{
	xsBuffer* aBuffer = xsGetContext(the);
	xsSymbolsData* data = NULL;
	FILE* aFile = NULL;
	txInteger aSize;
	txString aString = NULL;
	txID aCount;
	txID anID;
	txSlot* aSymbol;
	txSize aModulo;
	txSlot* result;
	txID anIndex;
	txByte* aCode;
	txInteger aLength;
	txBoolean failed;
	static char* prefix = "#define xsID_";
	static char* suffix = " (the->code[";
	txInteger prefixLength = c_strlen(prefix);
	txInteger suffixLength = c_strlen(suffix);
	
	mxTry(the) {
		data = c_calloc(1, sizeof(xsSymbolsData));
		xsElseError(data);

		xsVar(1) = xsCat2(xsVar(0), xsString(".h"));
		aFile = fopen(xsToString(xsVar(1)), "rb");
		if (aFile) {
			fseek(aFile, 0, SEEK_END);
			aSize = ftell(aFile);
			rewind(aFile);
			aString = c_malloc(aSize + 1);
			xsElseError(aString);
			fread(aString, 1, aSize, aFile);
			aString[aSize] = 0;
			fclose(aFile);
			aFile = C_NULL;
		}
		
		aCount = 0;
		if (aString) {
			txString p = c_strstr(aString, prefix), q;
			while (p) {
				p += prefixLength;
				q = c_strstr(p, suffix);
				q += suffixLength;
				anID = c_strtol(q, &p, 10);
				if (aCount <= anID)
					aCount = anID + 1;
				p = c_strstr(p, prefix);
			}
		}
		if (aCount < the->symbolCount)
			aCount = the->symbolCount;
			
		data->symbolCount = aCount;
		data->symbolIndex = 0;
		data->symbolArray = c_calloc(aCount, sizeof(txSlot*));
		xsElseError(data->symbolArray);
		data->symbolModulo = the->symbolModulo;
		data->symbolTable = c_calloc(the->symbolModulo, sizeof(txSlot*));
		xsElseError(data->symbolTable);
	
		if (aString) {
			txString p = c_strstr(aString, prefix), q;
			while (p) {
				p += prefixLength;
				q = c_strstr(p, suffix);
				*q = 0;
				aSymbol = fxNewSymbolC(the, p);
				aModulo = aSymbol->value.symbol.sum % data->symbolModulo;
				q += suffixLength;
				anID = c_strtol(q, &p, 10);
				xscBuildSymbol(the, data, aSymbol, anID, aModulo);
				data->symbolIndex = anID + 1;
				p = c_strstr(p, prefix);
			}
			c_free(aString);
			aString = C_NULL;
		}
			
		aCount = the->symbolIndex;
		anID = 0;
		for (anIndex = 0; anIndex < aCount; anIndex++) {
			aSymbol = the->symbolArray[anIndex];
			if (aSymbol->flag & XS_TO_C_FLAG) {
				aModulo = aSymbol->value.symbol.sum % data->symbolModulo;
				result = data->symbolTable[aModulo];
				while (result != C_NULL) {
					if (result->value.symbol.sum == aSymbol->value.symbol.sum)
						#if mxCmpStr
						if (result->value.symbol.string == aSymbol->value.symbol.string)
						#endif	
							break;
					result = result->next;
				}
				if (result == C_NULL) {
					while (data->symbolArray[anID])
						anID++;
					xscBuildSymbol(the, data, aSymbol, anID, aModulo);
					if (data->symbolIndex <= anID)
						data->symbolIndex = anID + 1;
				}
			}
		}
		
		aCount = data->symbolIndex;
		anIndex = 0;
		while (anID < aCount) {
			while ((anID < aCount) && data->symbolArray[anID])
				anID++;
			if (anID < aCount) {
				char aName[16];
				sprintf(aName, "@%d", anIndex);
				aSymbol = fxNewSymbolC(the, aName);
				aModulo = aSymbol->value.symbol.sum % data->symbolModulo;
				xscBuildSymbol(the, data, aSymbol, anID, aModulo);
			}
		}
		
		aCode = aBuffer->bottom;
		xscBuildSymbolsCode(the, data, aCode);
		aCount = data->symbolIndex;
		
		aSize = 2;
		for (anIndex = 0; anIndex < aCount; anIndex++)
			aSize += strlen(data->symbolArray[anIndex]->value.symbol.string) + symbolEncodeLength + 1;
		aBuffer->symbols = c_malloc(aSize);
		xsElseError(aBuffer->symbols);
		aBuffer->symbolsSize = aSize;
		
		aCode = aBuffer->symbols;
		mxEncode2(aCode, aCount);
		for (anIndex = 0; anIndex < aCount; anIndex++) {
			aString = data->symbolArray[anIndex]->value.symbol.string;
			aLength = strlen(aString) + 1;
			memcpy(aCode, aString, aLength);
			aCode += aLength;
#if mxUseApHash
			mxEncode4(aCode,data->symbolArray[anIndex]->value.symbol.sum);
#endif
		}
		aString = C_NULL;
		failed = 0;
	}
	mxCatch(the) {
		failed = 1;
	}	
	if (data) {
		if (data->symbolTable)
			c_free(data->symbolTable);
		if (data->symbolArray) {
			aCount = data->symbolIndex;
			for (anIndex = 0; anIndex < aCount; anIndex++)
				c_free(data->symbolArray[anIndex]);
			c_free(data->symbolArray);
		}
		if (aString)
			c_free(aString);
		if (aFile)
			fclose(aFile);
		c_free(data);
	}
	if (failed)
		xsThrow(xsException);
}
Exemple #12
0
extern char* int_to_str(int num)
{
	char *str = c_calloc(20);
	sprintf(str, "%d", num);
	return str;
}