1
0
mirror of https://github.com/postgres/postgres.git synced 2025-12-06 00:02:13 +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:
Peter Eisentraut
2025-12-04 19:40:08 +01:00
parent 6bd469d26a
commit c6be3daa05
12 changed files with 33 additions and 33 deletions

View File

@@ -49,7 +49,7 @@ typedef struct
*/
#define GBT_FREE_IF_COPY(ptr1, ptr2) \
do { \
if ((Pointer) (ptr1) != DatumGetPointer(ptr2)) \
if ((ptr1) != DatumGetPointer(ptr2)) \
pfree(ptr1); \
} while (0)

View File

@@ -569,7 +569,7 @@ toast_build_flattened_tuple(TupleDesc tupleDesc,
int num_to_free;
int i;
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
@@ -593,7 +593,7 @@ toast_build_flattened_tuple(TupleDesc tupleDesc,
{
new_value = detoast_external_attr(new_value);
new_values[i] = PointerGetDatum(new_value);
freeable_values[num_to_free++] = (Pointer) new_value;
freeable_values[num_to_free++] = new_value;
}
}
}

View File

@@ -3125,7 +3125,7 @@ object_aclmask_ext(Oid classid, Oid objectid, Oid roleid,
result = aclmask(acl, roleid, ownerId, mask, how);
/* if we have a detoasted copy, free it */
if (acl && (Pointer) acl != DatumGetPointer(aclDatum))
if (acl && acl != DatumGetPointer(aclDatum))
pfree(acl);
ReleaseSysCache(tuple);
@@ -3255,7 +3255,7 @@ pg_attribute_aclmask_ext(Oid table_oid, AttrNumber attnum, Oid roleid,
result = aclmask(acl, roleid, ownerId, mask, how);
/* if we have a detoasted copy, free it */
if (acl && (Pointer) acl != DatumGetPointer(aclDatum))
if (acl && acl != DatumGetPointer(aclDatum))
pfree(acl);
ReleaseSysCache(attTuple);
@@ -3362,7 +3362,7 @@ pg_class_aclmask_ext(Oid table_oid, Oid roleid, AclMode mask,
result = aclmask(acl, roleid, ownerId, mask, how);
/* if we have a detoasted copy, free it */
if (acl && (Pointer) acl != DatumGetPointer(aclDatum))
if (acl && acl != DatumGetPointer(aclDatum))
pfree(acl);
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);
/* if we have a detoasted copy, free it */
if (acl && (Pointer) acl != DatumGetPointer(aclDatum))
if (acl && acl != DatumGetPointer(aclDatum))
pfree(acl);
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);
/* if we have a detoasted copy, free it */
if (acl && (Pointer) acl != DatumGetPointer(aclDatum))
if (acl && acl != DatumGetPointer(aclDatum))
pfree(acl);
ReleaseSysCache(tuple);
@@ -3589,7 +3589,7 @@ pg_largeobject_aclmask_snapshot(Oid lobj_oid, Oid roleid,
result = aclmask(acl, roleid, ownerId, mask, how);
/* if we have a detoasted copy, free it */
if (acl && (Pointer) acl != DatumGetPointer(aclDatum))
if (acl && acl != DatumGetPointer(aclDatum))
pfree(acl);
systable_endscan(scan);
@@ -3683,7 +3683,7 @@ pg_namespace_aclmask_ext(Oid nsp_oid, Oid roleid,
result = aclmask(acl, roleid, ownerId, mask, how);
/* if we have a detoasted copy, free it */
if (acl && (Pointer) acl != DatumGetPointer(aclDatum))
if (acl && acl != DatumGetPointer(aclDatum))
pfree(acl);
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);
/* if we have a detoasted copy, free it */
if (acl && (Pointer) acl != DatumGetPointer(aclDatum))
if (acl && acl != DatumGetPointer(aclDatum))
pfree(acl);
ReleaseSysCache(tuple);
@@ -4003,7 +4003,7 @@ pg_attribute_aclcheck_all_ext(Oid table_oid, Oid roleid,
attmask = aclmask(acl, roleid, ownerId, mode, ACLMASK_ANY);
/* if we have a detoasted copy, free it */
if ((Pointer) acl != DatumGetPointer(aclDatum))
if (acl != DatumGetPointer(aclDatum))
pfree(acl);
}

View File

@@ -1544,7 +1544,7 @@ DeconstructFkConstraintRow(HeapTuple tuple, int *numfks,
if (numkeys <= 0 || numkeys > INDEX_MAX_KEYS)
elog(ERROR, "foreign key constraint cannot have %d columns", numkeys);
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 */
adatum = SysCacheGetAttrNotNull(CONSTROID, tuple,
@@ -1556,7 +1556,7 @@ DeconstructFkConstraintRow(HeapTuple tuple, int *numfks,
ARR_ELEMTYPE(arr) != INT2OID)
elog(ERROR, "confkey is not a 1-D smallint array");
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 */
if (pf_eq_oprs)
@@ -1571,7 +1571,7 @@ DeconstructFkConstraintRow(HeapTuple tuple, int *numfks,
ARR_ELEMTYPE(arr) != OIDOID)
elog(ERROR, "conpfeqop is not a 1-D Oid array");
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 */
}
@@ -1586,7 +1586,7 @@ DeconstructFkConstraintRow(HeapTuple tuple, int *numfks,
ARR_ELEMTYPE(arr) != OIDOID)
elog(ERROR, "conppeqop is not a 1-D Oid array");
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 */
}
@@ -1601,7 +1601,7 @@ DeconstructFkConstraintRow(HeapTuple tuple, int *numfks,
ARR_ELEMTYPE(arr) != OIDOID)
elog(ERROR, "conffeqop is not a 1-D Oid array");
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 */
}
@@ -1624,7 +1624,7 @@ DeconstructFkConstraintRow(HeapTuple tuple, int *numfks,
elog(ERROR, "confdelsetcols is not a 1-D smallint array");
num_delete_cols = ARR_DIMS(arr)[0];
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 */
*num_fk_del_set_cols = num_delete_cols;

View File

@@ -5687,7 +5687,7 @@ accumArrayResultArr(ArrayBuildStateArr *astate,
MemoryContextSwitchTo(oldcontext);
/* Release detoasted copy if any */
if ((Pointer) arg != DatumGetPointer(dvalue))
if (arg != DatumGetPointer(dvalue))
pfree(arg);
return astate;

View File

@@ -299,9 +299,9 @@ datum_image_eq(Datum value1, Datum value2, bool typByVal, int typLen)
len1 - VARHDRSZ) == 0);
/* Only free memory if it's a copy made here. */
if ((Pointer) arg1val != DatumGetPointer(value1))
if (arg1val != DatumGetPointer(value1))
pfree(arg1val);
if ((Pointer) arg2val != DatumGetPointer(value2))
if (arg2val != DatumGetPointer(value2))
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);
/* Only free memory if it's a copy made here. */
if ((Pointer) val != DatumGetPointer(value))
if (val != DatumGetPointer(value))
pfree(val);
}
else if (typLen == -2)

View File

@@ -1035,7 +1035,7 @@ like_fixed_prefix(Const *patt_const, bool case_insensitive, Oid collation,
pattlen = VARSIZE_ANY_EXHDR(bstr);
patt = (char *) palloc(pattlen);
memcpy(patt, VARDATA_ANY(bstr), pattlen);
Assert((Pointer) bstr == DatumGetPointer(patt_const->constvalue));
Assert(bstr == DatumGetPointer(patt_const->constvalue));
}
match = palloc(pattlen + 1);
@@ -1577,7 +1577,7 @@ make_greater_string(const Const *str_const, FmgrInfo *ltproc, Oid collation)
len = VARSIZE_ANY_EXHDR(bstr);
workstr = (char *) palloc(len);
memcpy(workstr, VARDATA_ANY(bstr), len);
Assert((Pointer) bstr == DatumGetPointer(str_const->constvalue));
Assert(bstr == DatumGetPointer(str_const->constvalue));
cmpstr = str_const->constvalue;
}
else

View File

@@ -2194,7 +2194,7 @@ numeric_abbrev_convert(Datum original_datum, SortSupport ssup)
}
/* should happen only for external/compressed toasts */
if ((Pointer) original_varatt != DatumGetPointer(original_datum))
if (original_varatt != DatumGetPointer(original_datum))
pfree(original_varatt);
return result;
@@ -2284,9 +2284,9 @@ numeric_fast_cmp(Datum x, Datum y, SortSupport ssup)
result = cmp_numerics(nx, ny);
if ((Pointer) nx != DatumGetPointer(x))
if (nx != DatumGetPointer(x))
pfree(nx);
if ((Pointer) ny != DatumGetPointer(y))
if (ny != DatumGetPointer(y))
pfree(ny);
return result;

View File

@@ -1513,9 +1513,9 @@ range_fast_cmp(Datum a, Datum b, SortSupport ssup)
cmp = range_cmp_bounds(typcache, &upper1, &upper2);
}
if ((Pointer) range_a != DatumGetPointer(a))
if (range_a != DatumGetPointer(a))
pfree(range_a);
if ((Pointer) range_b != DatumGetPointer(b))
if (range_b != DatumGetPointer(b))
pfree(range_b);
return cmp;

View File

@@ -1529,9 +1529,9 @@ record_image_cmp(FunctionCallInfo fcinfo)
if ((cmpresult == 0) && (len1 != len2))
cmpresult = (len1 < len2) ? -1 : 1;
if ((Pointer) arg1val != DatumGetPointer(values1[i1]))
if (arg1val != DatumGetPointer(values1[i1]))
pfree(arg1val);
if ((Pointer) arg2val != DatumGetPointer(values2[i2]))
if (arg2val != DatumGetPointer(values2[i2]))
pfree(arg2val);
}
else

View File

@@ -240,7 +240,7 @@ DecodeTextArrayToBitmapset(Datum array)
}
pfree(elems);
if ((Pointer) arr != DatumGetPointer(array))
if (arr != DatumGetPointer(array))
pfree(arr);
return bms;

View File

@@ -259,7 +259,7 @@ extern struct varlena *pg_detoast_datum_packed(struct varlena *datum);
*/
#define PG_FREE_IF_COPY(ptr,n) \
do { \
if ((Pointer) (ptr) != PG_GETARG_POINTER(n)) \
if ((ptr) != PG_GETARG_POINTER(n)) \
pfree(ptr); \
} while (0)