Exemple #1
0
static intptr_t
GetSerialNumber(void* aPtr, bool aCreate)
{
  PLHashEntry** hep = PL_HashTableRawLookup(gSerialNumbers,
                                            HashNumber(aPtr),
                                            aPtr);
  if (hep && *hep) {
    return static_cast<SerialNumberRecord*>((*hep)->value)->serialNumber;
  } else if (aCreate) {
    SerialNumberRecord* record = new SerialNumberRecord();
    WalkTheStackSavingLocations(record->allocationStack);
    PL_HashTableRawAdd(gSerialNumbers, hep, HashNumber(aPtr),
                       aPtr, static_cast<void*>(record));
    return gNextSerialNumber;
  }
  return 0;
}
static intptr_t
GetSerialNumber(void* aPtr, bool aCreate)
{
  PLHashEntry** hep = PL_HashTableRawLookup(gSerialNumbers,
                                            HashNumber(aPtr),
                                            aPtr);
  if (hep && *hep) {
    return reinterpret_cast<serialNumberRecord*>((*hep)->value)->serialNumber;
  } else if (aCreate) {
    serialNumberRecord* record = PR_NEW(serialNumberRecord);
    record->serialNumber = ++gNextSerialNumber;
    record->refCount = 0;
    record->COMPtrCount = 0;
    PL_HashTableRawAdd(gSerialNumbers, hep, HashNumber(aPtr),
                       aPtr, reinterpret_cast<void*>(record));
    return gNextSerialNumber;
  }
  return 0;
}
static int32_t*
GetCOMPtrCount(void* aPtr)
{
  PLHashEntry** hep = PL_HashTableRawLookup(gSerialNumbers,
                                            HashNumber(aPtr),
                                            aPtr);
  if (hep && *hep) {
    return &((reinterpret_cast<serialNumberRecord*>((*hep)->value))->COMPtrCount);
  }
  return nullptr;
}
Exemple #4
0
static int32_t*
GetRefCount(void* aPtr)
{
  PLHashEntry** hep = PL_HashTableRawLookup(gSerialNumbers,
                                            HashNumber(aPtr),
                                            aPtr);
  if (hep && *hep) {
    return &(static_cast<SerialNumberRecord*>((*hep)->value)->refCount);
  } else {
    return nullptr;
  }
}
Exemple #5
0
static intptr_t
GetSerialNumber(void* aPtr, bool aCreate)
{
  PLHashEntry** hep = PL_HashTableRawLookup(gSerialNumbers,
                                            HashNumber(aPtr),
                                            aPtr);
  if (hep && *hep) {
    MOZ_RELEASE_ASSERT(!aCreate, "If an object already has a serial number, we should be destroying it.");
    return static_cast<SerialNumberRecord*>((*hep)->value)->serialNumber;
  }

  if (!aCreate) {
    return 0;
  }

  SerialNumberRecord* record = new SerialNumberRecord();
  WalkTheStackSavingLocations(record->allocationStack);
  PL_HashTableRawAdd(gSerialNumbers, hep, HashNumber(aPtr),
                     aPtr, static_cast<void*>(record));
  return gNextSerialNumber;
}