IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Opened 20 years ago

Closed 17 years ago

#690 closed defect (fixed)

Add prefixIsType() API for all types

Reported by: rhl@… Owned by: Paul Price
Priority: high Milestone:
Component: IPP SDRS Version: unspecified
Severity: normal Keywords:
Cc:

Description

The PS memory system knows the type of any pointer via the freeFunction in its psMemBlock,
but this information isn't available to the user as the freeFunctions are declare static in the
files that create the type.

I propose that for all types prefixFoo, we add a function

bool prefixIsFoo(void *ptr);

that returns true iff ptr is non-NULL and ptr's freeFunction is prefixFoo's free function. E.g.

static void peakFree(pmPeak *tmp) {}

pmPeak *pmPeakAlloc(...)
{
...

psMemSetDeallocator(tmp, (psFreeFunc) peakFree);

return(tmp);

}

bool pmIsPeak(const psPtr ptr)
{

return psMemGetDeallocator(ptr) == (psFreeFunc)peakFree;

}

Change History (4)

comment:1 by Paul Price, 20 years ago

Cc: eugene@… added
Owner: changed from eugene to Paul Price

Some of this functionality is already provided in psLib (see 2.3.13 of the
SDRS), but not in the modules.

comment:2 by rhl@…, 20 years ago

This mechanism is

  1. Uniform
  2. Extendable to e.g. modules, psAstro

An alternative is to register the free functions with a typename, and then have an
API that returns the typename:

psRegisterType(fooFree, "FOO");

assert (strcmp(psGetType(ptr), "FOO") == 0);

comment:3 by Paul Price, 20 years ago

Status: newassigned

Sorry, does that mean you're in favour of the current system, or advocating
something different?

comment:4 by eugene, 17 years ago

Resolution: fixed
Status: assignedclosed

the functionality described by RHL is identical to the functions of the form psMemCheckFoo implemented in psLib; something equivalent (with inconsistent names) is also provided for many of the types supplied by psModules. There is no automated or enforced coding of the standard, but that is not really needed.

Note: See TracTickets for help on using tickets.