Opened 20 years ago
Closed 17 years ago
#690 closed defect (fixed)
Add prefixIsType() API for all types
| Reported by: | 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 , 20 years ago
| Cc: | added |
|---|---|
| Owner: | changed from to |
comment:2 by , 20 years ago
This mechanism is
- Uniform
- 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 , 20 years ago
| Status: | new → assigned |
|---|
Sorry, does that mean you're in favour of the current system, or advocating
something different?
comment:4 by , 17 years ago
| Resolution: | → fixed |
|---|---|
| Status: | assigned → closed |
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.

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