本文整理汇总了C++中HASH_FIND_INT函数的典型用法代码示例。如果您正苦于以下问题:C++ HASH_FIND_INT函数的具体用法?C++ HASH_FIND_INT怎么用?C++ HASH_FIND_INT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了HASH_FIND_INT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HASH_FIND_INT
inline js_type_class_t *js_get_type_from_native(T* native_obj) {
js_type_class_t *typeProxy;
long typeId = cocos2d::getHashCodeByString(typeid(*native_obj).name());
HASH_FIND_INT(_js_global_type_ht, &typeId, typeProxy);
if (!typeProxy) {
cocos2d::TypeInfo *typeInfo = dynamic_cast<cocos2d::TypeInfo *>(native_obj);
if (typeInfo) {
typeId = typeInfo->getClassTypeInfo();
} else {
typeId = cocos2d::getHashCodeByString(typeid(T).name());
}
HASH_FIND_INT(_js_global_type_ht, &typeId, typeProxy);
}
return typeProxy;
}
示例2: HASH_FIND_INT
page_node *add_page(stored_object *object, uint32_t page_id)
{
page_node *curr,*page;
HASH_FIND_INT(global_page_table,&page_id,page);
if(page)
{
printf("ERROR[add_page] Object %lu already contains page %d\n",page->object_id,page_id);
return NULL;
}
object->size += PAGE_SIZE;
if(object->pages == NULL)
{
page = allocate_new_page(object->id,page_id);
HASH_ADD_INT(global_page_table, page_id, page);
object->pages = page;
return object->pages;
}
for(curr=page=object->pages; page && page->page_id != page_id; curr=page,page=page->next)
;
if(page)
{
printf("ERROR[add_page] Object %lu already contains page %d\n",page->object_id,page_id);
return NULL;
}
page = allocate_new_page(object->id,page_id);
HASH_ADD_INT(global_page_table, page_id, page);
curr->next = page;
return curr->next;
}
示例3: HASH_FIND_INT
void CCActionManager::removeAllActionsFromTarget(CAObject *pTarget)
{
// explicit null handling
if (pTarget == NULL)
{
return;
}
tHashElement *pElement = NULL;
HASH_FIND_INT(m_pTargets, &pTarget, pElement);
if (pElement)
{
if (ccArrayContainsObject(pElement->actions, pElement->currentAction) && (! pElement->currentActionSalvaged))
{
pElement->currentAction->retain();
pElement->currentActionSalvaged = true;
}
ccArrayRemoveAllObjects(pElement->actions);
if (m_pCurrentTarget == pElement)
{
m_bCurrentTargetSalvaged = true;
}
else
{
deleteHashElement(pElement);
}
}
else
{
// CCLOG("CrossApp: removeAllActionsFromTarget: Target not found");
}
}
示例4: HASH_FIND_INT
struct mystruct *find_key(off_t st_size)
{
struct mystruct *s;
HASH_FIND_INT(myfiles, &st_size, s);
return s;
}
示例5: farray_create
/**
* Return an array of prototypes labeled with cluster numbers
* @param c cluster structure
* @param a assignment of prototypes
* @param p prototypes
* @return rejected feature vectors
*/
farray_t *cluster_get_prototypes(cluster_t *c, assign_t *a, farray_t *p)
{
int i;
farray_t *n = farray_create("prototypes");
count_t *hash = NULL, *entry;
for (i = 0; i < a->len; i++) {
/* Skip rejected clusters */
if (!c->cluster[i])
continue;
/* Check if prototype has been added */
int j = a->proto[i];
HASH_FIND_INT(hash, &j, entry);
if (entry)
continue;
/* Add new prototype */
entry = malloc(sizeof(count_t));
entry->label = j;
HASH_ADD_INT(hash, label, entry);
/* Add prototype */
farray_add(n, fvec_clone(p->x[j]), cluster_get_name(c, i));
}
/* Delete hash table */
while (hash) {
entry = hash;
HASH_DEL(hash, entry);
free(entry);
}
return n;
}
示例6: erl_element
ETERM *space_delete(ETERM *fromp, ETERM *argp) {
// get the args
ETERM *space_refp = erl_element(1, argp);
erlmunk_space *s;
int space_id = ERL_REF_NUMBER(space_refp);
HASH_FIND_INT(erlmunk_spaces, &space_id, s);
// remove all subscribers
for(erlmunk_subscriber *subscriber = s->subscribers; subscriber != NULL;
subscriber = subscriber->hh.next) {
space_remove_subscriber(s, subscriber);
}
// remove all bodies
for(erlmunk_body *b = s->bodies; b != NULL;
b = b->hh.next) {
erlmunk_body_data *data = cpBodyGetUserData(b->body);
if (data->term != NULL)
erl_free_compound(data->term);
free(data);
cpSpaceRemoveBody(s->space, b->body);
cpBodyDestroy(b->body);
cpBodyFree(b->body);
space_remove_body_hash(s, b);
}
return NULL;
}
示例7: consolidate_gpos_single
bool consolidate_gpos_single(otfcc_Font *font, table_OTL *table, otl_Subtable *_subtable,
const otfcc_Options *options) {
subtable_gpos_single *subtable = &(_subtable->gpos_single);
gpos_single_hash *h = NULL;
for (glyphid_t k = 0; k < subtable->length; k++) {
if (!GlyphOrder.consolidateHandle(font->glyph_order, &subtable->items[k].target)) {
logWarning("[Consolidate] Ignored missing glyph /%s.\n", subtable->items[k].target.name);
continue;
}
gpos_single_hash *s;
int fromid = subtable->items[k].target.index;
HASH_FIND_INT(h, &fromid, s);
if (s) {
logWarning("[Consolidate] Detected glyph double-mapping about /%s.\n", subtable->items[k].target.name);
} else {
NEW(s);
s->fromid = subtable->items[k].target.index;
s->fromname = sdsdup(subtable->items[k].target.name);
s->v = subtable->items[k].value;
HASH_ADD_INT(h, fromid, s);
}
}
HASH_SORT(h, gpos_by_from_id);
iSubtable_gpos_single.clear(subtable);
gpos_single_hash *s, *tmp;
HASH_ITER(hh, h, s, tmp) {
iSubtable_gpos_single.push(subtable,
((otl_GposSingleEntry){
.target = Handle.fromConsolidated(s->fromid, s->fromname), .value = s->v,
}));
示例8: del_giga_fi
void del_giga_fi(int fd)
{
giga_file_info_t *info;
HASH_FIND_INT(_open_files, &fd, info);
if(info != NULL)
HASH_DEL(_open_files, info);
}
示例9: HASH_FIND_INT
struct fl_url_filter *find_filter(int url_id)
{
struct fl_url_filter *s;
HASH_FIND_INT(filters, &url_id, s); /* s: output pointer */
return s;
}
示例10: allocate_file_descriptor_table
struct file_descriptor_table * allocate_file_descriptor_table(int pid) {
struct file_descriptor_table * result_table;
HASH_FIND_INT(file_descriptor_tables, &pid, result_table);
if (result_table == NULL) {
int i;
struct file_descriptor_table * table = (struct file_descriptor_table *) malloc(sizeof(struct file_descriptor_table));
table->pid = pid;
table->entries = (struct file_descriptor_entry *) malloc(8 * sizeof(struct file_descriptor_entry));
table->total_descriptors = 8;
table->used_descriptors = 3;
table->entries[0].fd = 0;
table->entries[1].fd = 1;
table->entries[2].fd = 2;
for (i = 3; i < table->total_descriptors; i++) {
table->entries[i].fd = FD_NOT_USED;
}
HASH_ADD_INT(file_descriptor_tables, pid, table);
return table;
}
return NULL;
}
示例11: sec_exists_entry
bool sec_exists_entry(uint32_t secid) {
struct secentry *se=NULL;
HASH_FIND_INT(hash, &secid, se);
if(!se)
return false;
return true;
}
示例12: adtn_socket_base
static int adtn_socket_base(const char *data_path)
{
static int UID = 1;
int sock_id = -1;
int len;
bunsock_s *identifier;
++UID;
HASH_FIND_INT( sockStore, &sock_id, identifier);
if (identifier == NULL) {
sock_id = UID;
identifier = (bunsock_s *)calloc(1, sizeof(bunsock_s));
identifier->id = sock_id;
identifier->sopt.proc_flags = H_DESS | H_NOTF;
identifier->sopt.block_flags = B_DEL_NP;
identifier->sopt.lifetime = 100000; //this time is in seconds
len = strlen(data_path) + 1;
identifier->data_path = (char *)calloc(len, sizeof(char));
strncpy(identifier->data_path, data_path, len);
identifier->bdata = NULL;
HASH_ADD_INT( sockStore, id, identifier);
} else {
errno = EBUSY;
}
return sock_id;
}
示例13: adtn_setcodopt_base
int adtn_setcodopt_base(int fd, code_type_e option, const char *code, int from_file, int replace)
{
int ret = -1;
bunsock_s *identifier;
HASH_FIND_INT(sockStore, &fd, identifier);
if (!identifier) {
errno = ENOTSOCK;
goto end;
}
if (code == NULL || strcmp(code, "") == 0 || from_file < 0 || from_file > 1) {
errno = EINVAL;
goto end;
}
switch (option) {
case ROUTING_CODE:
if (identifier->opt.rcode) {
if (replace) {
free(identifier->opt.rcode);
} else {
errno = EOPNOTSUPP;
goto end;
}
}
identifier->opt.rcode = strdup(code);
identifier->opt.r_fromfile = from_file;
break;
case LIFE_CODE:
if (identifier->opt.lcode) {
if (replace) {
free(identifier->opt.lcode);
} else {
errno = EOPNOTSUPP;
goto end;
}
}
identifier->opt.lcode = strdup(code);
identifier->opt.l_fromfile = from_file;
break;
case PRIO_CODE:
if (identifier->opt.pcode) {
if (replace) {
free(identifier->opt.pcode);
} else {
errno = EOPNOTSUPP;
goto end;
}
}
identifier->opt.pcode = strdup(code);
identifier->opt.p_fromfile = from_file;
break;
default:
errno = EINVAL;
goto end;
}
ret = 0;
end:
return ret;
}
示例14: swDataBuffer_clear
int swDataBuffer_clear(swDataBuffer *data_buffer, int fd)
{
swDataBuffer_item *item = NULL;
HASH_FIND_INT(data_buffer->ht, &fd, item);
if (item == NULL)
{
swTrace("buffer item not found\n");
return SW_ERR;
}
else
{
swDataBuffer_trunk *trunk = item->first;
swDataBuffer_trunk *will_free_trunk; //保存trunk的指针,用于释放内存
while (trunk != NULL)
{
sw_free(trunk->data);
will_free_trunk = trunk;
trunk = trunk->next;
sw_free(will_free_trunk);
}
HASH_DEL(data_buffer->ht, item);
sw_free(item);
}
return SW_OK;
}
示例15: assert
CCAction* CCActionManager::getActionByTag(int tag, NSObject *pTarget)
{
assert(tag != kCCActionTagInvalid);
tHashElement *pElement = NULL;
HASH_FIND_INT(m_pTargets, &pTarget, pElement);
if (pElement)
{
if (pElement->actions != NULL)
{
unsigned int limit = pElement->actions->num;
for (unsigned int i = 0; i < limit; ++i)
{
CCAction *pAction = (CCAction*)pElement->actions->arr[i];
if (pAction->getTag() == tag)
{
return pAction;
}
}
}
CCLOG("cocos2d : getActionByTag: Action not found");
}
else
{
CCLOG("cocos2d : getActionByTag: Target not found");
}
return NULL;
}