Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit72257f9

Browse files
committed
simplehash: Additional tweaks to make specifying an allocator work.
Even if we don't emit definitions for SH_ALLOCATE and SH_FREE, westill need prototypes. The user can't define them before includingsimplehash.h because SH_TYPE isn't available yet.For the allocator to be able to access private_data, it needs tobecome an argument to SH_CREATE. Previously we relied on callersto set that after returning from SH_CREATE, but SH_CREATE callsSH_ALLOCATE before returning.Dilip Kumar, reviewed by me.
1 parent3f3d60d commit72257f9

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

‎src/backend/executor/execGrouping.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,8 +330,7 @@ BuildTupleHashTable(int numCols, AttrNumber *keyColIdx,
330330
else
331331
hashtable->hash_iv=0;
332332

333-
hashtable->hashtab=tuplehash_create(tablecxt,nbuckets);
334-
hashtable->hashtab->private_data=hashtable;
333+
hashtable->hashtab=tuplehash_create(tablecxt,nbuckets,hashtable);
335334

336335
returnhashtable;
337336
}

‎src/backend/nodes/tidbitmap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ tbm_create_pagetable(TIDBitmap *tbm)
244244
Assert(tbm->status!=TBM_HASH);
245245
Assert(tbm->pagetable==NULL);
246246

247-
tbm->pagetable=pagetable_create(tbm->mcxt,128);
247+
tbm->pagetable=pagetable_create(tbm->mcxt,128,NULL);
248248

249249
/* If entry1 is valid, push it into the hashtable */
250250
if (tbm->status==TBM_ONE_PAGE)

‎src/include/lib/simplehash.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ typedef struct SH_ITERATOR
137137
}SH_ITERATOR;
138138

139139
/* externally visible function prototypes */
140-
SH_SCOPESH_TYPE*SH_CREATE(MemoryContextctx,uint32nelements);
140+
SH_SCOPESH_TYPE*SH_CREATE(MemoryContextctx,uint32nelements,
141+
void*private_data);
141142
SH_SCOPEvoidSH_DESTROY(SH_TYPE*tb);
142143
SH_SCOPEvoidSH_GROW(SH_TYPE*tb,uint32newsize);
143144
SH_SCOPESH_ELEMENT_TYPE*SH_INSERT(SH_TYPE*tb,SH_KEY_TYPEkey,bool*found);
@@ -280,6 +281,10 @@ SH_ENTRY_HASH(SH_TYPE *tb, SH_ELEMENT_TYPE * entry)
280281
#endif
281282
}
282283

284+
/* default memory allocator function */
285+
staticinlinevoid*SH_ALLOCATE(SH_TYPE*type,Sizesize);
286+
staticinlinevoidSH_FREE(SH_TYPE*type,void*pointer);
287+
283288
#ifndefSH_USE_NONDEFAULT_ALLOCATOR
284289

285290
/* default memory allocator function */
@@ -309,13 +314,14 @@ SH_FREE(SH_TYPE *type, void *pointer)
309314
* the passed-in context.
310315
*/
311316
SH_SCOPESH_TYPE*
312-
SH_CREATE(MemoryContextctx,uint32nelements)
317+
SH_CREATE(MemoryContextctx,uint32nelements,void*private_data)
313318
{
314319
SH_TYPE*tb;
315320
uint64size;
316321

317322
tb=MemoryContextAllocZero(ctx,sizeof(SH_TYPE));
318323
tb->ctx=ctx;
324+
tb->private_data=private_data;
319325

320326
/* increase nelements by fillfactor, want to store nelements elements */
321327
size=Min((double)SH_MAX_SIZE, ((double)nelements) /SH_FILLFACTOR);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp