IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Opened 22 years ago

Closed 22 years ago

Last modified 22 years ago

#33 closed defect (fixed)

additional members added to psMemBlock

Reported by: robert.desonia@… Owned by: eugene
Priority: high Milestone:
Component: PSLib SDRS Version: unspecified
Severity: normal Keywords:
Cc:

Description

Expanded the definition of psMemBlock (PsLib SDRS section 2.1.3 in 4/1/2004
version) to be:

/ typedef for memory identification numbers. Guaranteed to be some variety of
integer.
typedef unsigned long psMemoryId;

/ typedef for a memory block's reference count. Guaranteed to be some variety
of integer.
typedef unsigned long psReferenceCount;

typedef struct psMemBlock
{

const void* startblock; /< initialised to p_psMEMMAGIC
struct psMemBlock* previousBlock;
/< previous block in allocation list
struct psMemBlock* nextBlock; /< next block allocation list
size_t userMemorySize;
/< the size of the user-portion of the

memory block

const psMemoryId id; /< a unique ID for this allocation
const char* file;
/< set from FILE in e.g. p_psAlloc
const int lineno; /< set from LINE in e.g. p_psAlloc
psReferenceCount refCounter;
/< how many times pointer is

referenced

const void* endblock; /< initialised to p_psMEMMAGIC

} psMemBlock;

The previousBlock and nextBlock is used to make a double-linked list out of the
memory blocks as to keep track of all the memory while allowing very efficient
alloc/free functionality.

The userMemorySize is used to calculate the end of the user area so that a
marker can be put there as to detect buffer overflows (i.e., writing beyond the
user space) as well as underflows (via endblock).

Change History (1)

comment:1 by eugene, 22 years ago

Resolution: fixed
Status: newclosed

these changes look fine. it is nice to have the link to the previous and next
entries. the choice of representing the end of the memory block by the size
rather than the pointer makes it easier to perform reallocations - just make
sure the endpost PS_MEM_MAGIC value is set (it is not obvious from the comments).

Note: See TracTickets for help on using tickets.