Categories:
.NET (961)
C (387)
C++ (185)
CSS (84)
DBA (8)
General (31)
HTML (48)
Java (641)
JavaScript (220)
JSP (109)
JUnit (31)
MySQL (297)
Networking (10)
Oracle (562)
Perl (48)
Perl (9)
PHP (259)
PL/SQL (140)
RSS (51)
Software QA (28)
SQL Server (5)
Struts (20)
Unix (2)
Windows (3)
XHTML (199)
XML (59)
Other Resources:
What is alloca and why is its use discouraged?
What is alloca and why is its use discouraged?
✍: Guest
alloca allocates memory which is automatically freed when the function which called alloca returns. That is, memory allocated with alloca is local to a particular function's ``stack frame'' or context.
alloca cannot be written portably, and is difficult to implement on machines without a conventional stack. Its use is problematical (and the obvious implementation on a stack-based machine fails) when its return value is passed directly to another function, as in fgets(alloca(100), 100, stdin).
For these reasons, alloca is not Standard and cannot be used in programs which must be widely portable, no matter how useful it might be. Now that C99 supports variable-length arrays (VLA's), they can be used to more cleanly accomplish most of the tasks which alloca used to be put to.
2016-03-14, 868👍, 0💬
Popular Posts:
How did you implement UML in your project ? PART II Implementation phase / Coding phase (Class diagr...
Which bit wise operator is suitable for checking whether a particular bit is on or off? The bitwise ...
How to measure functional software requirement specification (SRS) documents? Well, we need to defin...
How do we access attributes using “XmlReader”? Below snippets shows the way to access attributes. Fi...
How can I enable session tracking for JSP pages if the browser has disabled cookies? We know that se...