1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-15 03:41:20 +03:00

Massive commit to run PGINDENT on all *.c and *.h files.

This commit is contained in:
Bruce Momjian
1997-09-07 05:04:48 +00:00
parent 8fecd4febf
commit 1ccd423235
687 changed files with 150775 additions and 136888 deletions

View File

@@ -2,47 +2,49 @@
*
* Varray.c --
*
* routines to provide a generic set of functions to handle variable sized
* arrays. originally by Jiang Wu
* routines to provide a generic set of functions to handle variable sized
* arrays. originally by Jiang Wu
* ************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include "Varray.h"
Varray *NewVarray(size_t nobj, size_t size)
Varray *
NewVarray(size_t nobj, size_t size)
/*
* NewVarray -- allocate a Varray to contain an array of val each of which
* is size valSize. Returns the Varray if successful,
* returns NULL otherwise.
* is size valSize. Returns the Varray if successful,
* returns NULL otherwise.
*/
{
Varray *result;
Varray *result;
if (nobj == 0)
nobj = VARRAY_INITIAL_SIZE;
result = (Varray *) malloc(sizeof(Varray));
result->val = (void *) calloc(nobj, size);
if (result == NULL)
return NULL;
result->size = size;
result->nobj = 0;
result->maxObj = nobj;
return result;
if (nobj == 0)
nobj = VARRAY_INITIAL_SIZE;
result = (Varray *) malloc(sizeof(Varray));
result->val = (void *) calloc(nobj, size);
if (result == NULL)
return NULL;
result->size = size;
result->nobj = 0;
result->maxObj = nobj;
return result;
}
int AppendVarray(Varray *array, void *value, CopyingFunct copy)
int
AppendVarray(Varray * array, void *value, CopyingFunct copy)
/*
* AppendVarray -- append value to the end of array. This function
* returns the size of the array after the addition of
* the new element.
* returns the size of the array after the addition of
* the new element.
*/
{
copy(value, VARRAY_NTH(array->val, array->size, array->nobj));
array->nobj++;
if (array->nobj >= array->maxObj) {
ENLARGE_VARRAY(array, array->maxObj / 2);
}
return array->nobj;
copy(value, VARRAY_NTH(array->val, array->size, array->nobj));
array->nobj++;
if (array->nobj >= array->maxObj)
{
ENLARGE_VARRAY(array, array->maxObj / 2);
}
return array->nobj;
}