*
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/pg_config/pg_config.c,v 1.20 2006/06/06 22:41:09 momjian Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_config/pg_config.c,v 1.21 2006/09/27 16:19:42 tgl Exp $
*
*-------------------------------------------------------------------------
*/
if (all)
printf("PGXS = ");
get_pkglib_path(mypath, path);
- strncat(path, "/pgxs/src/makefiles/pgxs.mk", MAXPGPATH - 1);
+ strncat(path, "/pgxs/src/makefiles/pgxs.mk", MAXPGPATH - 1 - strlen(path));
cleanup_path(path);
printf("%s\n", path);
}
-/* $PostgreSQL: pgsql/src/tutorial/funcs.c,v 1.15 2006/05/31 20:58:09 tgl Exp $ */
+/* $PostgreSQL: pgsql/src/tutorial/funcs.c,v 1.16 2006/09/27 16:19:42 tgl Exp $ */
/******************************************************************************
These are user-defined functions that can be bound to a Postgres backend
text *
concat_text(text *arg1, text *arg2)
{
- int32 new_text_size = VARSIZE(arg1) + VARSIZE(arg2) - VARHDRSZ;
+ int32 arg1_size = VARSIZE(arg1) - VARHDRSZ;
+ int32 arg2_size = VARSIZE(arg2) - VARHDRSZ;
+ int32 new_text_size = arg1_size + arg2_size + 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);
+ memcpy(VARDATA(new_text), VARDATA(arg1), arg1_size);
+ memcpy(VARDATA(new_text) + arg1_size, VARDATA(arg2), arg2_size);
return new_text;
}
-/* $PostgreSQL: pgsql/src/tutorial/funcs_new.c,v 1.11 2006/07/14 14:52:27 momjian Exp $ */
+/* $PostgreSQL: pgsql/src/tutorial/funcs_new.c,v 1.12 2006/09/27 16:19:42 tgl Exp $ */
/******************************************************************************
These are user-defined functions that can be bound to a Postgres backend
{
text *arg1 = PG_GETARG_TEXT_P(0);
text *arg2 = PG_GETARG_TEXT_P(1);
- int32 new_text_size = VARSIZE(arg1) + VARSIZE(arg2) - VARHDRSZ;
+ int32 arg1_size = VARSIZE(arg1) - VARHDRSZ;
+ int32 arg2_size = VARSIZE(arg2) - VARHDRSZ;
+ int32 new_text_size = arg1_size + arg2_size + 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);
+ memcpy(VARDATA(new_text), VARDATA(arg1), arg1_size);
+ memcpy(VARDATA(new_text) + arg1_size, VARDATA(arg2), arg2_size);
PG_RETURN_TEXT_P(new_text);
}