diff options
author | Bruce Momjian <bruce@momjian.us> | 2001-03-22 04:01:46 +0000 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 2001-03-22 04:01:46 +0000 |
commit | 9e1552607a9dc6bc23e43d46770a9063ade4f3f0 (patch) | |
tree | 6a230d81917ebc004e40cd46c48f2aa27eec153e /src/tutorial/funcs.c | |
parent | 6cf8707b828b14b5c2336076ce358b18b67829d6 (diff) | |
download | postgresql-9e1552607a9dc6bc23e43d46770a9063ade4f3f0.tar.gz postgresql-9e1552607a9dc6bc23e43d46770a9063ade4f3f0.zip |
pgindent run. Make it all clean.
Diffstat (limited to 'src/tutorial/funcs.c')
-rw-r--r-- | src/tutorial/funcs.c | 81 |
1 files changed, 42 insertions, 39 deletions
diff --git a/src/tutorial/funcs.c b/src/tutorial/funcs.c index 58ede56cc88..cb3de3e6e76 100644 --- a/src/tutorial/funcs.c +++ b/src/tutorial/funcs.c @@ -18,20 +18,20 @@ /* These prototypes just prevent possible warnings from gcc. */ int add_one(int arg); -float8 *add_one_float8(float8 *arg); +float8 *add_one_float8(float8 *arg); Point *makepoint(Point *pointx, Point *pointy); text *copytext(text *t); -text *concat_text(text *arg1, text *arg2); +text *concat_text(text *arg1, text *arg2); bool c_overpaid(TupleTableSlot *t, /* the current instance of EMP */ int32 limit); /* By Value */ - + int add_one(int arg) { - return arg + 1; + return arg + 1; } /* By Reference, Fixed Length */ @@ -39,22 +39,22 @@ add_one(int arg) float8 * add_one_float8(float8 *arg) { - float8 *result = (float8 *) palloc(sizeof(float8)); + float8 *result = (float8 *) palloc(sizeof(float8)); + + *result = *arg + 1.0; - *result = *arg + 1.0; - - return result; + return result; } Point * makepoint(Point *pointx, Point *pointy) { - Point *new_point = (Point *) palloc(sizeof(Point)); + Point *new_point = (Point *) palloc(sizeof(Point)); + + new_point->x = pointx->x; + new_point->y = pointy->y; - new_point->x = pointx->x; - new_point->y = pointy->y; - - return new_point; + return new_point; } /* By Reference, Variable Length */ @@ -62,31 +62,34 @@ makepoint(Point *pointx, Point *pointy) text * copytext(text *t) { - /* - * VARSIZE is the total size of the struct in bytes. - */ - text *new_t = (text *) palloc(VARSIZE(t)); - VARATT_SIZEP(new_t) = VARSIZE(t); - /* - * VARDATA is a pointer to the data region of the struct. - */ - memcpy((void *) VARDATA(new_t), /* destination */ - (void *) VARDATA(t), /* source */ - VARSIZE(t)-VARHDRSZ); /* how many bytes */ - return new_t; + + /* + * VARSIZE is the total size of the struct in bytes. + */ + text *new_t = (text *) palloc(VARSIZE(t)); + + VARATT_SIZEP(new_t) = VARSIZE(t); + + /* + * VARDATA is a pointer to the data region of the struct. + */ + memcpy((void *) VARDATA(new_t), /* destination */ + (void *) VARDATA(t), /* source */ + VARSIZE(t) - VARHDRSZ); /* how many bytes */ + return new_t; } text * concat_text(text *arg1, text *arg2) { - int32 new_text_size = VARSIZE(arg1) + VARSIZE(arg2) - VARHDRSZ; - text *new_text = (text *) palloc(new_text_size); - - memset((void *) new_text, 0, new_text_size); - VARATT_SIZEP(new_text) = new_text_size; - strncpy(VARDATA(new_text), VARDATA(arg1), VARSIZE(arg1)-VARHDRSZ); - strncat(VARDATA(new_text), VARDATA(arg2), VARSIZE(arg2)-VARHDRSZ); - return new_text; + int32 new_text_size = VARSIZE(arg1) + VARSIZE(arg2) - VARHDRSZ; + text *new_text = (text *) palloc(new_text_size); + + memset((void *) new_text, 0, new_text_size); + VARATT_SIZEP(new_text) = new_text_size; + strncpy(VARDATA(new_text), VARDATA(arg1), VARSIZE(arg1) - VARHDRSZ); + strncat(VARDATA(new_text), VARDATA(arg2), VARSIZE(arg2) - VARHDRSZ); + return new_text; } /* Composite types */ @@ -95,11 +98,11 @@ bool c_overpaid(TupleTableSlot *t, /* the current instance of EMP */ int32 limit) { - bool isnull; - int32 salary; + bool isnull; + int32 salary; - salary = DatumGetInt32(GetAttributeByName(t, "salary", &isnull)); - if (isnull) - return (false); - return salary > limit; + salary = DatumGetInt32(GetAttributeByName(t, "salary", &isnull)); + if (isnull) + return (false); + return salary > limit; } |