示例#1
0
文件: primes.c 项目: FoXPeeD/OS-bwis
// Gets node p, deletes all of its multiples (stops if p^2 is missing), and returns the next p
Node handleCandidate(Node p, FILE* f, int i) {
	if (!p)
		return NULL;

	Node p2 = LL_next(p);
	int isFirstThread = 0;
	while (p2 && (isFirstThread || p2->num <= p->num * p->num)) {
		if (p2->num == p->num * p->num) {
			isFirstThread = 1;
			fprintf(f, "Prime %d (by %d).\n", p->num, i);
		}

		// Delete if needed, move on either way.
		if (p2->num % p->num == 0) {
			fprintf(f, "%d\n", p2->num);
			p2 = LL_remove(p2);
		} else
			p2 = LL_next(p2);
	}

	// Reached the end of the list
	int res;
	if (p2) {
		res = release(p2->prev);
		res = release(p2);
	}

	res = acquire(p->prev);

	res = acquire(p);

	p = LL_next(p);
	return p;
}
示例#2
0
int _close_image(Ihandle* self)
{
	//Return if we have no images
	if(!IupGetInt(list, "COUNT"))
		return IUP_DEFAULT;

	//Remove image from the preview
	int index = IupGetInt(list, "VALUE") - 1;
	IupSetAttribute(list, "REMOVEITEM", IupGetAttribute(list, "VALUE"));

	//Set the images displayed to some placeholders (or just wipe everything out)
	IupSetAttributeHandle(preview, "IMAGE", placeholder);
	Ihandle* child;
	while((child = IupGetChild(imgmod, 0)) != NULL)
		IupDestroy(child);

	//Delete the linked list element associated with the image being deleted
	LL_remove(&images, index);

	main_window_set_menu_state();
	return IUP_DEFAULT;
}