コード例 #1
0
ファイル: linked_list.c プロジェクト: tjhei/fgmpi
/**
 * add a data item to the front of the list
 **/
void pl_add_head(pointer_list_t *pl, const void *data)
{
  pointer_list_entry_t *e;

  e = (pointer_list_entry_t*) ll_add_head(pl);
  e->data = data;
}
コード例 #2
0
ファイル: dllmain.c プロジェクト: cbh34680/jbx
static int on_OK_read_chunk(const struct jbxm_initconf_st* iconf,
	struct jbxm_callback_if_st* cbif)
{
	assert(iconf);
	assert(cbif);
	assert(cbif->type == JBXM_CBT_OK_RCHUNK);
	assert(cbif->io_area->avail > 0);

	struct UserData_st* ud = dbGET(cbif, "user-data");
	assert(ud);

	// available cbif->io_area->buff[0 to cbif->io_area->avail] + '\0'

#if LOG_PRINT_ON
logPRINTF("read chunk [%s] %zd", cbif->io_area->buff, cbif->io_area->avail);
#endif

	unsigned char* buff = cbif->io_area->buff;
	cbif->io_area->buff = NULL;					 // move memory

// reverse
	char* revstr = new_lua_strrev(ud->luaS, iconf->dllargv[1], (char*)buff);

	free(buff);
	buff = NULL;

	if (! revstr)
	{
		errPRINTF("reverse error");

		return -1;
	}

#if LOG_PRINT_ON
logPRINTF("revstr [%s] %zu", revstr, strlen(revstr));
#endif

	void* ok = ll_add_head(ud->chunks, revstr);
	if (! ok)
	{
		errPRINTF("ll_add_head");

		return -1;
	}

	// [if buff is string]
	//fprintf(stderr, "read [%.*s]\n", (int)cbif->io_area->avail, cbif->io_area->buff);

	// set cbif->flow->next_events if necessary

	return 0;
}