Example #1
0
File: main.c Project: Ribtoks/heap
int main()
{
    FuncFactory stringFunctions;

    SkipList* list = 0;

    FILE* out = 0;

    InitStringFactoryStruct(&stringFunctions);
    list = CreateSkipList(&stringFunctions);

    memset(filename, '\0', MAX_FILENAME_LENGTH*sizeof(char));

    printf("Enter filename :> ");
    gets(filename);


    ProcessFile(filename, list);

    printf("\nAll words:\n");


    PrintList(list);

    if (AskUser("Print results to file?"))
    {
        if ((out = fopen("results.txt", "w+")) == NULL)
        {
            printf("Cannot open file. Press any key to exit.\n");
            getchar();
            exit(-1);
        }

        PrintListToFile(out, FilePrinter, list);
    }

    CleanupList(list);

    printf("Done.\n\nPress any key to exit...");
    getchar();
    return 0;
}
Example #2
0
bool ShareInfo::Checking(DWORD cur, uint64 use_drives, CheckInfo *ci, bool include_myself)
{
	ci->Init();

	uint64	total_used = CleanupList(cur);

	total_used = drvMng->OccupancyDrives(total_used);
	use_drives = drvMng->OccupancyDrives(use_drives);

	bool	need_wait = (total_used & use_drives) ? true : false;

	for (int i=0; i < head->total; i++) {
		Head::Data	&data = head->data[i];

		if (data.mutexCount == selfCount) {
			ci->self_idx = i;
			if (include_myself) {
				data.last = cur;
			}
			else continue;
		}
		bool	is_target = use_drives ? (data.useDrives & use_drives) != 0 : false;

		if (data.mode == TAKE) {
			if (is_target) ci->tgt_running++;
			ci->all_running++;
			ci->use_drives |= data.useDrives;
		}
		else if (data.mode == WAIT) {
			if (is_target) {
				ci->tgt_waiting++;
				if (ci->wait_top_idx == -1) {
					if ((total_used & data.useDrives) == 0 || need_wait) {
						ci->wait_top_idx = i;
					}
				}
			}
			ci->all_waiting++;
		}
	}
	return	true;
}