コード例 #1
0
ファイル: corgi_ts.c プロジェクト: E-LLP/n900
static void ts_interrupt_main(struct corgi_ts *corgi_ts, int isTimer)
{
	if ((GPLR(IRQ_TO_GPIO(corgi_ts->irq_gpio)) & GPIO_bit(IRQ_TO_GPIO(corgi_ts->irq_gpio))) == 0) {
		/* Disable Interrupt */
		set_irq_type(corgi_ts->irq_gpio, IRQ_TYPE_NONE);
		if (read_xydata(corgi_ts)) {
			corgi_ts->pendown = 1;
			new_data(corgi_ts);
		}
		mod_timer(&corgi_ts->timer, jiffies + HZ / 100);
	} else {
		if (corgi_ts->pendown == 1 || corgi_ts->pendown == 2) {
			mod_timer(&corgi_ts->timer, jiffies + HZ / 100);
			corgi_ts->pendown++;
			return;
		}

		if (corgi_ts->pendown) {
			corgi_ts->tc.pressure = 0;
			new_data(corgi_ts);
		}

		/* Enable Falling Edge */
		set_irq_type(corgi_ts->irq_gpio, IRQ_TYPE_EDGE_FALLING);
		corgi_ts->pendown = 0;
	}
}
コード例 #2
0
ファイル: message.cpp プロジェクト: Gremory/hpcourse
void message::reserve(uint32_t new_size) {
	if(!data.unique()) {
		std::shared_ptr<char> new_data(new char[new_size], std::default_delete<char[]>());
		data = new_data;
		capacity = new_size;
	} else {
		if(new_size > capacity) {
			std::shared_ptr<char> new_data(new char[new_size], std::default_delete<char[]>());
			data = new_data;
			capacity = new_size;
		}
	}
	size = new_size;
}
コード例 #3
0
ファイル: else.c プロジェクト: Alexey1994/Zubr
char parser_else(Parser *parser)
{
    If *if_data,
       *else_if_data,
       *cur_if;

    if(debug)
    {
        block_pos--;
        print_block();
        printf("ELSE ");
        block_pos++;
    }

    if(parser->cur_block->type!=IF)
    {
        printf("else находится не в if\n");
        return 0;
    }

    if_data=parser->cur_block->data;
    parser->cur_body=if_data->else_body;

    skip(parser);

    if(is_true_word(parser, "if"))
    {
        if(debug)
        {
            printf("IF ");
        }

        else_if_data            = new(If);
        else_if_data->body      = array_init(8);
        else_if_data->else_body = array_init(8);
        else_if_data->condition = parser_get_expression(parser);

        parser->cur_block=new_data(else_if_data, IF);

        array_push(if_data->else_body, parser->cur_block);
        parser->cur_body=else_if_data->body;
    }
    else
        parser->cur_block=new_data(if_data->body, ELSE);

    if(debug)
        printf("\n");

    return 1;
}
コード例 #4
0
struct app_list_t *new_app(void)
{
	struct app_list_t *app = (struct app_list_t *)new_data();
	app->app = malloc(sizeof(*app->app));
	memset(app->app, 0, sizeof(*app->app));
	return app;
}
コード例 #5
0
ファイル: symbols.hpp プロジェクト: LocutusOfBorg/poedit
        T* add(IteratorT first, IteratorT const& last, T const& data)
        {
            assert(first != last);

            node_ptr* np = &root;
            CharT ch = *first;

            for (;;) {
                if (!*np) {
                    *np = new node_t(ch);
                }
                else if ((*np)->reference_count > 1) {
                    *np = new node_t(**np);
                }

                if (ch < (*np)->value) {
                    np = &(*np)->left;
                }
                else if (ch == (*np)->value) {
                    ++first;
                    if (first == last) break;
                    ch = *first;
                    np = &(*np)->middle;
                }
                else {
                    np = &(*np)->right;
                }
            }

            boost::scoped_ptr<T> new_data(new T(data));
            boost::swap((*np)->data, new_data);
            return (*np)->data.get();
        }
コード例 #6
0
ファイル: main-kinetis.c プロジェクト: koson/mchck-os
void
loopback_init(int enable)
{
        if (enable) {
                new_data(NULL, 0);
        }
}
コード例 #7
0
void mp_game_settings::update_addon_requirements(const config & cfg) {
	if (cfg["id"].empty()) {
		WRN_NG << "Tried to add add-on metadata to a game, missing mandatory id field... skipping.\n" << cfg.debug() << "\n";
		return;
	}

	mp_game_settings::addon_version_info new_data(cfg);

	// Check if this add-on already has an entry as a dependency for this scenario. If so, try to reconcile their version info,
	// by taking the larger of the min versions. The version should be the same for all WML from the same add-on...
	std::map<std::string, addon_version_info>::iterator it = addons.find(cfg["id"].str());
	if (it != addons.end()) {
		addon_version_info & addon = it->second;

		if (new_data.version) {
			if (!addon.version || (*addon.version != *new_data.version)) {
				WRN_NG << "Addon version data mismatch -- not all local WML has same version of '" << cfg["id"].str() << "' addon.\n";
			}
		}
		if (addon.version && !new_data.version) {
			WRN_NG << "Addon version data mismatch -- not all local WML has same version of '" << cfg["id"].str() << "' addon.\n";
		}
		if (new_data.min_version) {
			if (!addon.min_version || (*new_data.min_version > *addon.min_version)) {
				addon.min_version = *new_data.min_version;
			}
		}
	} else {
		// Didn't find this addon-id in the map, so make a new entry.
		addons.insert(std::make_pair(cfg["id"].str(), new_data));
	}
}
コード例 #8
0
void MainWindow::on_button_connect_clicked(bool check ) {
    ROS_INFO("TESTE");

	if ( ui.checkbox_use_environment->isChecked() ) {		//using environment variables
		if ( !qnode.init() ) {
			showNoMasterMessage();
		} else {
			ui.button_connect->setEnabled(false);

			//Connect signal from NODE to SLOT in window
            QObject::connect(&qnode, SIGNAL((new_data)), this, SLOT(update_data()));
		}
	} else {
		if ( ! qnode.init(ui.line_edit_master->text().toStdString(),
				   ui.line_edit_host->text().toStdString()) ) {
			showNoMasterMessage();
		} else {

			QObject::connect(&qnode, SIGNAL(new_data()), this, SLOT(update_data()));
			ui.button_connect->setEnabled(false);
			ui.line_edit_master->setReadOnly(true);
			ui.line_edit_host->setReadOnly(true);
			ui.line_edit_topic->setReadOnly(true);
		}
	}
}
コード例 #9
0
ファイル: parse_flags.c プロジェクト: ftibi/libft
t_data	*parse_flags(char **fmt)
{
	t_data	*data;
	char	*format;

	format = (char*)*fmt;
	data = new_data();
	format = parse_opt_flags(format, data);
	format = parse_mwidth_flag(format, data);
	format = parse_prec_flag(format, data);
	while (format && *format && ft_strchr("hljz", *format))
	{
		format = parse_jzh_flags(format, data);
		if (*format == 'l')
		{
			if (*(format + 1) == 'l')
			{
				data->ll = 1;
				format++;
			}
			else
				data->l = 1;
		}
		format++;
	}
	data->fmt = format;
	return (data);
}
コード例 #10
0
struct lib_list_t *new_lib(void)
{
	struct lib_list_t *lib = (struct lib_list_t *)new_data();
	lib->lib = malloc(sizeof(*lib->lib));
	memset(lib->lib, 0, sizeof(*lib->lib));
	return lib;
}
コード例 #11
0
ファイル: g_xrama.c プロジェクト: yhalcyon/Gromacs
static gmx_bool xrCallBack(struct t_x11 *x11, XEvent *event, Window w, void *data)
{
    t_app   *app;
    t_xrama *xr;
    char     buf[256];
    int      i;

    (void)XTextHeight(x11->font);
    app = (t_app *)data;
    xr  = app->xr;
    scx = app->xrwd.width/(2.0*M_PI);
    scy = app->xrwd.height/(2.0*M_PI);
    switch (event->type)
    {
        case Expose:
            XClearWindow(x11->disp, app->xrwd.self);
            XDrawLine(x11->disp, app->xrwd.self, x11->gc,
                      SX(0), SY(-M_PI)+1, SX(0), SY(M_PI)-1);
            XDrawLine(x11->disp, app->xrwd.self, x11->gc,
                      SX(-M_PI)+1, SY(0), SX(M_PI)-1, SY(0));
            TextInRect(x11, app->xrwd.self, "Phi", SX(M_PI)-50, SY(0)+4, 46, 20, eXRight, eYTop);
            TextInRect(x11, app->xrwd.self, "Psi", SX(0)+4, 4, 46, 20, eXLeft, eYTop);
            for (i = 0; (i < xr->npp); i++)
            {
                if (app->bShowGly || !app->bIsGly[i])
                {
                    plot_pp(x11, app->xrwd.self, &(xr->pp[i]), xr->dih);
                }
            }
            break;
        case ButtonPress:
            if (label_pp(x11, app->xrwd.self, xr->npp, xr->pp, xr->dih,
                         event->xbutton.x, event->xbutton.y))
            {
                ExposeWin(x11->disp, app->xrwd.self);
            }
            break;
        case ConfigureNotify:
            app->xrwd.width  = event->xconfigure.width;
            app->xrwd.height = event->xconfigure.height;
            break;
    }
    if (app->status == esGo)
    {
        if (!new_data(app->xr))
        {
            app->status = ebStop;
        }
        else
        {
            ExposeWin(x11->disp, app->xrwd.self);
            sprintf(buf, "Rama: t=%.2f", app->xr->t);
            XSetStandardProperties(x11->disp, app->wd.self, buf,
                                   "Rama", 0, NULL, 0, NULL);

        }
    }
    return FALSE;
}
コード例 #12
0
ファイル: Anneal.cpp プロジェクト: WilliamHua/cpp_practice
std::vector<int> Anneal::swap(const std::vector<int>& data, int a, int b) {
    std::vector<int> new_data(data.size());
    new_data = data;
    int x = new_data.at(a);
    new_data.at(a) = new_data.at(b);
    new_data.at(b) = x;
    return new_data;
}
コード例 #13
0
ファイル: concurrent_queue.hpp プロジェクト: ssteinberg/ste
	void push(T &&new_value) {
		auto ptr = allocator.allocate(1);
		::new (ptr) T(std::move(new_value));

		stored_ptr new_data(ptr);

		push(std::move(new_data));
	}
コード例 #14
0
 void push(T new_value) {
     std::shared_ptr<T> new_data(std::make_shared<T>(new_value));
     node *const old_head = head.load();
     node *p = new node;
     p->data.swap(new_data);
     p->next = old_head;
     head.store(p);
 }
コード例 #15
0
ファイル: message.cpp プロジェクト: Gremory/hpcourse
void* message::getData() {
	if(!data.unique()) {
		std::shared_ptr<char> new_data(new char[size], std::default_delete<char[]>());
		std::memcpy(new_data.get(), data.get(), size);
		data = new_data;
	}
	return data.get();
}
    void push(T new_value) {
/* 7 */ std::shared_ptr<T> new_data(std::make_shared<T>(std::move(new_value)));
/* 8 */ std::unique_ptr<node> p(new node);
/* 9 */ tail->data = new_data;
        node* const new_tail = p.get();
        tail->next = std::move(p);
        tail = new_tail;
    }
コード例 #17
0
ファイル: MapMatrix.cpp プロジェクト: ProjectKidona/game
void MapMatrix::resize(int row, int col) {
	del_data();
	m_row = row;
	m_col = col;
	new_data();
	for (int i = 0; i < getSize(); i++) {
		m_data[i] = 0x00;
	}
}
コード例 #18
0
 void push(T new_value)
 {
     std::shared_ptr<T> new_data(std::make_shared<T>(new_value));
     node* p = new node;
     node* const old_tail = tail.load();
     old_tail->data.swap(new_data);
     old_tail->next = p;
     tail.store(p);
 }
コード例 #19
0
ファイル: MapMatrix.cpp プロジェクト: ProjectKidona/game
MapMatrix::MapMatrix(int row, int col, int* data)
	: m_data(nullptr),
	m_row(row),
	m_col(col)
{
	new_data();
	for (int i = 0; i < getSize(); i++) {
		m_data[i] = data[i];
	}
}
 void push(T new_value) {
     std::shared_ptr<T> new_data(
       std::make_shared<T>(std::move(new_value)));
     std::unique_ptr<node> p(new node());
     const node* new_tail = p.get();
     std::lock_guard<std::mutex> tail_lock(_tail_mutex);
     _tail->data = new_data;
     _tail->next = std::move(p);
     _tail = new_tail;
 }
コード例 #21
0
ファイル: MapMatrix.cpp プロジェクト: ProjectKidona/game
MapMatrix::MapMatrix(const MapMatrix& init)
	: m_data(nullptr),
	m_row(init.getRow()),
	m_col(init.getCol())
{
	new_data();
	for (int i = 0; i < getSize(); i++) {
		m_data[i] = init.m_data[i];
	}
}
コード例 #22
0
ファイル: dbvalue.cpp プロジェクト: vadz/lmi.new
void database_entity::reshape(std::vector<int> const& new_dims)
{
    LMI_ASSERT(e_number_of_axes == new_dims.size());
    LMI_ASSERT(1 == new_dims[0] || e_max_dim_gender    == new_dims[0]);
    LMI_ASSERT(1 == new_dims[1] || e_max_dim_uw_class  == new_dims[1]);
    LMI_ASSERT(1 == new_dims[2] || e_max_dim_smoking   == new_dims[2]);
    LMI_ASSERT(1 == new_dims[3] || e_max_dim_issue_age == new_dims[3]);
    LMI_ASSERT(1 == new_dims[4] || e_max_dim_uw_basis  == new_dims[4]);
    LMI_ASSERT(1 == new_dims[5] || e_max_dim_state     == new_dims[5]);
    LMI_ASSERT(1 <= new_dims[6] && new_dims[6] <= e_max_dim_duration);

    // Number of times we'll go through the assignment loop.
    int n_iter = getndata(new_dims);

    // Create a new instance of this class having the same key but the
    // desired dimensions, for convenient use of operator[]().
    std::vector<double> new_data(n_iter);
    database_entity new_object(key(), new_dims, new_data);

    std::vector<int> dst_max_idx(e_number_of_axes);
    assign(dst_max_idx, new_dims - 1);

    std::vector<int> src_max_idx(e_number_of_axes);
    assign(src_max_idx, axis_lengths_ - 1);

    std::vector<int> dst_idx(e_number_of_axes); // indexes new_object
    std::vector<int> src_idx(e_number_of_axes); // indexes '*this'

    std::vector<int> working_idx(e_number_of_axes);
    for(int j = 0; j < n_iter; j++)
        {
        int z = j;
        std::vector<int>::const_iterator i = new_dims.begin();
        std::vector<int>::iterator w = working_idx.begin();
        while(i != new_dims.end())
            {
            LMI_ASSERT(0 != *i);
            *w = z % *i;
            z /= *i;
            i++;
            w++;
            }
        LMI_ASSERT(0 == z);

        // limit dst and source indexes to those that actually vary
        assign(dst_idx, apply_binary(lesser_of<int>(), working_idx, dst_max_idx));
        assign(src_idx, apply_binary(lesser_of<int>(), working_idx, src_max_idx));
        new_object[dst_idx] = operator[](src_idx);
        }

    axis_lengths_ = new_dims;
    data_values_  = new_object.data_values_;
    assert_invariants();
}
コード例 #23
0
ファイル: zlist_test.c プロジェクト: rocflyhi/glow
int main(int argc, char* argv[])
{
	zlist_t *ls = NULL;
	if (zlist_new(&ls) == S_ERROR)
		return 1;

	zlist_push_back(ls, new_data(2));
	zlist_push_back(ls, new_data(3));
	zlist_push_front(ls, new_data(1));
	zlist_push_front(ls, new_data(0));
	zlist_traversal(ls, traversal);
	printf("\n");

	int d = *(int*)zlist_front(ls);
	printf("head: %d, ", d);
	d = *(int*)zlist_back(ls);
	printf("tail: %d\n", d);

	zlist_push_back(ls, new_data(4));

	d = *(int*)zlist_pop_front(ls);
	printf("pop head: %d, ", d);
	d = *(int*)zlist_pop_back(ls);
	printf("pop tail: %d\n", d);

	zlist_push_front(ls, new_data(0));
	zlist_push_back(ls, new_data(4));
	zlist_push_back(ls, new_data(5));
	zlist_push_back(ls, new_data(6));
	zlist_push_back(ls, new_data(7));
	zlist_traversal(ls, traversal);
	printf("\n");

	zlist_reverse(ls);
	zlist_traversal(ls, traversal);
	printf("\n");

	zlist_delete(ls);
	return 0;
}
コード例 #24
0
void AdjustVertexData(float x_offset, float y_offset)
{
  std::vector<float> new_data(ARRAY_COUNT(vertex_positions));
  memcpy(&new_data[0], vertex_positions, sizeof(vertex_positions));

  for(int i = 0; i < ARRAY_COUNT(vertex_positions); i += 4) {
    new_data[i] += x_offset;
    new_data[i + 1] += y_offset;
  }

  glBindBuffer(GL_ARRAY_BUFFER, position_buffer_object);
  glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(vertex_positions), &new_data[0]);
  glBindBuffer(GL_ARRAY_BUFFER, 0);
}
コード例 #25
0
 void push(T new_value)
 {
     std::shared_ptr<T> new_data(
         std::make_shared<T>(std::move(new_value)));
     std::unique_ptr<node> p(new node);
     {
         std::lock_guard<std::mutex> tail_lock(tail_mutex);
         tail->data = new_data;
         node *const new_tail = p.get();
         tail->next = std::move(p);
         tail = new_tail;
     }
     data_cond.notify_one();
 }
コード例 #26
0
ファイル: gmx_rama.c プロジェクト: martinhoefling/gromacs
int gmx_rama(int argc,char *argv[])
{
  const char *desc[] = {
    "[TT]g_rama[tt] selects the [GRK]phi[grk]/[GRK]psi[grk] dihedral combinations from your topology file",
    "and computes these as a function of time.",
    "Using simple Unix tools such as [IT]grep[it] you can select out", 
    "specific residues."
  };

  FILE      *out;
  t_xrama   *xr;
  int       j;
  output_env_t oenv;
  t_filenm  fnm[] = {
    { efTRX, "-f", NULL,  ffREAD },
    { efTPX, NULL, NULL,  ffREAD },
    { efXVG, NULL, "rama",ffWRITE }
  };
#define NFILE asize(fnm)

  parse_common_args(&argc,argv,PCA_CAN_VIEW | PCA_CAN_TIME | PCA_BE_NICE,
		    NFILE,fnm,0,NULL,asize(desc),desc,0,NULL,&oenv);

		      
  snew(xr,1);
  init_rama(oenv,ftp2fn(efTRX,NFILE,fnm),ftp2fn(efTPX,NFILE,fnm),xr,3);
  
  out=xvgropen(ftp2fn(efXVG,NFILE,fnm),"Ramachandran Plot","Phi","Psi",oenv);
  xvgr_line_props(out,0,elNone,ecFrank,oenv);
  xvgr_view(out,0.2,0.2,0.8,0.8,oenv);
  xvgr_world(out,-180,-180,180,180,oenv);
  fprintf(out,"@    xaxis  tick on\n@    xaxis  tick major 60\n@    xaxis  tick minor 30\n");
  fprintf(out,"@    yaxis  tick on\n@    yaxis  tick major 60\n@    yaxis  tick minor 30\n");
  fprintf(out,"@ s0 symbol 2\n@ s0 symbol size 0.4\n@ s0 symbol fill 1\n");
  
  j=0;
  do {
    plot_rama(out,xr);
    j++;
  } while (new_data(xr));
  fprintf(stderr,"\n");
  ffclose(out);
  
  do_view(oenv,ftp2fn(efXVG,NFILE,fnm),NULL);
  
  thanx(stderr);
  
  return 0;
}
コード例 #27
0
ファイル: odf_process.hpp プロジェクト: sw82arup/DSI-Studio
    virtual void run(Voxel& voxel, VoxelData& data)
    {

        if(!voxel.scheme_balance)
            return;
        if(stored_voxel)// restored btalbe here in case user terminate the recon
        {
            stored_voxel = 0;
            voxel.bvalues = old_bvalues;
            voxel.bvectors = old_bvectors;
        }
        std::vector<float> new_data(new_q_count);
        data.space.swap(new_data);
        image::mat::vector_product(trans.begin(),new_data.begin(),data.space.begin(),image::dyndim(new_q_count,old_q_count));
    }
コード例 #28
0
ファイル: corgi_ts.c プロジェクト: E-LLP/n900
static int corgits_suspend(struct platform_device *dev, pm_message_t state)
{
	struct corgi_ts *corgi_ts = platform_get_drvdata(dev);

	if (corgi_ts->pendown) {
		del_timer_sync(&corgi_ts->timer);
		corgi_ts->tc.pressure = 0;
		new_data(corgi_ts);
		corgi_ts->pendown = 0;
	}
	corgi_ts->power_mode = PWR_MODE_SUSPEND;

	corgi_ssp_ads7846_putget((1u << ADSCTRL_ADR_SH) | ADSCTRL_STS);

	return 0;
}
コード例 #29
0
ファイル: texture_data.cpp プロジェクト: SFTtech/openage
Texture2dData Texture2dData::flip_y() {
	size_t row_size = this->info.get_row_size();
	size_t height = this->info.get_size().second;

	std::vector<uint8_t> new_data(this->data.size());

	for (size_t y = 0; y < height; ++y) {
		std::copy(this->data.data() + row_size * y, this->data.data() + row_size * (y+1), new_data.end() - row_size * (y+1));
	}

	this->data = new_data;

	Texture2dInfo new_info(this->info);

	return Texture2dData(std::move(new_info), std::move(new_data));
}
コード例 #30
0
ファイル: lgrec.cpp プロジェクト: glycerine/shore-mt
rc_t
lgdata_p::append(const vec_t& data, uint4_t start, uint4_t amount)
{
    FUNC(lgdata_p::append);

    // new vector at correct start and with correct size
    if(data.is_zvec()) {
        const zvec_t amt_vec_tmp(amount);            
        W_DO(splice(0, (slot_length_t) tuple_size(0), 0, amt_vec_tmp));
    } else {
        vec_t new_data(data, u4i(start), u4i(amount));
        w_assert9(amount == new_data.size());
        W_DO(splice(0, (slot_length_t) tuple_size(0), 0, new_data));
    }
    return RCOK;
}