× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



(PDQ = Possibly Dumb Question)

Ok, maybe I'm doing something completely wrong here ... but I'm not seeing it.

I'm trying to dynamically allocate space for a work buffer in a procedure.

Here is a fragment of the code that's encountering the error ...

PwordwrapText B
D PI
D input 32767 value
D linelength 5 0 value
D lineCount 5 0 value
D output 32767

D workBuffer S 32767 based(workBufferP)
D workBufferP S *

/free
inputLength = %len(%trim(input));
workBufferP = %alloc(inputLength + lineLength);
workBuffer = %trim(input);

When I assign workBuffer to the trimmed value of input, I'm getting a MCH0601 (Space offset X'00008FFE' or X'0000000000000000' is outside current limit for object DGIBBSC1 DEVDMG 773502.) The space class is x'04'.

This is for a word wrapping routine ... the reason I allocate the input Length + the line length is because I might end up processing off the end of the input.

In this particular case, inputLength is 89 and lineLength is 50.

I also tried assigning the workBuffer to %subst(input:1:inputLength), but got the same error.

I don't claim to be an expert in pointers ... but I thought that assigning a value to a based variable will simply copy the contents into the previously allocated space.

Any idea why I'm getting the MCH0601 error?

Thanks!

david


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.