Unconfigured Ad Widget

Collapse

Announcement

Collapse
No announcement yet.

Best of Cozzi: Dynamic Memory and Dynamic Arrays

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • buffcessna
    replied
    Best of Cozzi: Dynamic Memory and Dynamic Arrays

    ** This thread discusses the article: Best of Cozzi: Dynamic Memory and Dynamic Arrays **
    Hey all, I'm getting an error when I try to call memset within my program. Here's my code: dprptarrays*inz drptarrays261adim(9999)based(prptarray) dnelemss5i0 dnoldsizes10i0 dnmemsizes10i0 dntotelemss5i0 ... dmemsetprextproc('memset') dpdata*value dcchartoset1avalue dnbytecount10i0value ... /free clearprptarray; ... nelems=100;//this works fine the first time thorough ntotelems = nelems; nmemsize = nelems * %size(rptarray); prptarray = %alloc(nmemsize); callp memset(prptarray:x'40':nmemsize); noldsize = nmemsize; ... nelems = 100;//this is where it bombs out... ntotelems += nelems; nmemsize = nelems * %size(rptarray); prptarray = %realloc(prptarray:nmemsize); callp memset(prptarray + noldsize:x'40':nmemsize); noldsize = nmemsize; /end-free Any time I call memset after a %realloc, it comes up with this error: Message ID......: RNQ0202 Date sent ......: 08/11/04Time sent ......: 11:12:55 Message ....: The call to memset ended in error (C G D F). Cause .....: RPG procedure CPRPOCRPT in program ASCLIB/CPRPOCRPT at statement 048400 called program or procedure memset, which ended in error. If the name is *N, the call was a bound call by procedure pointer. Recovery ...: Check the job log for more information on the cause of the error and contact the person responsible for program maintenance. Possible choices for replying to message ...............: D -- Obtain RPG formatted dump. S -- Obtain system dump. G -- Continue processing at *GETIN. C -- Cancel. F -- Obtain full formatted dump. Any help will be greatly appreciated...Thanx. Shane

    Leave a comment:


  • Guest's Avatar
    Guest replied
    Best of Cozzi: Dynamic Memory and Dynamic Arrays

    ** This thread discusses the article: Best of Cozzi: Dynamic Memory and Dynamic Arrays **
    I know Bob knows this but it should be stated for others. Once you dynamically allocate memory for an array, you have to be hyper-aware of the actual number of allocated elements in the array in your programming. Simply doing a lookup could be problematic if you go beyond the actual number of allocated elements. This is why some array opcodes allow an optional parameter to indicate the number of elements to process. %LOOKUP(arg : array {: startindex {: numelems}}) Chris

    Leave a comment:


  • Best of Cozzi: Dynamic Memory and Dynamic Arrays

    ** This thread discusses the article: Best of Cozzi: Dynamic Memory and Dynamic Arrays **
    ** This thread discusses the Content article: Best of Cozzi: Dynamic Memory and Dynamic Arrays **
    0
Working...
X