aboutsummaryrefslogtreecommitdiff
path: root/src/tutorial/C-code/funcs.c
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>1997-09-07 05:04:48 +0000
committerBruce Momjian <bruce@momjian.us>1997-09-07 05:04:48 +0000
commit1ccd423235a48739d6f7a4d7889705b5f9ecc69b (patch)
tree8001c4e839dfad8f29ceda7f8c5f5dbb8759b564 /src/tutorial/C-code/funcs.c
parent8fecd4febf8357f3cc20383ed29ced484877d5ac (diff)
downloadpostgresql-1ccd423235a48739d6f7a4d7889705b5f9ecc69b.tar.gz
postgresql-1ccd423235a48739d6f7a4d7889705b5f9ecc69b.zip
Massive commit to run PGINDENT on all *.c and *.h files.
Diffstat (limited to 'src/tutorial/C-code/funcs.c')
-rw-r--r--src/tutorial/C-code/funcs.c89
1 files changed, 46 insertions, 43 deletions
diff --git a/src/tutorial/C-code/funcs.c b/src/tutorial/C-code/funcs.c
index 10e541a2249..989787e45ea 100644
--- a/src/tutorial/C-code/funcs.c
+++ b/src/tutorial/C-code/funcs.c
@@ -8,70 +8,73 @@
#include <string.h>
#include <stdio.h>
-#include "postgres.h" /* for char16, etc. */
-#include "utils/palloc.h" /* for palloc */
-#include "libpq-fe.h" /* for TUPLE */
-#include "executor/executor.h" /* for GetAttributeByName() */
+#include "postgres.h" /* for char16, etc. */
+#include "utils/palloc.h" /* for palloc */
+#include "libpq-fe.h" /* for TUPLE */
+#include "executor/executor.h" /* for GetAttributeByName() */
-/* The following prototypes declare what we assume the user declares to
+/* The following prototypes declare what we assume the user declares to
Postgres in his CREATE FUNCTION statement.
*/
-int add_one(int arg);
-char16 * concat16(char16 *arg1, char16 *arg2);
-text * copytext(text *t);
-bool c_overpaid(TUPLE t, /* the current instance of EMP */
- int4 limit);
+int add_one(int arg);
+char16 *concat16(char16 * arg1, char16 * arg2);
+text *copytext(text * t);
+bool
+c_overpaid(TUPLE t, /* the current instance of EMP */
+ int4 limit);
int
add_one(int arg)
{
- return(arg + 1);
+ return (arg + 1);
}
-char16 *
-concat16(char16 *arg1, char16 *arg2)
+char16 *
+concat16(char16 * arg1, char16 * arg2)
{
- char16 *new_c16 = (char16 *) palloc(sizeof(char16));
+ char16 *new_c16 = (char16 *) palloc(sizeof(char16));
- memset(new_c16, 0, sizeof(char16));
- strncpy((char*)new_c16, (char*)arg1, 16);
- return (char16 *)(strncat((char*)new_c16, (char*)arg2, 16));
+ memset(new_c16, 0, sizeof(char16));
+ strncpy((char *) new_c16, (char *) arg1, 16);
+ return (char16 *) (strncat((char *) new_c16, (char *) arg2, 16));
}
-text *
-copytext(text *t)
+text *
+copytext(text * t)
{
- /*
- * VARSIZE is the total size of the struct in bytes.
- */
- text *new_t = (text *) palloc(VARSIZE(t));
-
- memset(new_t, 0, VARSIZE(t));
-
- VARSIZE(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));
+
+ memset(new_t, 0, VARSIZE(t));
+
+ VARSIZE(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);
}
bool
-c_overpaid(TUPLE t, /* the current instance of EMP */
- int4 limit)
+c_overpaid(TUPLE t, /* the current instance of EMP */
+ int4 limit)
{
- bool isnull = false;
- int4 salary;
+ bool isnull = false;
+ int4 salary;
- salary = (int4) GetAttributeByName(t, "salary", &isnull);
+ salary = (int4) GetAttributeByName(t, "salary", &isnull);
- if (isnull)
- return (false);
- return(salary > limit);
+ if (isnull)
+ return (false);
+ return (salary > limit);
}