c - Is it OK to free 'void*'? -


<पूर्व> struct foo {int a; Int b; }; शून्य * p = (शून्य *) malloc (sizeof (struct foo)); ((एफू *) पी) - & gt; ए; // कुछ करना नि: शुल्क (पी); // क्या यह सुरक्षित है?

हां।

malloc रिटर्न void * < / कोड> और निशुल्क शून्य * लेता है, इसलिए आपके कुछ डाट अर्थ रहित होते हैं, और आप हमेशा शून्य * को मुक्त कर रहे हैं भले ही आप किसी अन्य प्रकार से शुरू कर रहे हों सूचक का।


Comments

Popular posts from this blog

.net - C# List<T>.Find(x=>x.Rectangle.Contains(Point)) FAIL -

iphone - Smoothing a rounded stroke in Core Graphics -

Best practice for URL redirection in ASP.NET web application -