Ejemplo n.º 1
0
void SB_Smap::put(Key_Type pp_key, const char *pp_value) {
    SML_Type *lp_item;
    int       lv_hash;
    int       lv_len;

    SB_util_assert_cpne(pp_key, NULL); // sw fault
    SB_util_assert_cpne(pp_value, NULL); // sw fault
    SB_Smap::remove(pp_key, NULL);
    lv_hash = hash(pp_key, iv_buckets);
    lp_item = new SML_Type;
    lp_item->iv_link.ip_next = reinterpret_cast<SB_QL_Type *>(ipp_HT[lv_hash]);
    lv_len = static_cast<int>(strlen(pp_key));
    lp_item->ip_key = new char[lv_len+1];
    strcpy(lp_item->ip_key, pp_key);
    lv_len = static_cast<int>(strlen(pp_value));
    lp_item->ip_value = new char[lv_len+1];
    lp_item->ip_vvalue = NULL;
    lp_item->iv_use_vvalue = false;
    strcpy(lp_item->ip_value, pp_value);
    ipp_HT[lv_hash] = lp_item;
    iv_count++;
    iv_mod++;
#ifdef USE_SB_MAP_STATS
    ip_stats->chain_add(lv_hash);  // put
#endif
#ifdef SMAP_CHECK
    check_integrity();
#endif // SMAP_CHECK
    if (iv_count > iv_buckets_threshold)
        SB_Smap::resize(iv_buckets_resize);
}
Ejemplo n.º 2
0
void SB_Smap::remove(Key_Type pp_key, char *pp_value) {
    SML_Type *lp_item;
    SML_Type *lp_prev;
    int       lv_hash;

    SB_util_assert_cpne(pp_key, NULL); // sw fault
    lv_hash = hash(pp_key, iv_buckets);
    lp_item = ipp_HT[lv_hash];
    lp_prev = NULL;
    while (lp_item != NULL) {
        if (strcmp(pp_key, lp_item->ip_key) == 0) {
            if (lp_prev == NULL)
                ipp_HT[lv_hash] = reinterpret_cast<SML_Type *>(lp_item->iv_link.ip_next);
            else
                lp_prev->iv_link.ip_next = lp_item->iv_link.ip_next;
#ifdef USE_SB_MAP_STATS
            ip_stats->chain_del(lv_hash); // remove
#endif
            iv_count--;
            iv_mod++;
#ifdef SMAP_CHECK
            check_integrity();
#endif // SMAP_CHECK
            if (pp_value != NULL)
                strcpy(pp_value, lp_item->ip_value);
            delete [] lp_item->ip_key;
            if (!lp_item->iv_use_vvalue)
                delete [] lp_item->ip_value;
            delete lp_item;
            break;
        }
        lp_prev = lp_item;
        lp_item = reinterpret_cast<SML_Type *>(lp_item->iv_link.ip_next);
    }
}
Ejemplo n.º 3
0
SB_Queue::SB_Queue(const char *pp_name)
    : iv_aecid_queue(SB_ECID_QUEUE),
      ip_head(NULL), ip_tail(NULL), iv_count(0), iv_hi(0), iv_multi_reader(false) {
    ia_q_name[sizeof(ia_q_name) - 1] = '\0';
    SB_util_assert_cpne(pp_name, NULL);
    strncpy(ia_q_name, pp_name, sizeof(ia_q_name) - 1);
}
Ejemplo n.º 4
0
// SB_Ts_Md_Md constructor
SB_Ts_Md_Map::SB_Ts_Md_Map(int         pv_qid,
                           const char *pp_name)
: SB_Ts_Imap(pp_name), iv_aecid_md_map(SB_ECID_MAP_MD) {
    iv_qid = pv_qid;
    ia_md_map_name[sizeof(ia_md_map_name) - 1] = '\0';
    SB_util_assert_cpne(pp_name, NULL);
    strncpy(ia_md_map_name, pp_name, sizeof(ia_md_map_name) - 1);
}
Ejemplo n.º 5
0
// SB_Md_Md constructor
SB_Md_Map::SB_Md_Map(int         pv_qid,
                     const char *pp_name)
: SB_Imap(pp_name) {
    iv_qid = pv_qid;
    ia_md_map_name[sizeof(ia_md_map_name) - 1] = '\0';
    SB_util_assert_cpne(pp_name, NULL);
    strncpy(ia_md_map_name, pp_name, sizeof(ia_md_map_name) - 1);
}
Ejemplo n.º 6
0
const char *SB_Smap::get(Key_Type pp_key) {
    SML_Type *lp_item;
    int       lv_hash;

    SB_util_assert_cpne(pp_key, NULL); // sw fault
    lv_hash = hash(pp_key, iv_buckets);
    lp_item = ipp_HT[lv_hash];
    while (lp_item != NULL) {
        if (strcmp(pp_key, lp_item->ip_key) == 0)
            return lp_item->ip_value;
        lp_item = reinterpret_cast<SML_Type *>(lp_item->iv_link.ip_next);
    }
    return NULL;
}