Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

how to fail???

Name: poor noobling 2008-10-23 12:22

Alright so I've got a lot of shit that should be done at the end of this program (closing any open files, ending SDL and/or Winsocks, freeing mallocated memory, etc).

But I can't always be sure when/where this program will terminate.

How do I make my codez so that I know it will always perform the clean-up code etc whenever I want the program to end?

Name: Anonymous 2008-10-23 12:32

<?php
// Failure script v.1.0
// Copyright (c) 1992-2005 xNeaRdeAtHx
// U MUST LEAVE THIS LINE IN YOUR CODE
print("<!-- Failure script v.1.0 - BY http://cool-free-php-scripts.tk/ -->");
die("FAIL!!!");
// End of Failure script v.1.0?>

Name: Anonymous 2008-10-23 12:37

Maybe you can use atexit? You need to give some more information about what you're trying to do.

Name: Anonymous 2008-10-24 16:42

>>3
I'm trying atexit right now but I am wondering about the best way to perform clean-up shit regardless of where my program ends etc.

I think I've got it

Name: Anonymous 2008-10-24 16:51

>>4
Keep a stack of cleanup functions for every simple task, and depending on the location in your program, push or pop the stack of functions. In the atexit function, just pop each value from the stack and call the function pointer.

I created this technique.

Name: Anonymous 2008-10-24 17:14

>>5
I'd just like to reiterate that I created this EXPERT PROGRAMMING technique.

Name: Anonymous 2008-10-24 17:51

RAII

Name: Anonymous 2010-12-17 1:36

Erika once told me that Xarn is a bad boyfriend

Don't change these.
Name: Email:
Entire Thread Thread List