Example #1
0
void TRI_DestroyShaper (TRI_shaper_t* shaper) {
  size_t n = shaper->_attributePathsByName._nrAlloc;
  size_t i;

  // only free pointers in attributePathsByName
  // (attributePathsByPid contains the same pointers!)
  for (i = 0; i < n; ++i) {
    void* data = shaper->_attributePathsByName._table[i];

    if (data) {
      TRI_Free(shaper->_memoryZone, data);
    }
  }

  TRI_DestroyAssociativeSynced(&shaper->_attributePathsByName);
  TRI_DestroyAssociativeSynced(&shaper->_attributePathsByPid);

  TRI_DestroyMutex(&shaper->_attributePathLock);
}
Example #2
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 #3
0
void TRI_FreeAssociativeSynced (TRI_memory_zone_t* zone, TRI_associative_synced_t* array) {
  TRI_DestroyAssociativeSynced(array);
  TRI_Free(zone, array);
}
Example #4
0
void TRI_FreeAssociativeSynced (TRI_associative_synced_t* array) {
  TRI_DestroyAssociativeSynced(array);
  TRI_Free(array);
}