|
The code below is not what you said, you said "I simply CLEAR MYDSNAME
and voila!". Now if you had said loop through the array of structures
and CLEAR MYDSNAME...
Pseudo code, assuming that myDS is a datastructure based on pDS, and
pDS...
pDS = %Alloc(%Size(myDS) * NBR_OF_ENTRIES) For I = 1 to NBR_OF_ENTRIES
Clear myDS
pDS += %Size(myDS)
endfor
...you are telling me that won't work? Sheesh I'd better go back and
fix all the production programs I have using this technique!
Dennis Lovelady
http://www.linkedin.com/in/dennislovelady
--
"Don't let your opinion sway your judgement."
-- movie mogul Samuel Goldwyn
Yes, I'm basing a datastructure. I'm creating a 2D array that canto
handle more than the limit at v5r4. Pretty easy to blow through the
limit.
If I
was at 6.1 or 7.1 I wouldn't need to do this, but here I am.
I'm not sure that what you said is true Dennis. How is CLEAR going
wipe out dynamically allocated memory? I think you are slightlycc
misunderstanding what is going on.... unless CLEAR can do way more
than I thought.
Thanks
Bryce Martin
Programmer/Analyst I
570-546-4777
"Dennis Lovelady" <iseries@xxxxxxxxxxxx> Sent by:
rpg400-l-bounces@xxxxxxxxxxxx 10/28/2010 11:35 AM Please respond to
RPG programming on the IBM i / System i <rpg400-l@xxxxxxxxxxxx>
To
"'RPG programming on the IBM i / System i'" <rpg400-l@xxxxxxxxxxxx>
program.
Subject
RE: Memory being reused by %alloc on second call to program.
Not sure about anyone else, but usually when I allocate memory, it's
because I want to base a data structure on it.
So, once I have the basing pointer set, I simply CLEAR MYDSNAME and
voila!
Instant clearing, with the additional benefit that numerics are
"cleared"
to
the correct format, and alphas are blank.
Dennis Lovelady
http://www.linkedin.com/in/dennislovelady
--
"Don't knock the weather; nine tenths of the people couldn't start a
conversation if it didn't change once in a while."
-- Kin Hubbard
Bryce;return
This is just my opinion, but your logic should be redesigned to
track, in this case, the number of records/array elements populated
and
that to the caller also.
Baring that, no a rclrsc won't help, even if this was an OPM
likeRPG's %Alloc or %ReAlloc does not have a "fill with" parameter,
Cprogram.
does, so you have to initialize it yourself using the C memsetfunction.
You could also use the C alloc/realloc functions instead of the RPG
bifs.
Duane Christen
--
Duane Christen Senior Software
Engineer
(319) 790-7162
Duane.Christen@xxxxxxxxxx
Visit PAETEC.COM
-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-
bounces@xxxxxxxxxxxx] On Behalf Of Bryce Martin
Sent: Thursday, October 28, 2010 9:38 AM
To: RPG programming on the IBM i / System i
Subject: Re: Memory being reused by %alloc on second call to
cc
I was wondering if I'd need to do that. What is the
easiest/quickest way to initialize the memory? Could I do a rclrsc
upon returning to the first screen in ProgramA? The StoredProc has
*inlr=*on so I'm guessing the RCLRSC won't do anything.
Thanks
Bryce Martin
Programmer/Analyst I
570-546-4777
Charles Wilt <charles.wilt@xxxxxxxxx> Sent by:
rpg400-l-bounces@xxxxxxxxxxxx 10/28/2010 10:20 AM Please respond to
RPG programming on the IBM i / System i <rpg400-l@xxxxxxxxxxxx>
To
"RPG programming on the IBM i / System i" <rpg400-l@xxxxxxxxxxxx>
viewing.dynamic
Subject
Re: Memory being reused by %alloc on second call to program.
Working as designed...
In any language, you should always initialize newly allocated
memory; if you code depends on it.
Charles
On Thu, Oct 28, 2010 at 9:36 AM, Bryce Martin <BMartin@xxxxxxxxxxxx>
wrote:
I have written my first external stored procedure and it uses
thatmemory allocation to create a couple of 2D arrays. The problem
I'mI
seeing is this...%alloc/%realloc/%dealloc
ProgramA using CLI calls StoredProc. StoredProc
and uses a regular static array for returning a result set.
ProgramA is two screens. First screen has fields to search by.
If
enter criteria and hit enter ProgramA then calls StoredProc.ProgramA
then processes the ResultSet and puts it into a subfile for
toIfI
I
F12 back to the first screen and change my search criteria tosomething
that shouldn't return results it still does but refined by
whatever
justthe
searched by. If I F3 out of ProgramA then all the memory used by
returnsStoredProc is released even if I don't do a RCLACTGRP ofexit
ProgramA's activation group. If I search a second time after
doing the full
by
the criteria that should not return results then it works and
no
results. (no results could also be a search that is too generic
anything.have
good results, this is handled by the StoredProc).address
In the StoredProc I am doing the following Destroy call, the
DestroyArray() procedure just take a pointer to an array memory
and does a dealloc(n) pWholeArray;
pArrayElem = *null;
DestroyArray(pWholeArray);
pWholeArray = *null;
I nulled the pointers for good measure but that didn't do
anythe
It looks like the second call is doing an %alloc and starting at
samedo
memory address as the previous call had done. So when I %alloc ablock
the memory already contains the data from the previous call. How
Ithe
handle this?
Thanks
Bryce Martin
Programmer/Analyst I
570-546-4777
--- This message (including any attachments) is intended only for
use of the individual or entity to which it is addressed and may
contain information that is non-public, proprietary, privileged,
confidential, and exempt from disclosure under applicable law. If
you are not the intended recipient, you are hereby notified that
mayuse, dissemination, distribution, or copying of this communicationmailing
is strictly prohibited.
If
you have received this communication in error, please notify us and
destroy this message immediately. ---
--mailing
This is the RPG programming on the IBM i / System i (RPG400-L)
list
To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe,--
unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx Before posting, please
take a moment to review the archives at
http://archive.midrange.com/rpg400-l.
This is the RPG programming on the IBM i / System i (RPG400-L)
list
To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx Before posting, please take
a moment to review the archives at
http://archive.midrange.com/rpg400-l.
--- This message (including any attachments) is intended only for
the use of the individual or entity to which it is addressed and
anycontain information that is non-public, proprietary, privileged,
confidential, and exempt from disclosure under applicable law. If
you are not the intended recipient, you are hereby notified that
mailinguse, dissemination, distribution, or copying of this communicationmailing
is strictly prohibited. If you have received this communication in
error, please notify us and destroy this message immediately. ---
--
This is the RPG programming on the IBM i / System i (RPG400-L)
listmailing
To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx Before posting, please take
a moment to review the archives at
http://archive.midrange.com/rpg400-l.
--
This is the RPG programming on the IBM i / System i (RPG400-L)
list
To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx Before posting, please take
a moment to review the archives at
http://archive.midrange.com/rpg400-l.
--
This is the RPG programming on the IBM i / System i (RPG400-L)
list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe,mailing
unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx Before posting, please take a
moment to review the archives at http://archive.midrange.com/rpg400-l.
--- This message (including any attachments) is intended only for the
use of the individual or entity to which it is addressed and may
contain information that is non-public, proprietary, privileged,
confidential, and exempt from disclosure under applicable law. If you
are not the intended recipient, you are hereby notified that any use,
dissemination, distribution, or copying of this communication is
strictly prohibited. If you have received this communication in error,
please notify us and destroy this message immediately. ---
--
This is the RPG programming on the IBM i / System i (RPG400-L)
list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx Before posting, please take a
moment to review the archives at http://archive.midrange.com/rpg400-l.
--
This is the RPG programming on the IBM i / System i (RPG400-L) mailing
list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
http://archive.midrange.com/rpg400-l.
--
This is the RPG programming on the IBM i / System i (RPG400-L) mailing
list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.
As an Amazon Associate we earn from qualifying purchases.
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.