Example #1
0
static inline mccp_result_t
s_add(mccp_hashmap_t *hmptr,
      void *key, void **valptr,
      bool allow_overwrite) {
  mccp_result_t ret = MCCP_RESULT_ANY_FAILURES;
  void *oldval = NULL;
  mccp_hashentry_t he;

  if ((*hmptr)->m_is_operational == true) {
    if ((he = s_find_entry(*hmptr, key)) != NULL) {
      oldval = GetHashValue(he);
      if (allow_overwrite == true) {
        SetHashValue(he, *valptr);
        ret = MCCP_RESULT_OK;
      } else {
        ret = MCCP_RESULT_ALREADY_EXISTS;
      }
    } else {
      he = s_create_entry(*hmptr, key);
      if (he != NULL) {
        SetHashValue(he, *valptr);
        (*hmptr)->m_n_entries++;
        ret = MCCP_RESULT_OK;
      } else {
        ret = MCCP_RESULT_NO_MEMORY;
      }
    }
    *valptr = oldval;
  } else {
    ret = MCCP_RESULT_NOT_OPERATIONAL;
  }

  return ret;
}
Example #2
0
void
mccp_hashmap_set_value(mccp_hashentry_t he, void *val) {
  if (he != NULL) {
    SetHashValue(he, val);
  }
}
Example #3
0
void
lagopus_hashmap_set_value(lagopus_hashentry_t he, void *val) {
  if (he != NULL) {
    SetHashValue(he, val);
  }
}