您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ sqlite3MallocSize函数代码示例

51自学网 2021-06-03 08:14:22
  C++
这篇教程C++ sqlite3MallocSize函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中sqlite3MallocSize函数的典型用法代码示例。如果您正苦于以下问题:C++ sqlite3MallocSize函数的具体用法?C++ sqlite3MallocSize怎么用?C++ sqlite3MallocSize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了sqlite3MallocSize函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: rehash

/* Resize the hash table so that it cantains "new_size" buckets.**** The hash table might fail to resize if sqlite3_malloc() fails or** if the new size is the same as the prior size.** Return TRUE if the resize occurs and false if not.*/static int rehash(Hash *pH, unsigned int new_size){  struct _ht *new_ht;            /* The new hash table */  HashElem *elem, *next_elem;    /* For looping over existing elements */#if SQLITE_MALLOC_SOFT_LIMIT>0  if( new_size*sizeof(struct _ht)>SQLITE_MALLOC_SOFT_LIMIT ){    new_size = SQLITE_MALLOC_SOFT_LIMIT/sizeof(struct _ht);  }  if( new_size==pH->htsize ) return 0;#endif  /* The inability to allocates space for a larger hash table is  ** a performance hit but it is not a fatal error.  So mark the  ** allocation as a benign. Use sqlite3Malloc()/memset(0) instead of   ** sqlite3MallocZero() to make the allocation, as sqlite3MallocZero()  ** only zeroes the requested number of bytes whereas this module will  ** use the actual amount of space allocated for the hash table (which  ** may be larger than the requested amount).  */  sqlite3BeginBenignMalloc();  new_ht = (struct _ht *)sqlite3Malloc( new_size*sizeof(struct _ht) );  sqlite3EndBenignMalloc();  if( new_ht==0 ) return 0;  sqlite3_free(pH->ht);  pH->ht = new_ht;  pH->htsize = new_size = sqlite3MallocSize(new_ht)/sizeof(struct _ht);  memset(new_ht, 0, new_size*sizeof(struct _ht));  for(elem=pH->first, pH->first=0; elem; elem = next_elem){    unsigned int h = strHash(elem->pKey, elem->nKey) % new_size;    next_elem = elem->next;    insertElement(pH, &new_ht[h], elem);  }  return 1;}
开发者ID:0x7678,项目名称:owasp-igoat,代码行数:41,


示例2: rehash

/* Resize the hash table so that it cantains "new_size" buckets.**** The hash table might fail to resize if sqlite3_malloc() fails or** if the new size is the same as the prior size.** Return TRUE if the resize occurs and false if not.*/static int rehash(Hash *pH, unsigned int new_size){  struct _ht *new_ht;            /* The new hash table */  HashElem *elem, *next_elem;    /* For looping over existing elements */#if SQLITE_MALLOC_SOFT_LIMIT>0  if( new_size*sizeof(struct _ht)>SQLITE_MALLOC_SOFT_LIMIT ){    new_size = SQLITE_MALLOC_SOFT_LIMIT/sizeof(struct _ht);  }  if( new_size==pH->htsize ) return 0;#endif  /* The inability to allocates space for a larger hash table is  ** a performance hit but it is not a fatal error.  So mark the  ** allocation as a benign.  */  sqlite3BeginBenignMalloc();  new_ht = (struct _ht *)sqlite3Malloc( new_size*sizeof(struct _ht) );  sqlite3EndBenignMalloc();  if( new_ht==0 ) return 0;  sqlite3_free(pH->ht);  pH->ht = new_ht;  pH->htsize = new_size = sqlite3MallocSize(new_ht)/sizeof(struct _ht);  memset(new_ht, 0, new_size*sizeof(struct _ht));  for(elem=pH->first, pH->first=0; elem; elem = next_elem){    unsigned int h = strHash(elem->pKey, elem->nKey) % new_size;    next_elem = elem->next;    insertElement(pH, &new_ht[h], elem);  }  return 1;}
开发者ID:77songsong,项目名称:sqlite3,代码行数:37,


示例3: sqlite3VdbeMemGrow

/*** Make sure pMem->z points to a writable allocation of at least ** n bytes.**** If the memory cell currently contains string or blob data** and the third argument passed to this function is true, the ** current content of the cell is preserved. Otherwise, it may** be discarded.  **** This function sets the MEM_Dyn flag and clears any xDel callback.** It also clears MEM_Ephem and MEM_Static. If the preserve flag is ** not set, Mem.n is zeroed.*/int sqlite3VdbeMemGrow(Mem *pMem, int n, int preserve){  assert( 1 >=    ((pMem->zMalloc && pMem->zMalloc==pMem->z) ? 1 : 0) +    (((pMem->flags&MEM_Dyn)&&pMem->xDel) ? 1 : 0) +     ((pMem->flags&MEM_Ephem) ? 1 : 0) +     ((pMem->flags&MEM_Static) ? 1 : 0)  );  if( !pMem->zMalloc || sqlite3MallocSize(pMem->zMalloc)<n ){    n = (n>32?n:32);    if( preserve && pMem->z==pMem->zMalloc ){      pMem->z = pMem->zMalloc = sqlite3DbReallocOrFree(pMem->db, pMem->z, n);      if( !pMem->z ){        pMem->flags = MEM_Null;      }      preserve = 0;    }else{      sqlite3_free(pMem->zMalloc);      pMem->zMalloc = sqlite3DbMallocRaw(pMem->db, n);    }  }  if( preserve && pMem->z && pMem->zMalloc && pMem->z!=pMem->zMalloc ){    memcpy(pMem->zMalloc, pMem->z, pMem->n);  }  if( pMem->flags&MEM_Dyn && pMem->xDel ){    pMem->xDel((void *)(pMem->z));  }  pMem->z = pMem->zMalloc;  pMem->flags &= ~(MEM_Ephem|MEM_Static);  pMem->xDel = 0;  return (pMem->z ? SQLITE_OK : SQLITE_NOMEM);}
开发者ID:Jacob-jiangbo,项目名称:my-test,代码行数:47,


示例4: mallocWithAlarm

/*** Do a memory allocation with statistics and alarms.  Assume the** lock is already held.*/static int mallocWithAlarm(int n, void **pp){  int nFull;  void *p;  assert( sqlite3_mutex_held(mem0.mutex) );  nFull = sqlite3GlobalConfig.m.xRoundup(n);  sqlite3StatusHighwater(SQLITE_STATUS_MALLOC_SIZE, n);  if( mem0.alarmThreshold>0 ){    sqlite3_int64 nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED);    if( nUsed >= mem0.alarmThreshold - nFull ){      mem0.nearlyFull = 1;      sqlite3MallocAlarm(nFull);    }else{      mem0.nearlyFull = 0;    }  }  p = sqlite3GlobalConfig.m.xMalloc(nFull);#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT  if( p==0 && mem0.alarmThreshold>0 ){    sqlite3MallocAlarm(nFull);    p = sqlite3GlobalConfig.m.xMalloc(nFull);  }#endif  if( p ){    nFull = sqlite3MallocSize(p);    sqlite3StatusUp(SQLITE_STATUS_MEMORY_USED, nFull);    sqlite3StatusUp(SQLITE_STATUS_MALLOC_COUNT, 1);  }  *pp = p;  return nFull;}
开发者ID:aobzhirov,项目名称:ChromiumGStreamerBackend,代码行数:34,


示例5: pcache1InitBulk

/*** Try to initialize the pCache->pFree and pCache->pBulk fields.  Return** true if pCache->pFree ends up containing one or more free pages.*/static int pcache1InitBulk(PCache1 *pCache){  i64 szBulk;  char *zBulk;  if( pcache1.nInitPage==0 ) return 0;  /* Do not bother with a bulk allocation if the cache size very small */  if( pCache->nMax<3 ) return 0;  sqlite3BeginBenignMalloc();  if( pcache1.nInitPage>0 ){    szBulk = pCache->szAlloc * (i64)pcache1.nInitPage;  }else{    szBulk = -1024 * (i64)pcache1.nInitPage;  }  if( szBulk > pCache->szAlloc*(i64)pCache->nMax ){    szBulk = pCache->szAlloc*pCache->nMax;  }  zBulk = pCache->pBulk = sqlite3Malloc( szBulk );  sqlite3EndBenignMalloc();  if( zBulk ){    int nBulk = sqlite3MallocSize(zBulk)/pCache->szAlloc;    int i;    for(i=0; i<nBulk; i++){      PgHdr1 *pX = (PgHdr1*)&zBulk[pCache->szPage];      pX->page.pBuf = zBulk;      pX->page.pExtra = &pX[1];      pX->isBulkLocal = 1;      pX->isAnchor = 0;      pX->pNext = pCache->pFree;      pCache->pFree = pX;      zBulk += pCache->szAlloc;    }  }  return pCache->pFree!=0;}
开发者ID:arizwanp,项目名称:intel_sgx,代码行数:37,


示例6: assert

/*** Malloc function used within this file to allocate space from the buffer** configured using sqlite3_config(SQLITE_CONFIG_PAGECACHE) option. If no** such buffer exists or there is no space left in it, this function falls** back to sqlite3Malloc().**** Multiple threads can run this routine at the same time.  Global variables** in pcache1 need to be protected via mutex.*/static void *pcache1Alloc(int nByte){  void *p = 0;  assert( sqlite3_mutex_notheld(pcache1.grp.mutex) );  if( nByte<=pcache1.szSlot ){    sqlite3_mutex_enter(pcache1.mutex);    p = (PgHdr1 *)pcache1.pFree;    if( p ){      pcache1.pFree = pcache1.pFree->pNext;      pcache1.nFreeSlot--;      pcache1.bUnderPressure = pcache1.nFreeSlot<pcache1.nReserve;      assert( pcache1.nFreeSlot>=0 );      sqlite3StatusHighwater(SQLITE_STATUS_PAGECACHE_SIZE, nByte);      sqlite3StatusUp(SQLITE_STATUS_PAGECACHE_USED, 1);    }    sqlite3_mutex_leave(pcache1.mutex);  }  if( p==0 ){    /* Memory is not available in the SQLITE_CONFIG_PAGECACHE pool.  Get    ** it from sqlite3Malloc instead.    */    p = sqlite3Malloc(nByte);#ifndef SQLITE_DISABLE_PAGECACHE_OVERFLOW_STATS    if( p ){      int sz = sqlite3MallocSize(p);      sqlite3_mutex_enter(pcache1.mutex);      sqlite3StatusHighwater(SQLITE_STATUS_PAGECACHE_SIZE, nByte);      sqlite3StatusUp(SQLITE_STATUS_PAGECACHE_OVERFLOW, sz);      sqlite3_mutex_leave(pcache1.mutex);    }#endif    sqlite3MemdebugSetType(p, MEMTYPE_PCACHE);  }  return p;}
开发者ID:arizwanp,项目名称:intel_sgx,代码行数:43,


示例7: pcache1Free

/*** Free an allocated buffer obtained from pcache1Alloc().*/static int pcache1Free(void *p){  int nFreed = 0;  if( p==0 ) return 0;  if( p>=pcache1.pStart && p<pcache1.pEnd ){    PgFreeslot *pSlot;    sqlite3_mutex_enter(pcache1.mutex);    sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_USED, -1);    pSlot = (PgFreeslot*)p;    pSlot->pNext = pcache1.pFree;    pcache1.pFree = pSlot;    pcache1.nFreeSlot++;    pcache1.bUnderPressure = pcache1.nFreeSlot<pcache1.nReserve;    assert( pcache1.nFreeSlot<=pcache1.nSlot );    sqlite3_mutex_leave(pcache1.mutex);  }else{    assert( sqlite3MemdebugHasType(p, MEMTYPE_PCACHE) );    sqlite3MemdebugSetType(p, MEMTYPE_HEAP);    nFreed = sqlite3MallocSize(p);    sqlite3_mutex_enter(pcache1.mutex);    sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_OVERFLOW, -nFreed);    sqlite3_mutex_leave(pcache1.mutex);    sqlite3_free(p);  }  return nFreed;}
开发者ID:GisKook,项目名称:Gis,代码行数:28,


示例8: pcache1Free

/*** Free an allocated buffer obtained from pcache1Alloc().*/static void pcache1Free(void *p){  int nFreed = 0;  if( p==0 ) return;  if( SQLITE_WITHIN(p, pcache1.pStart, pcache1.pEnd) ){    PgFreeslot *pSlot;    sqlite3_mutex_enter(pcache1.mutex);    sqlite3StatusDown(SQLITE_STATUS_PAGECACHE_USED, 1);    pSlot = (PgFreeslot*)p;    pSlot->pNext = pcache1.pFree;    pcache1.pFree = pSlot;    pcache1.nFreeSlot++;    pcache1.bUnderPressure = pcache1.nFreeSlot<pcache1.nReserve;    assert( pcache1.nFreeSlot<=pcache1.nSlot );    sqlite3_mutex_leave(pcache1.mutex);  }else{    assert( sqlite3MemdebugHasType(p, MEMTYPE_PCACHE) );    sqlite3MemdebugSetType(p, MEMTYPE_HEAP);#ifndef SQLITE_DISABLE_PAGECACHE_OVERFLOW_STATS    nFreed = sqlite3MallocSize(p);    sqlite3_mutex_enter(pcache1.mutex);    sqlite3StatusDown(SQLITE_STATUS_PAGECACHE_OVERFLOW, nFreed);    sqlite3_mutex_leave(pcache1.mutex);#endif    sqlite3_free(p);  }}
开发者ID:arizwanp,项目名称:intel_sgx,代码行数:29,


示例9: assert

/*** Allocate a page cache line.  Look in the page cache memory pool first** and use an element from it first if available.  If nothing is available** in the page cache memory pool, go to the general purpose memory allocator.*/static void *pcacheMalloc(int sz, PCache *pCache){  assert( sqlite3_mutex_held(pcache_g.mutex) );  if( sz<=pcache_g.szSlot && pcache_g.pFree ){    PgFreeslot *p = pcache_g.pFree;    pcache_g.pFree = p->pNext;    sqlite3StatusSet(SQLITE_STATUS_PAGECACHE_SIZE, sz);    sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_USED, 1);    return (void*)p;  }else{    void *p;    /* Allocate a new buffer using sqlite3Malloc. Before doing so, exit the    ** global pcache mutex and unlock the pager-cache object pCache. This is     ** so that if the attempt to allocate a new buffer causes the the     ** configured soft-heap-limit to be breached, it will be possible to    ** reclaim memory from this pager-cache.    */    pcacheExitMutex();    p = sqlite3Malloc(sz);    pcacheEnterMutex();    if( p ){      sz = sqlite3MallocSize(p);      sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_OVERFLOW, sz);    }    return p;  }}
开发者ID:contextlogger,项目名称:contextlogger2,代码行数:33,


示例10: assert

/*** Malloc function used within this file to allocate space from the buffer** configured using sqlite3_config(SQLITE_CONFIG_PAGECACHE) option. If no ** such buffer exists or there is no space left in it, this function falls ** back to sqlite3Malloc().*/static void *pcache1Alloc(int nByte){  void *p;  assert( sqlite3_mutex_held(pcache1.mutex) );  if( nByte<=pcache1.szSlot && pcache1.pFree ){    assert( pcache1.isInit );    p = (PgHdr1 *)pcache1.pFree;    pcache1.pFree = pcache1.pFree->pNext;    sqlite3StatusSet(SQLITE_STATUS_PAGECACHE_SIZE, nByte);    sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_USED, 1);  }else{    /* Allocate a new buffer using sqlite3Malloc. Before doing so, exit the    ** global pcache mutex and unlock the pager-cache object pCache. This is     ** so that if the attempt to allocate a new buffer causes the the     ** configured soft-heap-limit to be breached, it will be possible to    ** reclaim memory from this pager-cache.    */    pcache1LeaveMutex();    p = sqlite3Malloc(nByte);    pcache1EnterMutex();    if( p ){      int sz = sqlite3MallocSize(p);      sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_OVERFLOW, sz);    }  }  return p;}
开发者ID:Ramananda,项目名称:sqlcipher,代码行数:33,


示例11: sqlite3Malloc

/*** Change the size of an existing memory allocation*/void *sqlite3Realloc(void *pOld, int nBytes){  int nOld, nNew, nDiff;  void *pNew;  if( pOld==0 ){    return sqlite3Malloc(nBytes); /* IMP: R-28354-25769 */  }  if( nBytes<=0 ){    sqlite3_free(pOld); /* IMP: R-31593-10574 */    return 0;  }  if( nBytes>=0x7fffff00 ){    /* The 0x7ffff00 limit term is explained in comments on sqlite3Malloc() */    return 0;  }  nOld = sqlite3MallocSize(pOld);  /* IMPLEMENTATION-OF: R-46199-30249 SQLite guarantees that the second  ** argument to xRealloc is always a value returned by a prior call to  ** xRoundup. */  nNew = sqlite3GlobalConfig.m.xRoundup(nBytes);  if( nOld==nNew ){    pNew = pOld;  }else if( sqlite3GlobalConfig.bMemstat ){    sqlite3_mutex_enter(mem0.mutex);    sqlite3StatusSet(SQLITE_STATUS_MALLOC_SIZE, nBytes);    nDiff = nNew - nOld;    if( sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED) >=           mem0.alarmThreshold-nDiff ){      sqlite3MallocAlarm(nDiff);    }    assert( sqlite3MemdebugHasType(pOld, MEMTYPE_HEAP) );    assert( sqlite3MemdebugNoType(pOld, ~MEMTYPE_HEAP) );    pNew = sqlite3GlobalConfig.m.xRealloc(pOld, nNew);    if( pNew==0 && mem0.alarmCallback ){      sqlite3MallocAlarm(nBytes);      pNew = sqlite3GlobalConfig.m.xRealloc(pOld, nNew);    }    if( pNew ){      nNew = sqlite3MallocSize(pNew);      sqlite3StatusAdd(SQLITE_STATUS_MEMORY_USED, nNew-nOld);    }    sqlite3_mutex_leave(mem0.mutex);  }else{    pNew = sqlite3GlobalConfig.m.xRealloc(pOld, nNew);  }  assert( EIGHT_BYTE_ALIGNMENT(pNew) ); /* IMP: R-04675-44850 */  return pNew;}
开发者ID:AdrianHuang,项目名称:rt-thread-for-vmm,代码行数:50,


示例12: assert

/*** Change the size of an existing memory allocation*/void *sqlite3Realloc(void *pOld, u64 nBytes){  int nOld, nNew, nDiff;  void *pNew;  assert( sqlite3MemdebugHasType(pOld, MEMTYPE_HEAP) );  assert( sqlite3MemdebugNoType(pOld, (u8)~MEMTYPE_HEAP) );  if( pOld==0 ){    return sqlite3Malloc(nBytes); /* IMP: R-04300-56712 */  }  if( nBytes==0 ){    sqlite3_free(pOld); /* IMP: R-26507-47431 */    return 0;  }  if( nBytes>=0x7fffff00 ){    /* The 0x7ffff00 limit term is explained in comments on sqlite3Malloc() */    return 0;  }  nOld = sqlite3MallocSize(pOld);  /* IMPLEMENTATION-OF: R-46199-30249 SQLite guarantees that the second  ** argument to xRealloc is always a value returned by a prior call to  ** xRoundup. */  nNew = sqlite3GlobalConfig.m.xRoundup((int)nBytes);  if( nOld==nNew ){    pNew = pOld;  }else if( sqlite3GlobalConfig.bMemstat ){    sqlite3_mutex_enter(mem0.mutex);    sqlite3StatusHighwater(SQLITE_STATUS_MALLOC_SIZE, (int)nBytes);    nDiff = nNew - nOld;    if( sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED) >=           mem0.alarmThreshold-nDiff ){      sqlite3MallocAlarm(nDiff);    }    pNew = sqlite3GlobalConfig.m.xRealloc(pOld, nNew);    if( pNew==0 && mem0.alarmThreshold>0 ){      sqlite3MallocAlarm((int)nBytes);      pNew = sqlite3GlobalConfig.m.xRealloc(pOld, nNew);    }    if( pNew ){      nNew = sqlite3MallocSize(pNew);      sqlite3StatusUp(SQLITE_STATUS_MEMORY_USED, nNew-nOld);    }    sqlite3_mutex_leave(mem0.mutex);  }else{    pNew = sqlite3GlobalConfig.m.xRealloc(pOld, nNew);  }  assert( EIGHT_BYTE_ALIGNMENT(pNew) ); /* IMP: R-11148-40995 */  return pNew;}
开发者ID:aobzhirov,项目名称:ChromiumGStreamerBackend,代码行数:50,


示例13: pcachePageSize

/*** Return the number of bytes that will be returned to the heap when** the argument is passed to pcachePageFree().*/static int pcachePageSize(PgHdr *p) {    assert( sqlite3_mutex_held(pcache.mutex) );    assert( !pcache.pStart );    assert( p->apSave[0]==0 );    assert( p->apSave[1]==0 );    assert( p && p->pCache );    return sqlite3MallocSize(p);}
开发者ID:EmuxEvans,项目名称:sailing,代码行数:12,


示例14: sqlite3Malloc

void *sqlite3Realloc(void *pOld, int nBytes){  int nOld, nNew;  void *pNew;  if( pOld==0 ){    return sqlite3Malloc(nBytes);   }  if( nBytes<=0 ){    sqlite3_free(pOld);     return 0;  }  if( nBytes>=0x7fffff00 ){        return 0;  }  nOld = sqlite3MallocSize(pOld);  nNew = sqlite3GlobalConfig.m.xRoundup(nBytes);  if( nOld==nNew ){    pNew = pOld;  }else if( sqlite3GlobalConfig.bMemstat ){    sqlite3_mutex_enter(mem0.mutex);    sqlite3StatusSet(SQLITE_STATUS_MALLOC_SIZE, nBytes);    if( sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED)+nNew-nOld >=           mem0.alarmThreshold ){      sqlite3MallocAlarm(nNew-nOld);    }    assert( sqlite3MemdebugHasType(pOld, MEMTYPE_HEAP) );    assert( sqlite3MemdebugNoType(pOld, ~MEMTYPE_HEAP) );    pNew = sqlite3GlobalConfig.m.xRealloc(pOld, nNew);    if( pNew==0 && mem0.alarmCallback ){      sqlite3MallocAlarm(nBytes);      pNew = sqlite3GlobalConfig.m.xRealloc(pOld, nNew);    }    if( pNew ){      nNew = sqlite3MallocSize(pNew);      sqlite3StatusAdd(SQLITE_STATUS_MEMORY_USED, nNew-nOld);    }    sqlite3_mutex_leave(mem0.mutex);  }else{    pNew = sqlite3GlobalConfig.m.xRealloc(pOld, nNew);  }  assert( EIGHT_BYTE_ALIGNMENT(pNew) );   return pNew;}
开发者ID:qtekfun,项目名称:htcDesire820Kernel,代码行数:43,


示例15: sqlite3_free

/*** Free memory previously obtained from sqlite3Malloc().*/void sqlite3_free(void *p){  if( p==0 ) return;  if( sqlite3GlobalConfig.bMemstat ){    sqlite3_mutex_enter(mem0.mutex);    sqlite3StatusAdd(SQLITE_STATUS_MEMORY_USED, -sqlite3MallocSize(p));    sqlite3GlobalConfig.m.xFree(p);    sqlite3_mutex_leave(mem0.mutex);  }else{    sqlite3GlobalConfig.m.xFree(p);  }}
开发者ID:erik-knudsen,项目名称:eCos-enhancements,代码行数:14,


示例16: pcache1MemSize

/*** Return the size of a pcache allocation*/static int pcache1MemSize(void *p){  if( p>=pcache1.pStart && p<pcache1.pEnd ){    return pcache1.szSlot;  }else{    int iSize;    assert( sqlite3MemdebugHasType(p, MEMTYPE_PCACHE) );    sqlite3MemdebugSetType(p, MEMTYPE_HEAP);    iSize = sqlite3MallocSize(p);    sqlite3MemdebugSetType(p, MEMTYPE_PCACHE);    return iSize;  }}
开发者ID:arizwanp,项目名称:intel_sgx,代码行数:15,


示例17: sqlite3Malloc

/*** Change the size of an existing memory allocation*/void *sqlite3Realloc(void *pOld, int nBytes){  int nOld, nNew;  void *pNew;  if( pOld==0 ){    return sqlite3Malloc(nBytes);  }  if( nBytes<=0 ){    sqlite3_free(pOld);    return 0;  }  if( nBytes>=0x7fffff00 ){    /* The 0x7ffff00 limit term is explained in comments on sqlite3Malloc() */    return 0;  }  nOld = sqlite3MallocSize(pOld);  nNew = sqlite3GlobalConfig.m.xRoundup(nBytes);  if( nOld==nNew ){    pNew = pOld;  }else if( sqlite3GlobalConfig.bMemstat ){    sqlite3_mutex_enter(mem0.mutex);    sqlite3StatusSet(SQLITE_STATUS_MALLOC_SIZE, nBytes);    if( sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED)+nNew-nOld >=           mem0.alarmThreshold ){      sqlite3MallocAlarm(nNew-nOld);    }    pNew = sqlite3GlobalConfig.m.xRealloc(pOld, nNew);    if( pNew==0 && mem0.alarmCallback ){      sqlite3MallocAlarm(nBytes);      pNew = sqlite3GlobalConfig.m.xRealloc(pOld, nNew);    }    if( pNew ){      nNew = sqlite3MallocSize(pNew);      sqlite3StatusAdd(SQLITE_STATUS_MEMORY_USED, nNew-nOld);    }    sqlite3_mutex_leave(mem0.mutex);  }else{    pNew = sqlite3GlobalConfig.m.xRealloc(pOld, nNew);  }  return pNew;}
开发者ID:FarazShaikh,项目名称:LikewiseSMB2,代码行数:43,


示例18: sqlite3_free

void sqlite3_free(void *p){  if( p==0 ) return;    assert( sqlite3MemdebugNoType(p, MEMTYPE_DB) );  assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) );  if( sqlite3GlobalConfig.bMemstat ){    sqlite3_mutex_enter(mem0.mutex);    sqlite3StatusAdd(SQLITE_STATUS_MEMORY_USED, -sqlite3MallocSize(p));    sqlite3StatusAdd(SQLITE_STATUS_MALLOC_COUNT, -1);    sqlite3GlobalConfig.m.xFree(p);    sqlite3_mutex_leave(mem0.mutex);  }else{    sqlite3GlobalConfig.m.xFree(p);  }}
开发者ID:qtekfun,项目名称:htcDesire820Kernel,代码行数:14,


示例19: sqlite3_free

/*** Free memory previously obtained from sqlite3Malloc().*/void sqlite3_free(void *p){  if( p==0 ) return;  /* IMP: R-49053-54554 */  assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) );  assert( sqlite3MemdebugNoType(p, (u8)~MEMTYPE_HEAP) );  if( sqlite3GlobalConfig.bMemstat ){    sqlite3_mutex_enter(mem0.mutex);    sqlite3StatusDown(SQLITE_STATUS_MEMORY_USED, sqlite3MallocSize(p));    sqlite3StatusDown(SQLITE_STATUS_MALLOC_COUNT, 1);    sqlite3GlobalConfig.m.xFree(p);    sqlite3_mutex_leave(mem0.mutex);  }else{    sqlite3GlobalConfig.m.xFree(p);  }}
开发者ID:aobzhirov,项目名称:ChromiumGStreamerBackend,代码行数:17,


示例20: sqlite3PcacheReleaseMemory

/*** This function is called to free superfluous dynamically allocated memory** held by the pager system. Memory in use by any SQLite pager allocated** by the current thread may be sqlite3_free()ed.**** nReq is the number of bytes of memory required. Once this much has** been released, the function returns. The return value is the total number ** of bytes of memory released.*/int sqlite3PcacheReleaseMemory(int nReq){  int nFree = 0;  if( pcache1.pStart==0 ){    PgHdr1 *p;    pcache1EnterMutex();    while( (nReq<0 || nFree<nReq) && (p=pcache1.pLruTail) ){      nFree += sqlite3MallocSize(p);      pcache1PinPage(p);      pcache1RemoveFromHash(p);      pcache1FreePage(p);    }    pcache1LeaveMutex();  }  return nFree;}
开发者ID:qiuping,项目名称:sqlcipher,代码行数:24,


示例21: pcacheFree

/*** Release a pager memory allocation*/static void pcacheFree(void *p){  assert( sqlite3_mutex_held(pcache_g.mutex) );  if( p==0 ) return;  if( p>=pcache_g.pStart && p<pcache_g.pEnd ){    PgFreeslot *pSlot;    sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_USED, -1);    pSlot = (PgFreeslot*)p;    pSlot->pNext = pcache_g.pFree;    pcache_g.pFree = pSlot;  }else{    int iSize = sqlite3MallocSize(p);    sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_OVERFLOW, -iSize);    sqlite3_free(p);  }}
开发者ID:contextlogger,项目名称:contextlogger2,代码行数:18,


示例22: mallocWithAlarm

/*** Do a memory allocation with statistics and alarms.  Assume the** lock is already held.*/static void mallocWithAlarm(int n, void **pp){  void *p;  int nFull;  assert( sqlite3_mutex_held(mem0.mutex) );  assert( n>0 );  /* In Firefox (circa 2017-02-08), xRoundup() is remapped to an internal  ** implementation of malloc_good_size(), which must be called in debug  ** mode and specifically when the DMD "Dark Matter Detector" is enabled  ** or else a crash results.  Hence, do not attempt to optimize out the  ** following xRoundup() call. */  nFull = sqlite3GlobalConfig.m.xRoundup(n);#ifdef SQLITE_MAX_MEMORY  if( sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED)+nFull>SQLITE_MAX_MEMORY ){    *pp = 0;    return;  }#endif  sqlite3StatusHighwater(SQLITE_STATUS_MALLOC_SIZE, n);  if( mem0.alarmThreshold>0 ){    sqlite3_int64 nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED);    if( nUsed >= mem0.alarmThreshold - nFull ){      mem0.nearlyFull = 1;      sqlite3MallocAlarm(nFull);    }else{      mem0.nearlyFull = 0;    }  }  p = sqlite3GlobalConfig.m.xMalloc(nFull);#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT  if( p==0 && mem0.alarmThreshold>0 ){    sqlite3MallocAlarm(nFull);    p = sqlite3GlobalConfig.m.xMalloc(nFull);  }#endif  if( p ){    nFull = sqlite3MallocSize(p);    sqlite3StatusUp(SQLITE_STATUS_MEMORY_USED, nFull);    sqlite3StatusUp(SQLITE_STATUS_MALLOC_COUNT, 1);  }  *pp = p;}
开发者ID:SCALE-GmbH,项目名称:sqlcipher,代码行数:48,


示例23: sqlite3PageFree

void sqlite3PageFree(void *p){  if( p ){    if( sqlite3GlobalConfig.pPage==0           || p<sqlite3GlobalConfig.pPage           || p>=(void*)mem0.aPageFree ){      /* In this case, the page allocation was obtained from a regular       ** call to sqlite3_mem_methods.xMalloc() (a page-cache-memory       ** "overflow"). Free the block with sqlite3_mem_methods.xFree().      */      if( sqlite3GlobalConfig.bMemstat ){        int iSize = sqlite3MallocSize(p);        sqlite3_mutex_enter(mem0.mutex);        sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_OVERFLOW, -iSize);        sqlite3StatusAdd(SQLITE_STATUS_MEMORY_USED, -iSize);        sqlite3GlobalConfig.m.xFree(p);        sqlite3_mutex_leave(mem0.mutex);      }else{        sqlite3GlobalConfig.m.xFree(p);      }    }else{      /* The page allocation was allocated from the sqlite3GlobalConfig.pPage      ** buffer. In this case all that is add the index of the page in      ** the sqlite3GlobalConfig.pPage array to the set of free indexes stored      ** in the mem0.aPageFree[] array.      */      int i;      i = (u8 *)p - (u8 *)sqlite3GlobalConfig.pPage;      i /= sqlite3GlobalConfig.szPage;      assert( i>=0 && i<sqlite3GlobalConfig.nPage );      sqlite3_mutex_enter(mem0.mutex);      assert( mem0.nPageFree<sqlite3GlobalConfig.nPage );      mem0.aPageFree[mem0.nPageFree++] = i;      sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_USED, -1);      sqlite3_mutex_leave(mem0.mutex);#if !defined(NDEBUG) && 0      /* Assert that a duplicate was not just inserted into aPageFree[]. */      for(i=0; i<mem0.nPageFree-1; i++){        assert( mem0.aPageFree[i]!=mem0.aPageFree[mem0.nPageFree-1] );      }#endif    }  }}
开发者ID:erik-knudsen,项目名称:eCos-enhancements,代码行数:43,


示例24: sqlite3ScratchFree

void sqlite3ScratchFree(void *p){  if( p ){#if SQLITE_THREADSAFE==0 && !defined(NDEBUG)    /* Verify that no more than two scratch allocation per thread    ** is outstanding at one time.  (This is only checked in the    ** single-threaded case since checking in the multi-threaded case    ** would be much more complicated.) */    assert( scratchAllocOut>=1 && scratchAllocOut<=2 );    scratchAllocOut--;#endif    if( SQLITE_WITHIN(p, sqlite3GlobalConfig.pScratch, mem0.pScratchEnd) ){      /* Release memory from the SQLITE_CONFIG_SCRATCH allocation */      ScratchFreeslot *pSlot;      pSlot = (ScratchFreeslot*)p;      sqlite3_mutex_enter(mem0.mutex);      pSlot->pNext = mem0.pScratchFree;      mem0.pScratchFree = pSlot;      mem0.nScratchFree++;      assert( mem0.nScratchFree <= (u32)sqlite3GlobalConfig.nScratch );      sqlite3StatusDown(SQLITE_STATUS_SCRATCH_USED, 1);      sqlite3_mutex_leave(mem0.mutex);    }else{      /* Release memory back to the heap */      assert( sqlite3MemdebugHasType(p, MEMTYPE_SCRATCH) );      assert( sqlite3MemdebugNoType(p, (u8)~MEMTYPE_SCRATCH) );      sqlite3MemdebugSetType(p, MEMTYPE_HEAP);      if( sqlite3GlobalConfig.bMemstat ){        int iSize = sqlite3MallocSize(p);        sqlite3_mutex_enter(mem0.mutex);        sqlite3StatusDown(SQLITE_STATUS_SCRATCH_OVERFLOW, iSize);        sqlite3StatusDown(SQLITE_STATUS_MEMORY_USED, iSize);        sqlite3StatusDown(SQLITE_STATUS_MALLOC_COUNT, 1);        sqlite3GlobalConfig.m.xFree(p);        sqlite3_mutex_leave(mem0.mutex);      }else{        sqlite3GlobalConfig.m.xFree(p);      }    }  }}
开发者ID:aobzhirov,项目名称:ChromiumGStreamerBackend,代码行数:42,


示例25: pcache1Free

/*** Free an allocated buffer obtained from pcache1Alloc().*/static void pcache1Free(void *p){  assert( sqlite3_mutex_held(pcache1.mutex) );  if( p==0 ) return;  if( p>=pcache1.pStart && p<pcache1.pEnd ){    PgFreeslot *pSlot;    sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_USED, -1);    pSlot = (PgFreeslot*)p;    pSlot->pNext = pcache1.pFree;    pcache1.pFree = pSlot;    pcache1.nFreeSlot++;    assert( pcache1.nFreeSlot<=pcache1.nSlot );  }else{    int iSize;    assert( sqlite3MemdebugHasType(p, MEMTYPE_PCACHE) );    sqlite3MemdebugSetType(p, MEMTYPE_HEAP);    iSize = sqlite3MallocSize(p);    sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_OVERFLOW, -iSize);    sqlite3_free(p);  }}
开发者ID:Sheridan,项目名称:sqlite,代码行数:23,


示例26: sqlite3ScratchFree

void sqlite3ScratchFree(void *p){  if( p ){    if( sqlite3GlobalConfig.pScratch==0           || p<sqlite3GlobalConfig.pScratch           || p>=(void*)mem0.aScratchFree ){      assert( sqlite3MemdebugHasType(p, MEMTYPE_SCRATCH) );      sqlite3MemdebugSetType(p, MEMTYPE_HEAP);      if( sqlite3GlobalConfig.bMemstat ){        int iSize = sqlite3MallocSize(p);        sqlite3_mutex_enter(mem0.mutex);        sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_OVERFLOW, -iSize);        sqlite3StatusAdd(SQLITE_STATUS_MEMORY_USED, -iSize);        sqlite3GlobalConfig.m.xFree(p);        sqlite3_mutex_leave(mem0.mutex);      }else{        sqlite3GlobalConfig.m.xFree(p);      }    }else{      int i;      i = (int)((u8*)p - (u8*)sqlite3GlobalConfig.pScratch);      i /= sqlite3GlobalConfig.szScratch;      assert( i>=0 && i<sqlite3GlobalConfig.nScratch );      sqlite3_mutex_enter(mem0.mutex);      assert( mem0.nScratchFree<(u32)sqlite3GlobalConfig.nScratch );      mem0.aScratchFree[mem0.nScratchFree++] = i;      sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_USED, -1);      sqlite3_mutex_leave(mem0.mutex);#if SQLITE_THREADSAFE==0 && !defined(NDEBUG)    /* Verify that no more than two scratch allocation per thread    ** is outstanding at one time.  (This is only checked in the    ** single-threaded case since checking in the multi-threaded case    ** would be much more complicated.) */    assert( scratchAllocOut>=1 && scratchAllocOut<=2 );    scratchAllocOut = 0;#endif    }  }}
开发者ID:sukantoguha,项目名称:INET-Vagrant-Demos,代码行数:40,


示例27: sqlite3ScratchFree

void sqlite3ScratchFree(void *p){  if( p ){#if SQLITE_THREADSAFE==0 && !defined(NDEBUG)    assert( scratchAllocOut>=1 && scratchAllocOut<=2 );    scratchAllocOut--;#endif    if( p>=sqlite3GlobalConfig.pScratch && p<mem0.pScratchEnd ){            ScratchFreeslot *pSlot;      pSlot = (ScratchFreeslot*)p;      sqlite3_mutex_enter(mem0.mutex);      pSlot->pNext = mem0.pScratchFree;      mem0.pScratchFree = pSlot;      mem0.nScratchFree++;      assert( mem0.nScratchFree <= (u32)sqlite3GlobalConfig.nScratch );      sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_USED, -1);      sqlite3_mutex_leave(mem0.mutex);    }else{            assert( sqlite3MemdebugHasType(p, MEMTYPE_SCRATCH) );      assert( sqlite3MemdebugNoType(p, ~MEMTYPE_SCRATCH) );      sqlite3MemdebugSetType(p, MEMTYPE_HEAP);      if( sqlite3GlobalConfig.bMemstat ){        int iSize = sqlite3MallocSize(p);        sqlite3_mutex_enter(mem0.mutex);        sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_OVERFLOW, -iSize);        sqlite3StatusAdd(SQLITE_STATUS_MEMORY_USED, -iSize);        sqlite3StatusAdd(SQLITE_STATUS_MALLOC_COUNT, -1);        sqlite3GlobalConfig.m.xFree(p);        sqlite3_mutex_leave(mem0.mutex);      }else{        sqlite3GlobalConfig.m.xFree(p);      }    }  }}
开发者ID:qtekfun,项目名称:htcDesire820Kernel,代码行数:38,


示例28: mallocWithAlarm

/*** Do a memory allocation with statistics and alarms.  Assume the** lock is already held.*/static int mallocWithAlarm(int n, void **pp){  int nFull;  void *p;  assert( sqlite3_mutex_held(mem0.mutex) );  nFull = sqlite3GlobalConfig.m.xRoundup(n);  sqlite3StatusSet(SQLITE_STATUS_MALLOC_SIZE, n);  if( mem0.alarmCallback!=0 ){    int nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED);    if( nUsed+nFull >= mem0.alarmThreshold ){      sqlite3MallocAlarm(nFull);    }  }  p = sqlite3GlobalConfig.m.xMalloc(nFull);  if( p==0 && mem0.alarmCallback ){    sqlite3MallocAlarm(nFull);    p = sqlite3GlobalConfig.m.xMalloc(nFull);  }  if( p ){    nFull = sqlite3MallocSize(p);    sqlite3StatusAdd(SQLITE_STATUS_MEMORY_USED, nFull);  }  *pp = p;  return nFull;}
开发者ID:erik-knudsen,项目名称:eCos-enhancements,代码行数:28,


示例29: sqlite3_db_status

/* ** Query status information for a single database connection */SQLITE_API int sqlite3_db_status(                                 sqlite3 *db,          /* The database connection whose status is desired */                                 int op,               /* Status verb */                                 int *pCurrent,        /* Write current value here */                                 int *pHighwater,      /* Write high-water mark here */                                 int resetFlag         /* Reset high-water mark if true */){    int rc = SQLITE_OK;   /* Return code */    sqlite3_mutex_enter(db->mutex);    switch( op ){        case SQLITE_DBSTATUS_LOOKASIDE_USED: {            *pCurrent = db->lookaside.nOut;            *pHighwater = db->lookaside.mxOut;            if( resetFlag ){                db->lookaside.mxOut = db->lookaside.nOut;            }            break;        }                    case SQLITE_DBSTATUS_LOOKASIDE_HIT:        case SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE:        case SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL: {            testcase( op==SQLITE_DBSTATUS_LOOKASIDE_HIT );            testcase( op==SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE );            testcase( op==SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL );            assert( (op-SQLITE_DBSTATUS_LOOKASIDE_HIT)>=0 );            assert( (op-SQLITE_DBSTATUS_LOOKASIDE_HIT)<3 );            *pCurrent = 0;            *pHighwater = db->lookaside.anStat[op - SQLITE_DBSTATUS_LOOKASIDE_HIT];            if( resetFlag ){                db->lookaside.anStat[op - SQLITE_DBSTATUS_LOOKASIDE_HIT] = 0;            }            break;        }                        /*             ** Return an approximation for the amount of memory currently used             ** by all pagers associated with the given database connection.  The             ** highwater mark is meaningless and is returned as zero.             */        case SQLITE_DBSTATUS_CACHE_USED: {            int totalUsed = 0;            int i;            sqlite3BtreeEnterAll(db);            for(i=0; i<db->nDb; i++){                Btree *pBt = db->aDb[i].pBt;                if( pBt ){                    Pager *pPager = sqlite3BtreePager(pBt);                    totalUsed += sqlite3PagerMemUsed(pPager);                }            }            sqlite3BtreeLeaveAll(db);            *pCurrent = totalUsed;            *pHighwater = 0;            break;        }                        /*             ** *pCurrent gets an accurate estimate of the amount of memory used             ** to store the schema for all databases (main, temp, and any ATTACHed             ** databases.  *pHighwater is set to zero.             */        case SQLITE_DBSTATUS_SCHEMA_USED: {            int i;                      /* Used to iterate through schemas */            int nByte = 0;              /* Used to accumulate return value */                        sqlite3BtreeEnterAll(db);            db->pnBytesFreed = &nByte;            for(i=0; i<db->nDb; i++){                Schema *pSchema = db->aDb[i].pSchema;                if( ALWAYS(pSchema!=0) ){                    HashElem *p;                                        nByte += sqlite3GlobalConfig.m.xRoundup(sizeof(HashElem)) * (                                                                                 pSchema->tblHash.count                                                                                 + pSchema->trigHash.count                                                                                 + pSchema->idxHash.count                                                                                 + pSchema->fkeyHash.count                                                                                 );                    nByte += sqlite3MallocSize(pSchema->tblHash.ht);                    nByte += sqlite3MallocSize(pSchema->trigHash.ht);                    nByte += sqlite3MallocSize(pSchema->idxHash.ht);                    nByte += sqlite3MallocSize(pSchema->fkeyHash.ht);                                        for(p=sqliteHashFirst(&pSchema->trigHash); p; p=sqliteHashNext(p)){                        sqlite3DeleteTrigger(db, (Trigger*)sqliteHashData(p));                    }                    for(p=sqliteHashFirst(&pSchema->tblHash); p; p=sqliteHashNext(p)){                        sqlite3DeleteTable(db, (Table *)sqliteHashData(p));                    }                }            }            db->pnBytesFreed = 0;            sqlite3BtreeLeaveAll(db);                        *pHighwater = 0;            *pCurrent = nByte;//.........这里部分代码省略.........
开发者ID:pchernev,项目名称:Objective-C-iOS-Categories,代码行数:101,



注:本文中的sqlite3MallocSize函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ sqlite3MutexAlloc函数代码示例
C++ sqlite3MallocFailed函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。