Example #1
0
int TRI_InitShaper (TRI_shaper_t* shaper, TRI_memory_zone_t* zone) {
  int res;

  shaper->_memoryZone = zone;

  res = TRI_InitAssociativeSynced(&shaper->_attributePathsByName,
                                  zone,
                                  HashNameKeyAttributePath,
                                  HashNameElementAttributePath,
                                  EqualNameKeyAttributePath,
                                  0);

  if (res != TRI_ERROR_NO_ERROR) {
    return res;
  }

  res = TRI_InitAssociativeSynced(&shaper->_attributePathsByPid,
                                  zone,
                                  HashPidKeyAttributePath,
                                  HashPidElementAttributePath,
                                  EqualPidKeyAttributePath,
                                  0);

  if (res != TRI_ERROR_NO_ERROR) {
    TRI_DestroyAssociativeSynced(&shaper->_attributePathsByName);

    return res;
  }

  TRI_InitMutex(&shaper->_attributePathLock);

  shaper->_nextPid = 1;

  shaper->lookupAttributePathByPid = LookupPidAttributePath;
  shaper->findOrCreateAttributePathByName = FindOrCreateAttributePathByName;
  shaper->lookupAttributePathByName = LookupAttributePathByName;

  return TRI_ERROR_NO_ERROR;
}
Example #2
0
void TRI_InitShaper (TRI_shaper_t* shaper, TRI_memory_zone_t* zone) {
  shaper->_memoryZone = zone;

  TRI_InitAssociativeSynced(&shaper->_attributePathsByName,
                            zone,
                            HashNameKeyAttributePath,
                            HashNameElementAttributePath,
                            EqualNameKeyAttributePath,
                            0);

  TRI_InitAssociativeSynced(&shaper->_attributePathsByPid,
                            zone,
                            HashPidKeyAttributePath,
                            HashPidElementAttributePath,
                            EqualPidKeyAttributePath,
                            0);

  TRI_InitMutex(&shaper->_attributePathLock);

  shaper->_nextPid = 1;

  shaper->lookupAttributePathByPid = LookupPidAttributePath;
  shaper->findAttributePathByName = FindNameAttributePath;
}