mirror of
https://github.com/postgres/postgres.git
synced 2025-12-07 12:02:30 +03:00
Remove no longer needed casts to Pointer
These casts used to be required when Pointer was char *, but now it's
void * (commit 1b2bb5077e), so they are not needed anymore.
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Discussion: https://www.postgresql.org/message-id/4154950a-47ae-4223-bd01-1235cc50e933%40eisentraut.org
This commit is contained in:
@@ -49,7 +49,7 @@ typedef struct
|
|||||||
*/
|
*/
|
||||||
#define GBT_FREE_IF_COPY(ptr1, ptr2) \
|
#define GBT_FREE_IF_COPY(ptr1, ptr2) \
|
||||||
do { \
|
do { \
|
||||||
if ((Pointer) (ptr1) != DatumGetPointer(ptr2)) \
|
if ((ptr1) != DatumGetPointer(ptr2)) \
|
||||||
pfree(ptr1); \
|
pfree(ptr1); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
|||||||
@@ -569,7 +569,7 @@ toast_build_flattened_tuple(TupleDesc tupleDesc,
|
|||||||
int num_to_free;
|
int num_to_free;
|
||||||
int i;
|
int i;
|
||||||
Datum new_values[MaxTupleAttributeNumber];
|
Datum new_values[MaxTupleAttributeNumber];
|
||||||
Pointer freeable_values[MaxTupleAttributeNumber];
|
void *freeable_values[MaxTupleAttributeNumber];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We can pass the caller's isnull array directly to heap_form_tuple, but
|
* We can pass the caller's isnull array directly to heap_form_tuple, but
|
||||||
@@ -593,7 +593,7 @@ toast_build_flattened_tuple(TupleDesc tupleDesc,
|
|||||||
{
|
{
|
||||||
new_value = detoast_external_attr(new_value);
|
new_value = detoast_external_attr(new_value);
|
||||||
new_values[i] = PointerGetDatum(new_value);
|
new_values[i] = PointerGetDatum(new_value);
|
||||||
freeable_values[num_to_free++] = (Pointer) new_value;
|
freeable_values[num_to_free++] = new_value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3125,7 +3125,7 @@ object_aclmask_ext(Oid classid, Oid objectid, Oid roleid,
|
|||||||
result = aclmask(acl, roleid, ownerId, mask, how);
|
result = aclmask(acl, roleid, ownerId, mask, how);
|
||||||
|
|
||||||
/* if we have a detoasted copy, free it */
|
/* if we have a detoasted copy, free it */
|
||||||
if (acl && (Pointer) acl != DatumGetPointer(aclDatum))
|
if (acl && acl != DatumGetPointer(aclDatum))
|
||||||
pfree(acl);
|
pfree(acl);
|
||||||
|
|
||||||
ReleaseSysCache(tuple);
|
ReleaseSysCache(tuple);
|
||||||
@@ -3255,7 +3255,7 @@ pg_attribute_aclmask_ext(Oid table_oid, AttrNumber attnum, Oid roleid,
|
|||||||
result = aclmask(acl, roleid, ownerId, mask, how);
|
result = aclmask(acl, roleid, ownerId, mask, how);
|
||||||
|
|
||||||
/* if we have a detoasted copy, free it */
|
/* if we have a detoasted copy, free it */
|
||||||
if (acl && (Pointer) acl != DatumGetPointer(aclDatum))
|
if (acl && acl != DatumGetPointer(aclDatum))
|
||||||
pfree(acl);
|
pfree(acl);
|
||||||
|
|
||||||
ReleaseSysCache(attTuple);
|
ReleaseSysCache(attTuple);
|
||||||
@@ -3362,7 +3362,7 @@ pg_class_aclmask_ext(Oid table_oid, Oid roleid, AclMode mask,
|
|||||||
result = aclmask(acl, roleid, ownerId, mask, how);
|
result = aclmask(acl, roleid, ownerId, mask, how);
|
||||||
|
|
||||||
/* if we have a detoasted copy, free it */
|
/* if we have a detoasted copy, free it */
|
||||||
if (acl && (Pointer) acl != DatumGetPointer(aclDatum))
|
if (acl && acl != DatumGetPointer(aclDatum))
|
||||||
pfree(acl);
|
pfree(acl);
|
||||||
|
|
||||||
ReleaseSysCache(tuple);
|
ReleaseSysCache(tuple);
|
||||||
@@ -3454,7 +3454,7 @@ pg_parameter_aclmask(const char *name, Oid roleid, AclMode mask, AclMaskHow how)
|
|||||||
result = aclmask(acl, roleid, BOOTSTRAP_SUPERUSERID, mask, how);
|
result = aclmask(acl, roleid, BOOTSTRAP_SUPERUSERID, mask, how);
|
||||||
|
|
||||||
/* if we have a detoasted copy, free it */
|
/* if we have a detoasted copy, free it */
|
||||||
if (acl && (Pointer) acl != DatumGetPointer(aclDatum))
|
if (acl && acl != DatumGetPointer(aclDatum))
|
||||||
pfree(acl);
|
pfree(acl);
|
||||||
|
|
||||||
ReleaseSysCache(tuple);
|
ReleaseSysCache(tuple);
|
||||||
@@ -3509,7 +3509,7 @@ pg_parameter_acl_aclmask(Oid acl_oid, Oid roleid, AclMode mask, AclMaskHow how)
|
|||||||
result = aclmask(acl, roleid, BOOTSTRAP_SUPERUSERID, mask, how);
|
result = aclmask(acl, roleid, BOOTSTRAP_SUPERUSERID, mask, how);
|
||||||
|
|
||||||
/* if we have a detoasted copy, free it */
|
/* if we have a detoasted copy, free it */
|
||||||
if (acl && (Pointer) acl != DatumGetPointer(aclDatum))
|
if (acl && acl != DatumGetPointer(aclDatum))
|
||||||
pfree(acl);
|
pfree(acl);
|
||||||
|
|
||||||
ReleaseSysCache(tuple);
|
ReleaseSysCache(tuple);
|
||||||
@@ -3589,7 +3589,7 @@ pg_largeobject_aclmask_snapshot(Oid lobj_oid, Oid roleid,
|
|||||||
result = aclmask(acl, roleid, ownerId, mask, how);
|
result = aclmask(acl, roleid, ownerId, mask, how);
|
||||||
|
|
||||||
/* if we have a detoasted copy, free it */
|
/* if we have a detoasted copy, free it */
|
||||||
if (acl && (Pointer) acl != DatumGetPointer(aclDatum))
|
if (acl && acl != DatumGetPointer(aclDatum))
|
||||||
pfree(acl);
|
pfree(acl);
|
||||||
|
|
||||||
systable_endscan(scan);
|
systable_endscan(scan);
|
||||||
@@ -3683,7 +3683,7 @@ pg_namespace_aclmask_ext(Oid nsp_oid, Oid roleid,
|
|||||||
result = aclmask(acl, roleid, ownerId, mask, how);
|
result = aclmask(acl, roleid, ownerId, mask, how);
|
||||||
|
|
||||||
/* if we have a detoasted copy, free it */
|
/* if we have a detoasted copy, free it */
|
||||||
if (acl && (Pointer) acl != DatumGetPointer(aclDatum))
|
if (acl && acl != DatumGetPointer(aclDatum))
|
||||||
pfree(acl);
|
pfree(acl);
|
||||||
|
|
||||||
ReleaseSysCache(tuple);
|
ReleaseSysCache(tuple);
|
||||||
@@ -3819,7 +3819,7 @@ pg_type_aclmask_ext(Oid type_oid, Oid roleid, AclMode mask, AclMaskHow how,
|
|||||||
result = aclmask(acl, roleid, ownerId, mask, how);
|
result = aclmask(acl, roleid, ownerId, mask, how);
|
||||||
|
|
||||||
/* if we have a detoasted copy, free it */
|
/* if we have a detoasted copy, free it */
|
||||||
if (acl && (Pointer) acl != DatumGetPointer(aclDatum))
|
if (acl && acl != DatumGetPointer(aclDatum))
|
||||||
pfree(acl);
|
pfree(acl);
|
||||||
|
|
||||||
ReleaseSysCache(tuple);
|
ReleaseSysCache(tuple);
|
||||||
@@ -4003,7 +4003,7 @@ pg_attribute_aclcheck_all_ext(Oid table_oid, Oid roleid,
|
|||||||
attmask = aclmask(acl, roleid, ownerId, mode, ACLMASK_ANY);
|
attmask = aclmask(acl, roleid, ownerId, mode, ACLMASK_ANY);
|
||||||
|
|
||||||
/* if we have a detoasted copy, free it */
|
/* if we have a detoasted copy, free it */
|
||||||
if ((Pointer) acl != DatumGetPointer(aclDatum))
|
if (acl != DatumGetPointer(aclDatum))
|
||||||
pfree(acl);
|
pfree(acl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1544,7 +1544,7 @@ DeconstructFkConstraintRow(HeapTuple tuple, int *numfks,
|
|||||||
if (numkeys <= 0 || numkeys > INDEX_MAX_KEYS)
|
if (numkeys <= 0 || numkeys > INDEX_MAX_KEYS)
|
||||||
elog(ERROR, "foreign key constraint cannot have %d columns", numkeys);
|
elog(ERROR, "foreign key constraint cannot have %d columns", numkeys);
|
||||||
memcpy(conkey, ARR_DATA_PTR(arr), numkeys * sizeof(int16));
|
memcpy(conkey, ARR_DATA_PTR(arr), numkeys * sizeof(int16));
|
||||||
if ((Pointer) arr != DatumGetPointer(adatum))
|
if (arr != DatumGetPointer(adatum))
|
||||||
pfree(arr); /* free de-toasted copy, if any */
|
pfree(arr); /* free de-toasted copy, if any */
|
||||||
|
|
||||||
adatum = SysCacheGetAttrNotNull(CONSTROID, tuple,
|
adatum = SysCacheGetAttrNotNull(CONSTROID, tuple,
|
||||||
@@ -1556,7 +1556,7 @@ DeconstructFkConstraintRow(HeapTuple tuple, int *numfks,
|
|||||||
ARR_ELEMTYPE(arr) != INT2OID)
|
ARR_ELEMTYPE(arr) != INT2OID)
|
||||||
elog(ERROR, "confkey is not a 1-D smallint array");
|
elog(ERROR, "confkey is not a 1-D smallint array");
|
||||||
memcpy(confkey, ARR_DATA_PTR(arr), numkeys * sizeof(int16));
|
memcpy(confkey, ARR_DATA_PTR(arr), numkeys * sizeof(int16));
|
||||||
if ((Pointer) arr != DatumGetPointer(adatum))
|
if (arr != DatumGetPointer(adatum))
|
||||||
pfree(arr); /* free de-toasted copy, if any */
|
pfree(arr); /* free de-toasted copy, if any */
|
||||||
|
|
||||||
if (pf_eq_oprs)
|
if (pf_eq_oprs)
|
||||||
@@ -1571,7 +1571,7 @@ DeconstructFkConstraintRow(HeapTuple tuple, int *numfks,
|
|||||||
ARR_ELEMTYPE(arr) != OIDOID)
|
ARR_ELEMTYPE(arr) != OIDOID)
|
||||||
elog(ERROR, "conpfeqop is not a 1-D Oid array");
|
elog(ERROR, "conpfeqop is not a 1-D Oid array");
|
||||||
memcpy(pf_eq_oprs, ARR_DATA_PTR(arr), numkeys * sizeof(Oid));
|
memcpy(pf_eq_oprs, ARR_DATA_PTR(arr), numkeys * sizeof(Oid));
|
||||||
if ((Pointer) arr != DatumGetPointer(adatum))
|
if (arr != DatumGetPointer(adatum))
|
||||||
pfree(arr); /* free de-toasted copy, if any */
|
pfree(arr); /* free de-toasted copy, if any */
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1586,7 +1586,7 @@ DeconstructFkConstraintRow(HeapTuple tuple, int *numfks,
|
|||||||
ARR_ELEMTYPE(arr) != OIDOID)
|
ARR_ELEMTYPE(arr) != OIDOID)
|
||||||
elog(ERROR, "conppeqop is not a 1-D Oid array");
|
elog(ERROR, "conppeqop is not a 1-D Oid array");
|
||||||
memcpy(pp_eq_oprs, ARR_DATA_PTR(arr), numkeys * sizeof(Oid));
|
memcpy(pp_eq_oprs, ARR_DATA_PTR(arr), numkeys * sizeof(Oid));
|
||||||
if ((Pointer) arr != DatumGetPointer(adatum))
|
if (arr != DatumGetPointer(adatum))
|
||||||
pfree(arr); /* free de-toasted copy, if any */
|
pfree(arr); /* free de-toasted copy, if any */
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1601,7 +1601,7 @@ DeconstructFkConstraintRow(HeapTuple tuple, int *numfks,
|
|||||||
ARR_ELEMTYPE(arr) != OIDOID)
|
ARR_ELEMTYPE(arr) != OIDOID)
|
||||||
elog(ERROR, "conffeqop is not a 1-D Oid array");
|
elog(ERROR, "conffeqop is not a 1-D Oid array");
|
||||||
memcpy(ff_eq_oprs, ARR_DATA_PTR(arr), numkeys * sizeof(Oid));
|
memcpy(ff_eq_oprs, ARR_DATA_PTR(arr), numkeys * sizeof(Oid));
|
||||||
if ((Pointer) arr != DatumGetPointer(adatum))
|
if (arr != DatumGetPointer(adatum))
|
||||||
pfree(arr); /* free de-toasted copy, if any */
|
pfree(arr); /* free de-toasted copy, if any */
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1624,7 +1624,7 @@ DeconstructFkConstraintRow(HeapTuple tuple, int *numfks,
|
|||||||
elog(ERROR, "confdelsetcols is not a 1-D smallint array");
|
elog(ERROR, "confdelsetcols is not a 1-D smallint array");
|
||||||
num_delete_cols = ARR_DIMS(arr)[0];
|
num_delete_cols = ARR_DIMS(arr)[0];
|
||||||
memcpy(fk_del_set_cols, ARR_DATA_PTR(arr), num_delete_cols * sizeof(int16));
|
memcpy(fk_del_set_cols, ARR_DATA_PTR(arr), num_delete_cols * sizeof(int16));
|
||||||
if ((Pointer) arr != DatumGetPointer(adatum))
|
if (arr != DatumGetPointer(adatum))
|
||||||
pfree(arr); /* free de-toasted copy, if any */
|
pfree(arr); /* free de-toasted copy, if any */
|
||||||
|
|
||||||
*num_fk_del_set_cols = num_delete_cols;
|
*num_fk_del_set_cols = num_delete_cols;
|
||||||
|
|||||||
@@ -5687,7 +5687,7 @@ accumArrayResultArr(ArrayBuildStateArr *astate,
|
|||||||
MemoryContextSwitchTo(oldcontext);
|
MemoryContextSwitchTo(oldcontext);
|
||||||
|
|
||||||
/* Release detoasted copy if any */
|
/* Release detoasted copy if any */
|
||||||
if ((Pointer) arg != DatumGetPointer(dvalue))
|
if (arg != DatumGetPointer(dvalue))
|
||||||
pfree(arg);
|
pfree(arg);
|
||||||
|
|
||||||
return astate;
|
return astate;
|
||||||
|
|||||||
@@ -299,9 +299,9 @@ datum_image_eq(Datum value1, Datum value2, bool typByVal, int typLen)
|
|||||||
len1 - VARHDRSZ) == 0);
|
len1 - VARHDRSZ) == 0);
|
||||||
|
|
||||||
/* Only free memory if it's a copy made here. */
|
/* Only free memory if it's a copy made here. */
|
||||||
if ((Pointer) arg1val != DatumGetPointer(value1))
|
if (arg1val != DatumGetPointer(value1))
|
||||||
pfree(arg1val);
|
pfree(arg1val);
|
||||||
if ((Pointer) arg2val != DatumGetPointer(value2))
|
if (arg2val != DatumGetPointer(value2))
|
||||||
pfree(arg2val);
|
pfree(arg2val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -355,7 +355,7 @@ datum_image_hash(Datum value, bool typByVal, int typLen)
|
|||||||
result = hash_bytes((unsigned char *) VARDATA_ANY(val), len - VARHDRSZ);
|
result = hash_bytes((unsigned char *) VARDATA_ANY(val), len - VARHDRSZ);
|
||||||
|
|
||||||
/* Only free memory if it's a copy made here. */
|
/* Only free memory if it's a copy made here. */
|
||||||
if ((Pointer) val != DatumGetPointer(value))
|
if (val != DatumGetPointer(value))
|
||||||
pfree(val);
|
pfree(val);
|
||||||
}
|
}
|
||||||
else if (typLen == -2)
|
else if (typLen == -2)
|
||||||
|
|||||||
@@ -1035,7 +1035,7 @@ like_fixed_prefix(Const *patt_const, bool case_insensitive, Oid collation,
|
|||||||
pattlen = VARSIZE_ANY_EXHDR(bstr);
|
pattlen = VARSIZE_ANY_EXHDR(bstr);
|
||||||
patt = (char *) palloc(pattlen);
|
patt = (char *) palloc(pattlen);
|
||||||
memcpy(patt, VARDATA_ANY(bstr), pattlen);
|
memcpy(patt, VARDATA_ANY(bstr), pattlen);
|
||||||
Assert((Pointer) bstr == DatumGetPointer(patt_const->constvalue));
|
Assert(bstr == DatumGetPointer(patt_const->constvalue));
|
||||||
}
|
}
|
||||||
|
|
||||||
match = palloc(pattlen + 1);
|
match = palloc(pattlen + 1);
|
||||||
@@ -1577,7 +1577,7 @@ make_greater_string(const Const *str_const, FmgrInfo *ltproc, Oid collation)
|
|||||||
len = VARSIZE_ANY_EXHDR(bstr);
|
len = VARSIZE_ANY_EXHDR(bstr);
|
||||||
workstr = (char *) palloc(len);
|
workstr = (char *) palloc(len);
|
||||||
memcpy(workstr, VARDATA_ANY(bstr), len);
|
memcpy(workstr, VARDATA_ANY(bstr), len);
|
||||||
Assert((Pointer) bstr == DatumGetPointer(str_const->constvalue));
|
Assert(bstr == DatumGetPointer(str_const->constvalue));
|
||||||
cmpstr = str_const->constvalue;
|
cmpstr = str_const->constvalue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -2194,7 +2194,7 @@ numeric_abbrev_convert(Datum original_datum, SortSupport ssup)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* should happen only for external/compressed toasts */
|
/* should happen only for external/compressed toasts */
|
||||||
if ((Pointer) original_varatt != DatumGetPointer(original_datum))
|
if (original_varatt != DatumGetPointer(original_datum))
|
||||||
pfree(original_varatt);
|
pfree(original_varatt);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@@ -2284,9 +2284,9 @@ numeric_fast_cmp(Datum x, Datum y, SortSupport ssup)
|
|||||||
|
|
||||||
result = cmp_numerics(nx, ny);
|
result = cmp_numerics(nx, ny);
|
||||||
|
|
||||||
if ((Pointer) nx != DatumGetPointer(x))
|
if (nx != DatumGetPointer(x))
|
||||||
pfree(nx);
|
pfree(nx);
|
||||||
if ((Pointer) ny != DatumGetPointer(y))
|
if (ny != DatumGetPointer(y))
|
||||||
pfree(ny);
|
pfree(ny);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -1513,9 +1513,9 @@ range_fast_cmp(Datum a, Datum b, SortSupport ssup)
|
|||||||
cmp = range_cmp_bounds(typcache, &upper1, &upper2);
|
cmp = range_cmp_bounds(typcache, &upper1, &upper2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((Pointer) range_a != DatumGetPointer(a))
|
if (range_a != DatumGetPointer(a))
|
||||||
pfree(range_a);
|
pfree(range_a);
|
||||||
if ((Pointer) range_b != DatumGetPointer(b))
|
if (range_b != DatumGetPointer(b))
|
||||||
pfree(range_b);
|
pfree(range_b);
|
||||||
|
|
||||||
return cmp;
|
return cmp;
|
||||||
|
|||||||
@@ -1529,9 +1529,9 @@ record_image_cmp(FunctionCallInfo fcinfo)
|
|||||||
if ((cmpresult == 0) && (len1 != len2))
|
if ((cmpresult == 0) && (len1 != len2))
|
||||||
cmpresult = (len1 < len2) ? -1 : 1;
|
cmpresult = (len1 < len2) ? -1 : 1;
|
||||||
|
|
||||||
if ((Pointer) arg1val != DatumGetPointer(values1[i1]))
|
if (arg1val != DatumGetPointer(values1[i1]))
|
||||||
pfree(arg1val);
|
pfree(arg1val);
|
||||||
if ((Pointer) arg2val != DatumGetPointer(values2[i2]))
|
if (arg2val != DatumGetPointer(values2[i2]))
|
||||||
pfree(arg2val);
|
pfree(arg2val);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
2
src/backend/utils/cache/evtcache.c
vendored
2
src/backend/utils/cache/evtcache.c
vendored
@@ -240,7 +240,7 @@ DecodeTextArrayToBitmapset(Datum array)
|
|||||||
}
|
}
|
||||||
|
|
||||||
pfree(elems);
|
pfree(elems);
|
||||||
if ((Pointer) arr != DatumGetPointer(array))
|
if (arr != DatumGetPointer(array))
|
||||||
pfree(arr);
|
pfree(arr);
|
||||||
|
|
||||||
return bms;
|
return bms;
|
||||||
|
|||||||
@@ -259,7 +259,7 @@ extern struct varlena *pg_detoast_datum_packed(struct varlena *datum);
|
|||||||
*/
|
*/
|
||||||
#define PG_FREE_IF_COPY(ptr,n) \
|
#define PG_FREE_IF_COPY(ptr,n) \
|
||||||
do { \
|
do { \
|
||||||
if ((Pointer) (ptr) != PG_GETARG_POINTER(n)) \
|
if ((ptr) != PG_GETARG_POINTER(n)) \
|
||||||
pfree(ptr); \
|
pfree(ptr); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user