Github user cwelton commented on a diff in the pull request:
https://github.com/apache/incubator-madlib/pull/10#discussion_r49795535
--- Diff: methods/array_ops/src/pg_gp/array_ops.c ---
@@ -824,6 +836,25 @@ array_fill(PG_FUNCTION_ARGS){
}
/*
+ * This function apply cos function to each element.
+ */
+PG_FUNCTION_INFO_V1(array_cos);
+Datum
+array_cos(PG_FUNCTION_ARGS){
+ if (PG_ARGISNULL(0)) { PG_RETURN_NULL(); }
+
+ ArrayType *v1 = PG_GETARG_ARRAYTYPE_P(0);
+ Oid element_type = ARR_ELEMTYPE(v1);
+ Datum v2 = float8_datum_cast(0, element_type);
+
+ ArrayType *res = General_Array_to_Array(v1, v2, element_cos);
+
+ PG_FREE_IF_COPY(v1, 0);
--- End diff --
This is a weird use of PG_FREE_IF_COPY that simply looks wrong to me. This
call is equivalent to pfree(v1), and since that is a passed in argument you are
freeing something that does not belong to this function.
A correct call would be PG_FREE_IF_COPY(v1, PG_GETARG_ARRAYTYPE_P(0)),
except that will never free anything so would be a no-op. Ultimately this line
of code should simply be removed.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---