示例#1
0
void delete_way(int way,int cont_temp)
{
    char name[256];
    int id_cont;
    stu_t *p,*head;
    FILE *fp1;
    switch(way)
    {
        case 1:
            printf("Please input delete the ID :1~%d:",cont_temp);
            scanf("%d",&id_cont);
            getchar();
            fp1 = fopen("dong.txt","r");
            p = head_1(fp1);
            fclose(fp1);
            head = delete_id(p,id_cont);
            write(head);
            break;
        case 2:
            printf("Please input delete the Name :");
            scanf("%s",name);
            getchar();
            fp1 = fopen("dong.txt","r");
            p = head_1(fp1);
            fclose(fp1);
            head = delete_name(p,name);
            write(head);
        case 3:
            break;
    }
}
示例#2
0
void EntityController::remove_entity(Entity* entity){
	delete_id(entity->get_id());
	if(entity->get_id()<entities.size()){
		//std::cout<<"EntityController::remove_entity id="<<entity->id<<std::endl;
		//std::cout<<"EntityController::remove_entity size="<<entities.size()<<std::endl;
		entities.at(entity->get_id())=0;
	}else{
		std::cerr<<"EntityController::remove_entity(Entity* entity)"<<entity->get_id()
				<<"out if range"<<std::endl;
	}

}
示例#3
0
void _delvec(QSP_ARG_DECL  Data_Obj *dp)
{

	assert(dp!=NULL);
	assert(OBJ_NAME(dp)!=NULL);

#ifdef ZOMBIE_SUPPORT
	// This should go back in eventually!
	if( OBJ_FLAGS(dp) & DT_STATIC && OWNS_DATA(dp) ){
sprintf(ERROR_STRING,"delvec:  static object %s will be made a zombie",OBJ_NAME(dp));
advise(ERROR_STRING);
		make_zombie(dp);
		return;
	}


	if( OBJ_REFCOUNT(dp) > 0 ){
		/* This zombie business was introduced at a time
		 * when a displayed image had to be kept around
		 * to refresh its window...  with the current
		 * X windows implementation of viewers that is
		 * no longer the case, so this may be unecessary...
		 *
		 * But another case arises when we have a static
		 * object in the expression language, that gets
		 * deleted outside of the expression language.
		 * This shouldn't be done, but we don't want to
		 * be able to crash the program either...
		 */

sprintf(ERROR_STRING,"delvec:  object %s (refcount = %d) will be made a zombie",OBJ_NAME(dp),dp->dt_refcount);
advise(ERROR_STRING);
		make_zombie(dp);
		return;
	}
#endif /* ZOMBIE_SUPPORT */

	// If the object has been exported, we need to delete
	// the associated identifier...
	//
	// BUT if it was exported, then it may be referenced!?
	// So it should be static...
	//
	// If we have references, and are therefore keeping the
	// object as a zombie, then we don't want to delete the
	// identifier, and we probably don't want to change the
	// object's name...

	if( IS_EXPORTED(dp) ){
		Identifier *idp;

		idp = id_of(OBJ_NAME(dp));
		assert( idp != NULL );
		delete_id((Item *)idp);
	}

	if( OBJ_CHILDREN( dp ) != NULL ){
		delete_subobjects(dp);
	}
	if( OBJ_PARENT(dp) != NULL ){
		disown_child(dp);
	}

	if( IS_TEMP(dp) ){

if( OBJ_DECLFILE(dp) != NULL ){
sprintf(ERROR_STRING,"delvec %s:  temp object has declfile %s!?\n",
OBJ_NAME(dp),OBJ_DECLFILE(dp));
advise(ERROR_STRING);
}
		release_tmp_obj(dp);
		/*
		 * Most likely called when parent is deleted.
		 * Temp objects are not hashed, and are not dynamically
		 * allocated.
		 *
		 * Simply mark as free by clearing name field.
		 */
		return;
	}

	// We might clean this up by making the release
	// function a platform member...

	if( OWNS_DATA(dp) ){
		if( ! UNKNOWN_SHAPE(OBJ_SHAPE(dp)) ){
			release_data(dp);
		}
	}
	// In the first OpenCL implementation, we used subbuffers, which had
	// to be released here even for subimages.  But now we handle subobjects
	// ourselves, managing offsets, so non-data-owners don't need to release.

	rls_shape( OBJ_SHAPE(dp) );

	// We don't need to do this if we have garbage collection?
	/* The name might be null if we had an error creating the object... */
	if( OBJ_DECLFILE(dp) != NULL ){
		rls_str( OBJ_DECLFILE(dp) );
	}

#ifdef ZOMBIE_SUPPORT
	/* BUG context code assumes that this is really deleted... */
	// not sure I understand the above comment?
	if( IS_ZOMBIE(dp) ){
		// The object is a zombie that is no longer referenced...

		/* NOTE:  we used to release the struct here with givbuf,
		 * but in the current implementation of the item package,
		 * objects aren't allocated with getbuf!
		 */

		// The object has already been removed from the dictionary,
		// so we don't need to call del_item...

		/* put this back on the free list... */
		recycle_item(dobj_itp,dp);
	} else {
		del_item(dobj_itp, dp );
	}
#else /* ! ZOMBIE_SUPPORT */

	DELETE_OBJ_ITEM(dp);	// del_dobj - item function

#endif /* ! ZOMBIE_SUPPORT */

	// used to release the name here
	// and set to null, but that is done in del_item
}