HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- form() usage in USL.
Operating System - HP-UX
1832925
Members
3011
Online
110048
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2004 05:53 PM
05-28-2004 05:53 PM
form() usage in USL.
In our code, in quite a lot of places, USL's form() is used for formatting strings.
Since new aCC compilers ( -AA option ) doesn't support USL,
we had to write our own implementation for form().
Form's declartion is:
char * form(const char *,...);
and is same as used by USL.
With USL's form, there never used to be any memory leaks,
when used like
fp = fopen ( form ( "%s", fileName ) )
i.e the "char *" returned was never freed.
But still there were no memory leaks.
With our implementation, the same gives memory leaks.
What was the implementation of form() in USL, or is there any way in which we can avoid the memory leak( in the our implementation, memory is allocated in the heap, in form(), which needs to released once form() is called)
Since new aCC compilers ( -AA option ) doesn't support USL,
we had to write our own implementation for form().
Form's declartion is:
char * form(const char *,...);
and is same as used by USL.
With USL's form, there never used to be any memory leaks,
when used like
fp = fopen ( form ( "%s", fileName ) )
i.e the "char *" returned was never freed.
But still there were no memory leaks.
With our implementation, the same gives memory leaks.
What was the implementation of form() in USL, or is there any way in which we can avoid the memory leak( in the our implementation, memory is allocated in the heap, in form(), which needs to released once form() is called)
1 REPLY 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2007 01:11 AM
08-26-2007 01:11 AM
Re: form() usage in USL.
You do know that form() was already obsolete on the last version of cfront? I mentioned that in your other thread:
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=144703
Ah, I had to do the same port recently in part of the IPF linker tools. Except the correct solution is to use sprintf(3) or snprintf(3).
>What was the implementation of form() in USL
It used a fixed size buffer that was used over and over. I believe it used a "clock" algorithm so that the buffer wasn't reused right away. That's why sprintf(3) was good enough.
>or is there any way in which we can avoid the memory leak (memory is allocated in the heap, in form(), which needs to released once form() is called)
Either you remember it like form(), or you require each caller to free the memory. Or force the caller to use ANSI C Standard stdio calls like sprintf(3).
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=144703
Ah, I had to do the same port recently in part of the IPF linker tools. Except the correct solution is to use sprintf(3) or snprintf(3).
>What was the implementation of form() in USL
It used a fixed size buffer that was used over and over. I believe it used a "clock" algorithm so that the buffer wasn't reused right away. That's why sprintf(3) was good enough.
>or is there any way in which we can avoid the memory leak (memory is allocated in the heap, in form(), which needs to released once form() is called)
Either you remember it like form(), or you require each caller to free the memory. Or force the caller to use ANSI C Standard stdio calls like sprintf(3).
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP