Пример #1
0
 ~library_unloader(){ free_library(lib_);  }
Пример #2
0
/* used in headerbuttons.c image.c mesh.c screen.c sound.c and library.c */
void free_libblock(ListBase *lb, void *idv)
{
	ID *id= idv;

#ifdef WITH_PYTHON
	BPY_id_release(id);
#endif

	switch( GS(id->name) ) {	/* GetShort from util.h */
		case ID_SCE:
			free_scene((Scene *)id);
			break;
		case ID_LI:
			free_library((Library *)id);
			break;
		case ID_OB:
			free_object((Object *)id);
			break;
		case ID_ME:
			free_mesh((Mesh *)id);
			break;
		case ID_CU:
			free_curve((Curve *)id);
			break;
		case ID_MB:
			free_mball((MetaBall *)id);
			break;
		case ID_MA:
			free_material((Material *)id);
			break;
		case ID_TE:
			free_texture((Tex *)id);
			break;
		case ID_IM:
			free_image((Image *)id);
			break;
		case ID_LT:
			free_lattice((Lattice *)id);
			break;
		case ID_LA:
			free_lamp((Lamp *)id);
			break;
		case ID_CA:
			free_camera((Camera*) id);
			break;
		case ID_IP:
			free_ipo((Ipo *)id);
			break;
		case ID_KE:
			free_key((Key *)id);
			break;
		case ID_WO:
			free_world((World *)id);
			break;
		case ID_SCR:
			free_screen((bScreen *)id);
			break;
		case ID_VF:
			free_vfont((VFont *)id);
			break;
		case ID_TXT:
			free_text((Text *)id);
			break;
		case ID_SCRIPT:
			//XXX free_script((Script *)id);
			break;
		case ID_SPK:
			free_speaker((Speaker *)id);
			break;
		case ID_SO:
			sound_free((bSound*)id);
			break;
		case ID_GR:
			free_group_objects((Group *)id);
			break;
		case ID_AR:
			free_armature((bArmature *)id);
			break;
		case ID_AC:
			free_action((bAction *)id);
			break;
		case ID_NT:
			ntreeFreeTree((bNodeTree *)id);
			break;
		case ID_BR:
			free_brush((Brush *)id);
			break;
		case ID_PA:
			psys_free_settings((ParticleSettings *)id);
			break;
		case ID_WM:
			if(free_windowmanager_cb)
				free_windowmanager_cb(NULL, (wmWindowManager *)id);
			break;
		case ID_GD:
			free_gpencil_data((bGPdata *)id);
			break;
	}

	if (id->properties) {
		IDP_FreeProperty(id->properties);
		MEM_freeN(id->properties);
	}

	BLI_remlink(lb, id);

	/* this ID may be a driver target! */
	BKE_animdata_main_cb(G.main, animdata_dtar_clear_cb, (void *)id);

	MEM_freeN(id);
}
Пример #3
0
//int* adduser(int booknum);
//int userexist ();
int main()
{
	struct library *library = alloc_library();
	if (!library){
		printf("Failed to allocate library");
		return -1;
	}
	char input[80];
	char input2[80];
	int exit = 0;
	int ret;
	int menu;
	//i=0,booknum=0;
	while (!exit){
		printf("CHOOSE AN OPTION\n");
		scanf("%d",&menu);
		switch (menu)
		{
			case 1:
			scanf("%s", input);
			ret = add_user(library, input);
			if (ret < 0){
				printf("Failed to allocate memory\n");
				exit = 1;
				break;
			}
			if (ret == 1){
				printf("ERROR\n");
				break;
			}
			printf("User added\n");
			break;
		case 2:
			scanf("%s", input);
			ret = add_book(library, input);
			if (ret < 0){
				printf("Failed to allocate memory\n");
				exit = 1;
				break;
			}
			if (ret == 1){
				printf("ERROR\n");
				break;
			}
			printf("Book added\n");
			break;
		case 3:
			scanf("%s", input);
			ret = remove_book(library, input);
			if (ret == 1){
				printf("error\n");
				break;
			}
			printf("removed\n");
			break;
		case 4:
			scanf("%s", input);
			scanf("%s", input2);
			ret = take_book(library, input, input2);
			switch (ret){
				case -1:
					printf("Failed to allocate memory\n");
					exit = 1;
					break;
				case 1:
				case 2:
					printf("ERROR\n");
					break;
				case 3:
					printf("IN USE\n");
					break;
				default:
					printf("SUCESS\n");
					break;

			}
			break;
		case 5:
			scanf("%s", input);
			scanf("%s", input2);
			ret = return_book(library, input, input2);
			switch (ret){
				case 1:
				case 2:
					printf("ERROR\n");
					break;
				case 3:
					printf("NOT IN YOUR USE\n");
					break;
				default:
					printf("SUCESS\n");
			}
			break;
		case 6:
			scanf("%s", input);
			ret = print_user_info(library, input);
			if (ret == 1){
				printf("ERROR\n");
			}
			break;
		case 7:
			exit = 1;
			printf("BYE\n");
			break;
		}
	}
	free_library(library);
	return 0;
}