PL/I

PL/I

PL/I

 View Only
  • 1.  PLIFREE fails code 1102

    Posted Mon February 05, 2018 06:46 PM

    Win7/64 using vaPLI 2.1.12

    I have the following extract of a program which allocates storage, uses it, and later wants to free it

    I use ALLOCATE  and PLIFREE but I get a code 1102 failure

    What have I misunderstood, or how do I free the storage no longer required?

    Any help appreciated

     

    A block ENVinfo is allocated and attached to a block UCOMMON which is allocated within an area USER_AREA
    UCOMMON points with Ucommon.ENVinfo_ptr to ENVinfo structure
    I can manipulate the ENVinfo block, use it fine, but free it ???????
    The PLIFREE(addr) fails code 1102

    The main part of the code is as follows

         ALLOCATE USER_AREA set(user_1area_ptr);
         put skip edit("user_area @",user_1area_ptr)(2 a);
         ALLOCATE UCOMMON   IN (user_area) SET(ucommptr);
         put skip edit("Ucommon @",ucommptr)(2 a);
         Ucommon.userid="USER1";
         ALLOCATE ENVinfo  IN (user_area) SET (Ucommon.envinfo_ptr);
         put skip edit("ENVinfo @",Ucommon.envinfo_ptr)(2 a);
         Ucommon.envinfo_ptr->ENVinfo.date_format.date_break = "/";
         Ucommon.envinfo_ptr->ENVinfo.date_format.yr_width=4;
         Ucommon.envinfo_ptr->ENVinfo.date_format.dy_spot=1;
         Ucommon.envinfo_ptr->ENVinfo.date_format.mo_spot=2;
         Ucommon.envinfo_ptr->ENVinfo.date_format.yr_spot=3;

         put skip edit("About to free ENVinfo @",Ucommon.envinfo_ptr)(2 a);
         if Ucommon.envinfo_ptr\=null then call plifree(Ucommon.envinfo_ptr);
         return;

    user_area @01F10028
    Ucommon   @01F10038
    ENVinfo   @01F107A1
    About to free ENVinfo @01F107A1
    IBM0913I  ONCODE=1102  An error occurred on a FREE statement.
       At offset +00000572 in procedure with entry SYSTEST007
         
    From the manuals
    1102 An error occurred in storage management. Storage to be freed was pointed to by an invalid address
    PLIFREE(p): Builtin subroutine frees heap storage associated with the pointer P that was allocated using the ALLOCATE builtin function

      Dcl user_1area_ptr     pointer,
          user_area          AREA(2097152) based(user_1area_ptr);   /* 2Mb   */


          7.3          18  1     |DCL UCOMMPTR      POINTER ;                                                                                                        |
          8.3          19  1     |DCL 1 UCOMMON     BASED (UCOMMPTR),                                                                                                |
          9.3                    |      2 EYE                       CHAR(8),                                                                                         |
         10.3                    |      2 USERID                    CHAR(16),                                                                                        |
         14.3                    |      2 TIB_PTR                   POINTER,                                                                                         |
         15.3                    |      2 PCB_PTR                   POINTER,                                                                                         |
         16.3                    |      2 DIINFO_PTR                POINTER,                                                                                         |
         17.3                    |      2 USER_AREA_PTR             POINTER,                                                                                         |
         18.3                    |      2 TMP_AREA_PTR              POINTER,                                                                                         |
         19.3                    |      2 SEM_AREA_PTR              POINTER,                                                                                         |
         20.3                    |      2 SYSTEM                    POINTER,                                                                                         |
         21.3                    |      2 DCOMMON_PTR               POINTER,                                                                                         |
         22.3                    |      2 MONINFO_PTR               POINTER,                                                                                         |
         23.3                    |      2 ENVINFO_PTR               POINTER,                                                                                         |
         33.3                    |      2 USERINFO_PTR              POINTER,    
                   and lots more stuff ...
                   
      2.4                    |/*******************************************/                                                                                      |
          3.4                    |/*  USER ENVIRONMENT                       */                                                                                      |
          4.4                    |/*******************************************/                                                                                      |
          5.4          25  1     |DECLARE                                                                                                                            |
          6.4                    |        1 ENVINFO                     BASED (UCOMMON.ENVINFO_PTR),                                                                 |
          7.4                    |          2 EYE                       CHAR(8),                                                                                     |
         31.4                    |          2 DATE_FORMAT,                                                                                                           |
         32.4                    |            3 MO_SPOT                 FIXED BIN(15),                                                                               |
         33.4                    |            3 DY_SPOT                 FIXED BIN(15),                                                                               |
         34.4                    |            3 YR_SPOT                 FIXED BIN(15),                                                                               |
         35.4                    |            3 YR_WIDTH                FIXED BIN(15),                                                                               |
         36.4                    |            3 DATE_BREAK              CHAR(1),                                                                                     |
         37.4                    |          2 CALENDAR_PTR              POINTER,                                                                                     |
         38.4                    |          2 U_M_PTR                   POINTER,                                                                                     |
         39.4                    |          2 REQLIB_PTR                POINTER,                                                                                     |
         40.4                    |          2 CMPLIB_PTR                POINTER,                                                                                     |
                   and lots more stuff ...

     

    john173


  • 2.  Re: PLIFREE fails code 1102

    Posted Tue February 06, 2018 08:46 AM

    I expect that since ucommptr and Ucommon.envinfo_ptr are simply POINTERs rather than OFFSET(area) variables, you need to use the FREE statement, specifiying the IN(area) operand.

    brataj


  • 3.  Re: PLIFREE fails code 1102

    Posted Tue February 06, 2018 10:43 AM

    My Windows PDF manual for 2.1.x does not even mention FREE at all

    My OS PLI version 2.3 reference summary has the command but IN (AREA) only seems to apply to based variables not controlled variables

    My your suggestion DOES work, so thank you, shame about the documentation though.

    john173