fix nullptr check

This commit is contained in:
Pepijn de Vos 2024-09-23 13:54:55 +02:00
parent 832275cb75
commit 31a7e22aa6
2 changed files with 5 additions and 3 deletions

View File

@ -33,6 +33,8 @@ template <typename T> struct RelPtr
const T *get() const { return reinterpret_cast<const T *>(reinterpret_cast<const char *>(this) + offset); }
bool is_null() const { return offset == 0; }
const T &operator[](std::size_t index) const { return get()[index]; }
const T &operator*() const { return *(get()); }

View File

@ -241,7 +241,7 @@ struct GowinCstReader
};
void add_sip_constraints(Context *ctx, const Extra_package_data_POD *extra) {
static void add_sip_constraints(Context *ctx, const Extra_package_data_POD *extra) {
for(auto cst : extra->cst) {
auto it = ctx->cells.find(IdString(cst.net));
if (it == ctx->cells.end()) {
@ -260,8 +260,8 @@ void add_sip_constraints(Context *ctx, const Extra_package_data_POD *extra) {
bool gowin_apply_constraints(Context *ctx, std::istream &in)
{
// implicit constraints from SiP pins
const Extra_package_data_POD *extra = reinterpret_cast<const Extra_package_data_POD *>(ctx->package_info->extra_data.get());
if(extra != nullptr) {
if(!ctx->package_info->extra_data.is_null()) {
const Extra_package_data_POD *extra = reinterpret_cast<const Extra_package_data_POD *>(ctx->package_info->extra_data.get());
add_sip_constraints(ctx, extra);
}