BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

New Rule Suggestion

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Language BASM
View previous topic :: View next topic  
Author Message
Dennis
Guest





PostPosted: Mon May 30, 2005 6:05 pm    Post subject: New Rule Suggestion Reply with quote



Hi All

I would like us to discuss a new rule.

"A function returning a string as result must allocate enough memory for
that string and not more"

I think that is a bad idead to allocate to much memory for strings and just
setting the Length variable short.

Any suggestions to improve the wording of the rule?

Any opinions before we start voting?

Best regards
Dennis


Back to top
Anders Isaksson
Guest





PostPosted: Tue May 31, 2005 6:22 am    Post subject: Re: New Rule Suggestion Reply with quote



On Mon, 30 May 2005 20:05:10 +0200, "Dennis"
<marianndkc (AT) home3 (DOT) gvdnet.dk> wrote:

Quote:
I would like us to discuss a new rule.

"A function returning a string as result must allocate enough memory for
that string and not more"

Why? What's the point of this rule? Which problem does it remove?

If an algorithm can be made faster by allocating a bit more memory than
the final Result will need, what's the problem? Thats a valid solution
to boundary problems (sentinel values instead of repeatedly checking the
index, for example).

Or will the extra memory be orphaned? If so a validation would show
memory leaks, right?

--
Anders Isaksson, Sweden
BlockCAD: http://web.telia.com/~u16122508/proglego.htm
Gallery: http://web.telia.com/~u16122508/gallery/index.htm

Back to top
Aleksandr Sharahov
Guest





PostPosted: Tue May 31, 2005 6:43 am    Post subject: Re: New Rule Suggestion Reply with quote



Hi Dennis,

Quote:
I would like us to discuss a new rule.

"A function returning a string as result must allocate enough memory
for
that string and not more"

I think that is a bad idead to allocate to much memory for strings and
just
setting the Length variable short.

Borland votes "No" (see NewAnsiString).

This function rounds size up to full word.

My new UpperCase & LowerCase functions
round size up to full dword.

Is there big differnce?
There is no difference, because all existing MMs
allocate memory by dwords.

--
regards
Aleksandr



Back to top
Aleksandr Sharahov
Guest





PostPosted: Tue May 31, 2005 6:52 am    Post subject: Re: New Rule Suggestion Reply with quote

Really the new functions increase size up
when Length mod 4 = 1, i.e. in 1/4 of all cases.

--
regards
Aleksandr


Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Language BASM All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.