/* * Types are always allocated in global context. */ Type TypeClass_allocInstance2(TypeClass cls, Oid typeId, Form_pg_type pgType) { Type t = (Type)PgObjectClass_allocInstance((PgObjectClass)(cls), TopMemoryContext); t->typeId = typeId; t->arrayType = 0; t->elementType = 0; t->objectType = 0; t->inCoercions = 0; t->outCoercions = 0; if(pgType != 0) { t->length = pgType->typlen; t->byValue = pgType->typbyval; t->align = pgType->typalign; } else if(typeId != InvalidOid) { get_typlenbyvalalign(typeId, &t->length, &t->byValue, &t->align); } else { t->length = 0; t->byValue = true; t->align = 'i'; } return t; }
Iterator Iterator_create(HashMap source) { Iterator self = (Iterator)PgObjectClass_allocInstance(s_IteratorClass, GetMemoryChunkContext(source)); self->source = source; self->sourceTableSize = source->tableSize; self->currentBucket = 0; self->nextEntry = 0; return self; }
static Function Function_create(PG_FUNCTION_ARGS) { ParseResultData info; Function self = (Function)PgObjectClass_allocInstance(s_FunctionClass, TopMemoryContext); HeapTuple procTup = PgObject_getValidTuple(PROCOID, fcinfo->flinfo->fn_oid, "function"); memset(&info, 0, sizeof(ParseResultData)); parseFunction(&info, procTup); Function_init(self, &info, (Form_pg_proc)GETSTRUCT(procTup), fcinfo); pfree(info.buffer); ReleaseSysCache(procTup); return self; }