#55 closed defect (fixed)
Memory management allocation design
| Reported by: | Owned by: | eugene | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | PSLib SDRS | Version: | unspecified |
| Severity: | normal | Keywords: | |
| Cc: |
Description
In PSLib SRS paragraph 3.2.1.5, constructors shall never return NULL and
functions which call constructors do not need to check the return value. What
would be the proper action if for example psVectorAlloc is passed an invalid
argument for size or element type? If the constructor doesn't understand what
is to be constructed based on a user input, what should it do and how does it
convey this information back to the user?
Change History (2)
comment:1 by , 22 years ago
| Status: | new → assigned |
|---|
comment:2 by , 22 years ago
| Resolution: | → fixed |
|---|---|
| Status: | assigned → closed |
we've decided that the Alloc functions will call psAbort on an error. this
means it is the responsibility of the calling functions to validate the input
parameters if they want to recover from an error (or trap sig abort - not the
advised method).
This means we should look for places where boilerplate range checking code can
be replaced with range-checking functions associated with specific variable types.

this is definitely an issue I'd like to discuss in our next tuesday meeting
(this morning). Our current design philosophy seems rather restricted, and it
is probably not so much of a burden to type:
if ((V = psAlloc(N)) == NULL) {
}
(if we allowed if's without {} and in-line statements, it could be:
if ((V = psAlloc(N)) == NULL) { psAbort ("failed to get it"); }
it seems to be more necessary with richer alloc/free functions