changed troublesome NIL definition to NULL_POINTER. may need to refine further to get rid of annoying complaints about NULL_POINTER not being a static.
also added a merge sort and the start of quick sort and heap sort. defined partial heap class, to be moved elsewhere.
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
- <provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="358582486178666415" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
+ <provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="1107908306848771457" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
menu_item *menu_base::get_item(int index)
{
- bounds_return(index, 0, _items->elements(), NIL);
+ bounds_return(index, 0, _items->elements(), NULL_POINTER);
return dynamic_cast<menu_item *>(_items->borrow(index));
}
menu_base *menu_base::get_submenu(int index)
{
- bounds_return(index, 0, _menus->elements(), NIL);
+ bounds_return(index, 0, _menus->elements(), NULL_POINTER);
return dynamic_cast<menu_base *>(_menus->borrow(index));
}
{
//hmmm: implement this too....
if (!trigger){}
-return NIL;
+return NULL_POINTER;
}
void menu_base::activate()
menu_common_base *evaluate_trigger(char trigger);
//!< returns the item or menu associated with the "trigger" value.
- /*!< use of dynamic cast enables one to tell what has been returned. NIL
+ /*!< use of dynamic cast enables one to tell what has been returned. NULL_POINTER
is returned if there is nothing that answers to that trigger value.
note that this does not invoke any activation functions. */
void add_item(menu_item *to_invoke);
//!< adds a new menu_item onto this menu.
menu_item *get_item(int index);
- //!< gets the item at position "index". NIL is returned if out of range.
+ //!< gets the item at position "index". NULL_POINTER is returned if out of range.
bool zap_item(int index);
//!< removes the item at "index" if possible.
bool enable_item(int index, bool enable = true);
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider copy-of="extension" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"/>
- <provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="358582486178666415" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
+ <provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="1107908306848771457" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
eclipse.preferences.version=1
org.eclipse.cdt.codan.checkers.errnoreturn=Warning
-org.eclipse.cdt.codan.checkers.errnoreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},implicit\=>false}
+org.eclipse.cdt.codan.checkers.errnoreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"No return\\")",implicit\=>false}
org.eclipse.cdt.codan.checkers.errreturnvalue=Error
-org.eclipse.cdt.codan.checkers.errreturnvalue.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
+org.eclipse.cdt.codan.checkers.errreturnvalue.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Unused return value\\")"}
+org.eclipse.cdt.codan.checkers.nocommentinside=-Error
+org.eclipse.cdt.codan.checkers.nocommentinside.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Nesting comments\\")"}
+org.eclipse.cdt.codan.checkers.nolinecomment=-Error
+org.eclipse.cdt.codan.checkers.nolinecomment.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Line comments\\")"}
org.eclipse.cdt.codan.checkers.noreturn=Error
-org.eclipse.cdt.codan.checkers.noreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},implicit\=>false}
+org.eclipse.cdt.codan.checkers.noreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"No return value\\")",implicit\=>false}
org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation=Error
-org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
+org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Abstract class cannot be instantiated\\")"}
org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem=Error
-org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
+org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Ambiguous problem\\")"}
org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem=Warning
-org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
+org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Assignment in condition\\")"}
org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem=Error
-org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
+org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Assignment to itself\\")"}
org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem=Warning
-org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},no_break_comment\=>"no break",last_case_param\=>true,empty_case_param\=>false}
+org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"No break at end of case\\")",no_break_comment\=>"no break",last_case_param\=>false,empty_case_param\=>false}
org.eclipse.cdt.codan.internal.checkers.CatchByReference=Warning
-org.eclipse.cdt.codan.internal.checkers.CatchByReference.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},unknown\=>false,exceptions\=>()}
+org.eclipse.cdt.codan.internal.checkers.CatchByReference.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Catching by reference is recommended\\")",unknown\=>false,exceptions\=>()}
org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem=Error
-org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
+org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Circular inheritance\\")"}
org.eclipse.cdt.codan.internal.checkers.ClassMembersInitialization=Warning
-org.eclipse.cdt.codan.internal.checkers.ClassMembersInitialization.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},skip\=>true}
+org.eclipse.cdt.codan.internal.checkers.ClassMembersInitialization.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Class members should be properly initialized\\")",skip\=>true}
org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem=Error
-org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
+org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Field cannot be resolved\\")"}
org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem=Error
-org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
+org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Function cannot be resolved\\")"}
org.eclipse.cdt.codan.internal.checkers.InvalidArguments=Error
-org.eclipse.cdt.codan.internal.checkers.InvalidArguments.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
+org.eclipse.cdt.codan.internal.checkers.InvalidArguments.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid arguments\\")"}
org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem=Error
-org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
+org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid template argument\\")"}
org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem=Error
-org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
+org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Label statement not found\\")"}
org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem=Error
-org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
+org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Member declaration not found\\")"}
org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem=Error
-org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
+org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Method cannot be resolved\\")"}
org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker=-Info
-org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},pattern\=>"^[a-z]",macro\=>true,exceptions\=>()}
+org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Name convention for function\\")",pattern\=>"^[a-z]",macro\=>true,exceptions\=>()}
org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem=Warning
-org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
+org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Class has a virtual method and non-virtual destructor\\")"}
org.eclipse.cdt.codan.internal.checkers.OverloadProblem=Error
-org.eclipse.cdt.codan.internal.checkers.OverloadProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
+org.eclipse.cdt.codan.internal.checkers.OverloadProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid overload\\")"}
org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem=Error
-org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
+org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid redeclaration\\")"}
org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem=Error
-org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
+org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid redefinition\\")"}
org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem=-Warning
-org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
+org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Return with parenthesis\\")"}
org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem=-Warning
-org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
+org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Format String Vulnerability\\")"}
org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem=Warning
-org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true,exceptions\=>()}
+org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Statement has no effect\\")",macro\=>true,exceptions\=>()}
org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem=Warning
-org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},paramNot\=>false}
+org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Suggested parenthesis around expression\\")",paramNot\=>false}
org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem=Warning
-org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},else\=>false,afterelse\=>false}
+org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Suspicious semicolon\\")",else\=>false,afterelse\=>false}
org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem=Error
-org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
+org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Type cannot be resolved\\")"}
org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem=Warning
-org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true}
+org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Unused function declaration\\")",macro\=>true}
org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem=Warning
-org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true}
+org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Unused static function\\")",macro\=>true}
org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem=Warning
-org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true,exceptions\=>("@(\#)","$Id")}
+org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Unused variable declaration in file scope\\")",macro\=>true,exceptions\=>("@(\#)","$Id")}
org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem=Error
-org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
+org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Symbol is not resolved\\")"}
+org.eclipse.cdt.qt.core.qtproblem=Warning
+org.eclipse.cdt.qt.core.qtproblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_ON_FILE_OPEN\=>true,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>null}
}
LOG(astring("category name \"") + category_name
+ "\" in conflict with existing: " + catnames);
- inner_mark_tree *fake_it = NIL;
+ inner_mark_tree *fake_it = NULL_POINTER;
//hmmm: neither of these are right; they need to use a comparator that
// uses our magic comparison function.
LOG("==> failure to find a match for either category!");
deadly_error(class_name(), func, "collision resolution code failed; "
"please fix category error");
- return NIL;
+ return NULL_POINTER;
}
// now that we know these names are unique, we'll add them into the list
// so future categories can't reuse these.
// traverse the tree in prefix order.
tree::iterator itty = _categories.access_root().start(tree::prefix);
- tree *curr = NIL;
+ tree *curr = NULL_POINTER;
while ( (curr = itty.next()) ) {
inner_mark_tree *nod = (inner_mark_tree *)curr;
// print out the category on this node.
#include "bookmark_tree.h"
-#include <algorithms/shell_sort.h>
#include <application/hoople_main.h>
#include <application/command_line.h>
#include <basis/astring.h>
#include <curl/curl.h>
#include <signal.h>
#include <stdlib.h>
+#include "../../library/algorithms/sorts.h"
using namespace algorithms;
using namespace application;
FUNCDEF("test_all_links");
// traverse the tree in prefix order.
tree::iterator itty = _categories.access_root().start(tree::prefix);
- tree *curr = NIL;
+ tree *curr = NULL_POINTER;
while ( (curr = itty.next()) ) {
inner_mark_tree *nod = dynamic_cast<inner_mark_tree *>(curr);
if (!nod)
checking_thread *new_thread = new checking_thread(*lin, _bad_lines,
*this);
- unique_int id = _checkers.add_thread(new_thread, true, NIL);
+ unique_int id = _checkers.add_thread(new_thread, true, NULL_POINTER);
}
}
badness_file.close();
}
-marks_checker *main_program = NIL;
+marks_checker *main_program = NULL_POINTER;
void marks_checker::handle_OS_signal(int formal(sig_id))
{
BASE_LOG("caught break signal... now writing files.");
if (main_program) main_program->write_new_files();
BASE_LOG("exiting after handling break.");
- main_program = NIL;
+ main_program = NULL_POINTER;
exit(0);
}
ret = test_all_links();
write_new_files();
- main_program = NIL;
+ main_program = NULL_POINTER;
curl_global_cleanup(); // shut down cURL engine again.
// traverse the tree in prefix order.
tree::iterator itty = _categories.access_root().start(tree::prefix);
- tree *curr = NIL; // the current node.
+ tree *curr = NULL_POINTER; // the current node.
while ( (curr = itty.next()) ) {
inner_mark_tree *nod = (inner_mark_tree *)curr;
bundle_creator()
: application_shell(),
_app_name(filename(_global_argv[0]).basename()),
- _bundle(NIL), _stub_size(0), _keyword() {}
+ _bundle(NULL_POINTER), _stub_size(0), _keyword() {}
virtual ~bundle_creator() {
WHACK(_bundle);
}
}
- byte_filer *targo = NIL;
+ byte_filer *targo = NULL_POINTER;
if (keyword_good) targo = new byte_filer(curr._payload, "wb");
byte_array uncompressed(256 * KILOBYTE); // fluff it out to begin with.
byte_array temp(256 * KILOBYTE);
+++ /dev/null
-#ifndef SHELL_SORT_CLASS
-#define SHELL_SORT_CLASS
-
-//////////////
-// Name : shell_sort
-// Author : Chris Koeritz
-//////////////
-// Copyright (c) 1991-$now By Author. This program is free software; you can
-// redistribute it and/or modify it under the terms of the GNU General Public
-// License as published by the Free Software Foundation:
-// http://www.gnu.org/licenses/gpl.html
-// or under the terms of the GNU Library license:
-// http://www.gnu.org/licenses/lgpl.html
-// at your preference. Those licenses describe your legal rights to this
-// software, and no other rights or warranties apply.
-// Please send updates for this code to: fred@gruntose.com -- Thanks, fred.
-//////////////
-
-namespace algorithms {
-
-//! Orders an array in O(n log n) time.
-/*!
- This algorithm is based on Kernighan and Ritchie's "The C Programming Language".
-*/
-
-template <class type>
-void shell_sort(type v[], int n, bool reverse = false)
- //!< this function sorts a C array of the "type" with "n" elements.
- /*!< the "type" of object must support comparison operators. if "reverse"
- is true, then the list is sorted highest to lowest. */
-{
- type temp;
- int gap, i, j;
- // the gap sizes decrease quadratically(?). they partition the array of
- // items that need to be sorted into first two groups, then four, then
- // eight, ....
- // within each gap's worth of the array, the next loop takes effect...
- for (gap = n / 2; gap > 0; gap /= 2) {
- // the i indexed loop is the base for where the comparisons are made in
- // the j indexed loop. it makes sure that each item past the edge of
- // the gap sized partition gets considered.
- for (i = gap; i < n; i++) {
- // the j indexed loop looks at the values in our current gap and ensures
- // that they are in sorted order.
- if (!reverse) {
- // normal ordering.
- for (j = i - gap; j >= 0 && v[j] > v[j + gap]; j = j - gap) {
- // swap the elements that are disordered.
- temp = v[j]; v[j] = v[j + gap]; v[j + gap] = temp;
- }
- } else {
- // reversed ordering.
- for (j = i - gap; j >= 0 && v[j] < v[j + gap]; j = j - gap) {
- // swap the elements that are disordered.
- temp = v[j]; v[j] = v[j + gap]; v[j + gap] = temp;
- }
- }
- }
- }
-}
-
-} // namespace.
-
-#endif // outer guard.
-
--- /dev/null
+#ifndef ASSORTED_SORTS_GROUP
+#define ASSORTED_SORTS_GROUP
+
+//////////////
+// Name : shell_sort
+// Author : Chris Koeritz
+//////////////
+// Copyright (c) 1991-$now By Author. This program is free software; you can
+// redistribute it and/or modify it under the terms of the GNU General Public
+// License as published by the Free Software Foundation:
+// http://www.gnu.org/licenses/gpl.html
+// or under the terms of the GNU Library license:
+// http://www.gnu.org/licenses/lgpl.html
+// at your preference. Those licenses describe your legal rights to this
+// software, and no other rights or warranties apply.
+// Please send updates for this code to: fred@gruntose.com -- Thanks, fred.
+//////////////
+
+namespace algorithms {
+
+/*
+ * general considerations:
+ *
+ * + Generic objects to be sorted must support comparison operators.
+ *
+ * + If the "reverse" flag is true, the arrays will be sorted in reverse order.
+ * Reverse order here means "descending", such that array element i is always greater than or equal to array element i+1.
+ * Normal order is "ascending", such that element i is always less than or equal to array element i+1.
+ *
+ */
+
+//! shell sort algorithm.
+/*!
+ * Sorts a C array of the "type" with "n" elements.
+ * Operates on the original array.
+ * Performs in O(n log(n)) time.
+ * Algorithm is based on Kernighan and Ritchie's "The C Programming Language".
+*/
+template <class type>
+void shell_sort(type v[], int n, bool reverse = false)
+{
+ type temp;
+ int gap, i, j;
+ /* the gap sizes decrease quadratically(?). they partition the array of
+ * items that need to be sorted into first two groups, then four, then
+ * eight, etc. the inner loop iterates across each gap's worth of the array.
+ */
+ for (gap = n / 2; gap > 0; gap /= 2) {
+ // the i indexed loop is the base for where the comparisons are made in
+ // the j indexed loop. it makes sure that each item past the edge of
+ // the gap sized partition gets considered.
+ for (i = gap; i < n; i++) {
+ // the j indexed loop looks at the values in our current gap and ensures
+ // that they are in sorted order.
+ if (!reverse) {
+ // normal ordering.
+ for (j = i - gap; j >= 0 && v[j] > v[j + gap]; j = j - gap) {
+ // swap the elements that are disordered.
+ temp = v[j]; v[j] = v[j + gap]; v[j + gap] = temp;
+ }
+ } else {
+ // reversed ordering.
+ for (j = i - gap; j >= 0 && v[j] < v[j + gap]; j = j - gap) {
+ // swap the elements that are disordered.
+ temp = v[j]; v[j] = v[j + gap]; v[j + gap] = temp;
+ }
+ }
+ }
+ }
+}
+
+//////////////
+
+/*!
+ * sorted array merge
+ *
+ * merges two sorted arrays into a single sorted array.
+ */
+template <class type>
+basis::array<type> merge(const basis::array<type> &first, basis::array<type> &second, bool reverse)
+{
+ int first_iter = 0;
+ int second_iter = 0;
+ //hmmm: careful below; remember differences in heap allocated objects versus new-ed ones.
+ //this might be really inefficient to return on stack..?
+ basis::array<type> to_return;
+ // operate until we've consumed both of the arrays.
+ while ((first_iter < first.length()) && (second_iter < second.length())) {
+ if ( (!reverse && (first[first_iter] <= second[second_iter]))
+ || (reverse && (first[first_iter] >= second[second_iter])) ) {
+ // next item from first array goes into the merged array next.
+ to_return += first[first_iter++];
+ } else {
+ // next item from second array goes into the merged array next.
+ to_return += second[second_iter++];
+ }
+ }
+ return to_return;
+}
+
+/*!
+ * merge sort
+ *
+ * operates in O(n log(n)) time.
+ * returns a new array with sorted data.
+ */
+template <class type>
+basis::array<type> merge_sort(const basis::array<type> &v, bool reverse = false)
+{
+ if (v.length() <= 1) {
+ return new basis::array<type>(v);
+ }
+ int midway = v.length() / 2;
+ basis::array<type> firstPart = merge_sort(v.subarray(0, midway - 1));
+ basis::array<type> secondPart = merge_sort(v.subarray(midway, v.length() - 1));
+ return merge(firstPart, secondPart, reverse);
+}
+
+//////////////
+
+/*
+ * a heap is a structure that can quickly return the highest (or lowest) value,
+ * depending on how the priority of the item is defined. restructuring is
+ * also fast, when new data are added. the implicit structure is a binary tree
+ * represented in a flat array, where the children of a node at position n are
+ * in positions n * 2 + 1 and n * 2 + 2 (zero based).
+ */
+//hmmm: move this class out to basis?.
+template <class type>
+class heap
+{
+public:
+ heap(int max_elements, bool reverse) {
+ _max_elements = max_elements;
+ _reverse = reverse;
+ _heapspace = new basis::array<type> (_max_elements);
+ }
+
+ virtual ~heap() {
+ WHACK(_heapspace);
+ }
+
+ //! swaps the values in the heap stored at positions a and b.
+ void swap(int a, int b)
+ {
+ type temp = _heapspace[a];
+ _heapspace[a] = _heapspace[b];
+ _heapspace[b] = temp;
+ }
+
+ //! re-sorts the heapspace to maintain the heap ordering.
+ void heapify()
+ {
+
+ }
+
+ void add(type to_add) {
+ //
+ }
+
+
+private:
+ int _max_elements;
+ bool _reverse;
+ basis::array<type> *_heapspace = NULL_POINTER;
+};
+
+/*!
+ * heap sort
+ *
+ * operates in O(n log(n)).
+ * sorts the original array.
+ */
+template <class type>
+void heap_sort(type v[], int n, bool reverse = false)
+{
+ // use heap. do sorty.
+}
+
+//////////////
+
+template <class type>
+void partition(type v[], int start, int end)
+{
+
+}
+
+//! the recursive version of quick sort that does the work for our convenience method.
+template <class type>
+void inner_quick_sort(type v[], int n, int start, int end, bool reverse = false)
+{
+ if (start >= end) {
+ // nothing to see here.
+ } else {
+ // figure out where to pivot, and sort both halves around the pivot index.
+ int pivot = partition(v, start, end);
+ quicksort(v, start, pivot - 1);
+ quicksort(v, pivot + 1, end);
+ }
+}
+
+/*!
+ * quick sort
+ *
+ * operates in O(n log(n)) time on average, worst case O(n^2).
+ * sorts the original array.
+ */
+template <class type>
+void quick_sort(type v[], int n, bool reverse = false)
+{
+ inner_quick_sort(v, n, 0, n-1, reverse);
+}
+
+} // namespace.
+
+#endif // outer guard.
+
frame_tracking_instance::frame_tracking_instance(const char *class_name,
const char *func, const char *file, int line, bool add_frame)
: _frame_involved(add_frame),
- _class(class_name? strdup(class_name) : NIL),
- _func(func? strdup(func) : NIL),
- _file(file? strdup(file) : NIL),
+ _class(class_name? strdup(class_name) : NULL_POINTER),
+ _func(func? strdup(func) : NULL_POINTER),
+ _file(file? strdup(file) : NULL_POINTER),
_line(line)
{
if (_frame_involved) {
frame_tracking_instance::frame_tracking_instance
(const frame_tracking_instance &to_copy)
: _frame_involved(false), // copies don't get a right to this.
- _class(to_copy._class? strdup(to_copy._class) : NIL),
- _func(to_copy._func? strdup(to_copy._func) : NIL),
- _file(to_copy._file? strdup(to_copy._file) : NIL),
+ _class(to_copy._class? strdup(to_copy._class) : NULL_POINTER),
+ _func(to_copy._func? strdup(to_copy._func) : NULL_POINTER),
+ _file(to_copy._file? strdup(to_copy._file) : NULL_POINTER),
_line(to_copy._line)
{
}
program_wide_stack_trace().pop_frame();
}
_frame_involved = false;
- free(_class); _class = NIL;
- free(_func); _func = NIL;
- free(_file); _file = NIL;
+ free(_class); _class = NULL_POINTER;
+ free(_func); _func = NULL_POINTER;
+ free(_file); _file = NULL_POINTER;
_line = 0;
}
{
clean();
_frame_involved = false; // copies don't get a right to this.
- _class = class_name? strdup(class_name) : NIL;
- _func = func? strdup(func) : NIL;
- _file = file? strdup(file) : NIL;
+ _class = class_name? strdup(class_name) : NULL_POINTER;
+ _func = func? strdup(func) : NULL_POINTER;
+ _file = file? strdup(file) : NULL_POINTER;
_line = line;
}
extern int _global_argc;
extern char **_global_argv;
//! this macro allocates space for the command-line storage areas.
-#define DEFINE_ARGC_AND_ARGV int _global_argc = 0; char **_global_argv = NIL
+#define DEFINE_ARGC_AND_ARGV int _global_argc = 0; char **_global_argv = NULL_POINTER
//! this macro assigns our command-line parameters for this program.
#define SET_ARGC_ARGV(argc, argv) { \
// mainly for debugging purposes. having the value for DLL_NAME actually
// stored should allow us to know which dll is being debugged.
- static CDynLinkLibrary *dll_link = NIL;
+ static CDynLinkLibrary *dll_link = NULL_POINTER;
static int dll_entry_count = 0;
//////////////
-static hoople_service *_global_hoople_service = NIL;
+static hoople_service *_global_hoople_service = NULL_POINTER;
// this static object is set by the setup() method. it should only come
// into existence once during a program's lifetime.
MSG msg;
msg.hwnd = 0; msg.message = 0; msg.wParam = 0; msg.lParam = 0;
- while (!alert.is_defunct() && (GetMessage(&msg, NIL, 0, 0)) {
+ while (!alert.is_defunct() && (GetMessage(&msg, NULL_POINTER, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
FUNCDEF("constructor");
// start the application checking thread.
- _checker->start(NIL);
+ _checker->start(NULL_POINTER);
_checker->reschedule(200); // make it start pretty quickly.
}
#endif
void construct(void *ptr, int size, char *where, int line) {
- _next = NIL;
+ _next = NULL_POINTER;
_chunk = ptr;
_size = size;
_where = strdup(where); // uses malloc, not new, so we're safe.
}
void destruct() {
- free(_chunk); _chunk = NIL;
- free(_where); _where = NIL;
- _next = NIL;
+ free(_chunk); _chunk = NULL_POINTER;
+ free(_where); _where = NULL_POINTER;
+ _next = NULL_POINTER;
_size = 0;
_line = 0;
#ifdef ENABLE_CALLSTACK_TRACKING
- free(_stack); _stack = NIL;
+ free(_stack); _stack = NULL_POINTER;
#endif
}
};
{
public:
void construct() {
- _head = NIL;
+ _head = NULL_POINTER;
_count = 0;
_lock = (mutex_base *)malloc(sizeof(mutex_base));
_lock->construct();
_lock->lock();
// search the bin to locate the item specified.
memlink *current = _head; // current will scoot through the list.
- memlink *previous = NIL; // previous remembers the parent node, if any.
+ memlink *previous = NULL_POINTER; // previous remembers the parent node, if any.
while (current) {
if (current->_chunk == to_release) {
#ifdef MEMORY_CHECKER_STATISTICS
_bins[i].destruct();
}
free(_bins);
- _bins = NIL;
+ _bins = NULL_POINTER;
}
int compute_slot(void *ptr) {
// this is fairly resource intensive, so don't dump the state out that often.
char *text_form(bool show_outstanding) {
- char *to_return = NIL;
+ char *to_return = NULL_POINTER;
if (show_outstanding) {
to_return = report_allocations();
} else {
_mems->destruct();
free(_mems);
- _mems = NIL;
+ _mems = NULL_POINTER;
}
void *memory_checker::provide_memory(size_t size, char *file, int line)
stdio_redirecter::stdio_redirecter()
:
#ifdef __WIN32__
- _child_in(NIL), _child_out(NIL), _child_err(NIL),
- _parent_in(NIL), _parent_out(NIL), _parent_err(NIL),
- _app_handle(NIL),
+ _child_in(NULL_POINTER), _child_out(NULL_POINTER), _child_err(NULL_POINTER),
+ _parent_in(NULL_POINTER), _parent_out(NULL_POINTER), _parent_err(NULL_POINTER),
+ _app_handle(NULL_POINTER),
#endif
_command(new astring),
_parms(new astring),
const astring ¶meters)
:
#ifdef __WIN32__
- _child_in(NIL), _child_out(NIL), _child_err(NIL),
- _parent_in(NIL), _parent_out(NIL), _parent_err(NIL),
- _app_handle(NIL),
+ _child_in(NULL_POINTER), _child_out(NULL_POINTER), _child_err(NULL_POINTER),
+ _parent_in(NULL_POINTER), _parent_out(NULL_POINTER), _parent_err(NULL_POINTER),
+ _app_handle(NULL_POINTER),
#endif
_command(new astring(command)),
_parms(new astring(parameters)),
SECURITY_ATTRIBUTES sa;
ZeroMemory(&sa, sizeof(SECURITY_ATTRIBUTES));
sa.nLength= sizeof(SECURITY_ATTRIBUTES);
- sa.lpSecurityDescriptor = NIL;
+ sa.lpSecurityDescriptor = NULL_POINTER;
sa.bInheritHandle = true;
- HANDLE in_temp = NIL, out_temp = NIL, err_temp = NIL;
+ HANDLE in_temp = NULL_POINTER, out_temp = NULL_POINTER, err_temp = NULL_POINTER;
// create pipes that we will hook up to the child process. these are
// currently inheritable based on the security attributes.
// fork off the process.
PROCESS_INFORMATION pi;
- BOOL success = CreateProcess(NIL, to_unicode_temp(cmd), sec_attr, NIL,
- true, CREATE_NEW_CONSOLE, NIL, NIL, &si, &pi);
+ BOOL success = CreateProcess(NULL_POINTER, to_unicode_temp(cmd), sec_attr, NULL_POINTER,
+ true, CREATE_NEW_CONSOLE, NULL_POINTER, NULL_POINTER, &si, &pi);
// cleanup junk we allocated.
- if (sec_attr != NIL) GlobalFree(sec_attr);
- if (sec_desc != NIL) GlobalFree(sec_desc);
+ if (sec_attr != NULL_POINTER) GlobalFree(sec_attr);
+ if (sec_desc != NULL_POINTER) GlobalFree(sec_desc);
if (success) {
// toss out the thread handle since we don't use it.
}
#endif
- _stdout_reader->start(NIL);
- _stderr_reader->start(NIL);
+ _stdout_reader->start(NULL_POINTER);
+ _stderr_reader->start(NULL_POINTER);
return OKAY;
}
#ifdef __UNIX__
close(_output_fds[1]); // shut down input to the child program.
#elif defined(__WIN32__)
- if (_child_in) { CloseHandle(_child_in); _child_in = NIL; }
- if (_parent_in) { CloseHandle(_parent_in); _parent_in = NIL; }
+ if (_child_in) { CloseHandle(_child_in); _child_in = NULL_POINTER; }
+ if (_parent_in) { CloseHandle(_parent_in); _parent_in = NULL_POINTER; }
#endif
}
close_input();
- if (_child_out) { CloseHandle(_child_out); _child_out = NIL; }
- if (_parent_out) { CloseHandle(_parent_out); _parent_out = NIL; }
+ if (_child_out) { CloseHandle(_child_out); _child_out = NULL_POINTER; }
+ if (_parent_out) { CloseHandle(_parent_out); _parent_out = NULL_POINTER; }
- if (_child_err) { CloseHandle(_child_err); _child_err = NIL; }
- if (_parent_err) { CloseHandle(_parent_err); _parent_err = NIL; }
+ if (_child_err) { CloseHandle(_child_err); _child_err = NULL_POINTER; }
+ if (_parent_err) { CloseHandle(_parent_err); _parent_err = NULL_POINTER; }
// shut down the child process if it's still there.
if (_app_handle) {
}
}
CloseHandle(_app_handle);
- _app_handle = NIL;
+ _app_handle = NULL_POINTER;
}
#endif
#elif defined(__WIN32__)
DWORD writ = 0;
BOOL ret = WriteFile(_parent_in, to_write.observe(), to_write.length(),
- &writ, NIL);
+ &writ, NULL_POINTER);
written = writ;
if (ret) return OKAY;
else return ACCESS_DENIED;
// read some data from the file. the function will return when a write
// operation completes or we get that much data.
DWORD bytes_read = 0;
- BOOL ret = ReadFile(where, buff.access(), BUFFER_SIZE, &bytes_read, NIL);
+ BOOL ret = ReadFile(where, buff.access(), BUFFER_SIZE, &bytes_read, NULL_POINTER);
//hmmm: if (ret && !bytes_read) {///set eof!!! }
#endif
if (ret && bytes_read) {
LOG("failed to open the key, trying to create it.");
DWORD dispose; // the disposition of the call (created or existing).
ret = RegCreateKeyEx((HKEY)translate_hive(_hive),
- to_unicode_temp(section), 0, NIL, REG_OPTION_NON_VOLATILE,
- KEY_ALL_ACCESS, NIL, &key, &dispose);
+ to_unicode_temp(section), 0, NULL_POINTER, REG_OPTION_NON_VOLATILE,
+ KEY_ALL_ACCESS, NULL_POINTER, &key, &dispose);
if (ret != ERROR_SUCCESS) {
LOG("failed to create the key!!");
return false;
shared_memory::shared_memory(int size, const char *identity)
: _locking(new rendezvous(identity)),
- _the_memory(NIL),
+ _the_memory(NULL_POINTER),
_valid(false),
_identity(new astring(identity)),
_size(size)
::CloseHandle(_the_memory);
#else
//hmmm: fix.
- _the_memory = NIL;
+ _the_memory = NULL_POINTER;
#endif
WHACK(_locking);
WHACK(_identity);
abyte *shared_memory::locked_grab_memory()
{
FUNCDEF("locked_grab_memory")
- abyte *to_return = NIL;
+ abyte *to_return = NULL_POINTER;
if (!_the_memory) return to_return;
#ifdef __UNIX__
- to_return = (abyte *)mmap(NIL, _size, PROT_READ | PROT_WRITE,
+ to_return = (abyte *)mmap(NULL_POINTER, _size, PROT_READ | PROT_WRITE,
MAP_SHARED, int(_the_memory), 0);
#elif defined(__WIN32__)
to_return = (abyte *)::MapViewOfFile((HANDLE)_the_memory, FILE_MAP_ALL_ACCESS,
// this is a placeholder implementation for other platforms.
window_handle create_simplistic_window(const basis::astring &formal(window_title),
- const basis::astring &formal(class_name)) { return NIL; }
+ const basis::astring &formal(class_name)) { return NULL_POINTER; }
void whack_simplistic_window(window_handle formal(f_window)) {}
#else
register_class(class_name);
window_handle f_window = CreateWindow(basis::to_unicode_temp(class_name),
basis::to_unicode_temp(window_title), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT,
- 0, CW_USEDEFAULT, 0, NIL, NIL, GET_INSTANCE_HANDLE(), NIL);
+ 0, CW_USEDEFAULT, 0, NULL_POINTER, NULL_POINTER, GET_INSTANCE_HANDLE(), NULL_POINTER);
ShowWindow(f_window, SW_HIDE);
UpdateWindow(f_window);
return f_window;
void whack_simplistic_window(window_handle f_window)
{
- SendMessage(f_window, WM_CLOSE, NIL, NIL);
+ SendMessage(f_window, WM_CLOSE, NULL_POINTER, NULL_POINTER);
//hmmm: is this enough?
}
message.message = 0;
message.wParam = 0;
message.lParam = 0;
- if (!PeekMessage(&message, NIL, 0, 0, PM_REMOVE))
+ if (!PeekMessage(&message, NULL_POINTER, 0, 0, PM_REMOVE))
return false;
TranslateMessage(&message);
DispatchMessage(&message);
return strerror(to_name);
#elif defined(__WIN32__)
char error_text[1000];
- FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NIL, to_name,
+ FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL_POINTER, to_name,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)error_text,
- sizeof(error_text) - 1, NIL);
+ sizeof(error_text) - 1, NULL_POINTER);
istring to_return = error_text;
// trim off the ridiculous carriage return they add.
while ( (to_return[to_return.end()] == '\r')
.stuff(to_return[to_return.last()], len);
}
// add the sentinel to the list of strings.
- to_return += NIL;
+ to_return += NULL_POINTER;
#ifdef DEBUG_PORTABLE
for (int q = 0; to_return[q]; q++) {
printf("%d: %s\n", q, to_return[q]);
// }
}
istring parms = app_name + " " + command_line;
- bool success = CreateProcess(NIL, to_unicode_temp(parms), NIL, NIL, false,
- create_flag, NIL, NIL, &startup_info, &process_info);
+ bool success = CreateProcess(NULL_POINTER, to_unicode_temp(parms), NULL_POINTER, NULL_POINTER, false,
+ create_flag, NULL_POINTER, NULL_POINTER, &startup_info, &process_info);
if (!success)
return system_error();
// success then, merge back into stream.
namespace application {
-// istring module_name(const void *module_handle = NIL);
+// istring module_name(const void *module_handle = NULL_POINTER);
//!< returns the name of the module for the "module_handle" where supported.
- /*!< if the handle is NIL, then the program name is returned. */
+ /*!< if the handle is NULL_POINTER, then the program name is returned. */
// u_int system_error();
that's in use and we want NEW_AT_END, then the existing contents are
jammed up into the front end of the array. */
- array(int number = 0, const contents *init = NIL,
+ array(int number = 0, const contents *init = NULL_POINTER,
int flags = EXPONENTIAL_GROWTH | FLUSH_INVISIBLE);
//!< Constructs an array with room for "number" objects.
- /*!< The initial contents are copied from "init" unless NIL is passed in
- instead. If "init" is not NIL, then it must point to an array of objects
+ /*!< The initial contents are copied from "init" unless NULL_POINTER is passed in
+ instead. If "init" is not NULL_POINTER, then it must point to an array of objects
that contains at least "number". The "flags" are a value based on the
special flags being added bit-wise. If "flags" contains SIMPLE_COPY, then
memmove() is used rather than using the C++ object's assignment operator.
virtual ~array(); //!< destroys the memory allocated for the objects.
- void reset(int number = 0, const contents *initial_contents = NIL);
+ void reset(int number = 0, const contents *initial_contents = NULL_POINTER);
//!< Resizes this array and sets the contents from an array of contents.
- /*< If "initial_contents" is not NIL, then it must contain an array of
- "contents" with at least "number" objects in it. If it is NIL, then
+ /*< If "initial_contents" is not NULL_POINTER, then it must contain an array of
+ "contents" with at least "number" objects in it. If it is NULL_POINTER, then
the size of the array is changed but the contents are not. note that
any pre-existing elements that were previously out of range might still
have their prior contents; the newly available elements are not necessarily
class double_array : public array<double>
{
public:
- double_array(int len = 0, double *data = NIL)
+ double_array(int len = 0, double *data = NULL_POINTER)
: root_object(),
array<double>(len, data, SIMPLE_COPY | EXPONE) {}
double_array(const array<double> &to_copy) : array<double>(to_copy) {}
template <class contents>
array<contents>::array(int num, const contents *init, int flags)
-: root_object(), c_active_length(0), c_real_length(0), c_mem_block(NIL), c_offset(NIL), c_flags(flags)
+: root_object(), c_active_length(0), c_real_length(0), c_mem_block(NULL_POINTER), c_offset(NULL_POINTER), c_flags(flags)
{
if (c_flags > 7) {
#ifdef DEBUG_ARRAY
template <class contents>
array<contents>::array(const array<contents> &cf)
-: root_object(), c_active_length(0), c_real_length(0), c_mem_block(NIL), c_offset(NIL), c_flags(cf.c_flags)
+: root_object(), c_active_length(0), c_real_length(0), c_mem_block(NULL_POINTER), c_offset(NULL_POINTER), c_flags(cf.c_flags)
{
allocator_reset(cf.c_active_length, 1); // get some space.
operator = (cf); // assignment operator does the rest.
template <class contents>
array<contents>::~array()
{
- c_offset = NIL;
+ c_offset = NULL_POINTER;
if (c_mem_block) delete [] c_mem_block;
- c_mem_block = NIL;
+ c_mem_block = NULL_POINTER;
c_active_length = 0;
c_real_length = 0;
}
array<contents> array<contents>::concatenation(const array &s1) const
{
// tailor the return array to the new size needed.
- array<contents> to_return(this->length() + s1.length(), NIL, s1.c_flags);
+ array<contents> to_return(this->length() + s1.length(), NULL_POINTER, s1.c_flags);
to_return.overwrite(0, *this); // put the first part into the new array.
to_return.overwrite(this->length(), s1); // add the second segment.
return to_return;
template <class contents>
array<contents> array<contents>::concatenation(const contents &s1) const
{
- array<contents> to_return(this->length() + 1, NIL, c_flags);
+ array<contents> to_return(this->length() + 1, NULL_POINTER, c_flags);
to_return.overwrite(0, *this);
if (!this->simple())
to_return.access()[to_return.last()] = s1;
template <class contents>
array<contents> array<contents>::subarray(int start, int end) const
{
- bounds_return(start, 0, this->last(), array<contents>(0, NIL, c_flags));
- bounds_return(end, 0, this->last(), array<contents>(0, NIL, c_flags));
- if (start > end) return array<contents>(0, NIL, c_flags);
+ bounds_return(start, 0, this->last(), array<contents>(0, NULL_POINTER, c_flags));
+ bounds_return(end, 0, this->last(), array<contents>(0, NULL_POINTER, c_flags));
+ if (start > end) return array<contents>(0, NULL_POINTER, c_flags);
return array<contents>(end - start + 1, &(this->observe()[start]), c_flags);
}
if (c_mem_block) {
// remove old contents.
delete [] c_mem_block;
- c_mem_block = NIL;
- c_offset = NIL;
+ c_mem_block = NULL_POINTER;
+ c_offset = NULL_POINTER;
}
c_active_length = initial; // reset the length to the reporting size.
c_real_length = initial + blocking; // compute the real length.
if (c_real_length < new_size) {
// there's really not enough space overall, no fooling. we now will
// create a new block.
- c_mem_block = NIL; // zero out the pointer so reset doesn't delete it.
+ c_mem_block = NULL_POINTER; // zero out the pointer so reset doesn't delete it.
delete_old = true;
int blocking = 1;
if (exponential()) blocking = new_size + 1;
class char_star_array : public array<char *>
{
public:
- char_star_array() : array<char *>(0, NIL, SIMPLE_COPY | EXPONE
+ char_star_array() : array<char *>(0, NULL_POINTER, SIMPLE_COPY | EXPONE
| FLUSH_INVISIBLE) {}
~char_star_array() {
// clean up all the memory we're holding.
{
if (!initial) initial = ' '; // for nulls, we use spaces.
int new_size = c_character_manager.length() - 1;
- memset(c_character_manager.access(), initial, new_size);
+
+ /*hmmm: eclipse was badgering me into adding types on this, but it's not really an error in my code seemingly.
+ * eclipse seems to want a ? type in the last parameter, not a size_t or int. why? doesn't it know size_t?
+ */
+ memset((void *)c_character_manager.access(), (int)initial, (size_t)new_size);
c_character_manager.put(new_size, '\0');
c_held_string = (char * const *)c_character_manager.internal_offset_mem();
}
va_end(args);
}
-astring::~astring() { c_held_string = NIL; }
+astring::~astring() { c_held_string = NULL_POINTER; }
const astring &astring::empty_string() { return bogonic<astring>(); }
}
// action time: the output string is given a tasty value.
char temp[LONGEST_SPRINTF];
- char *temp2 = NIL; // for dynamic only.
+ char *temp2 = NULL_POINTER; // for dynamic only.
switch (next_argument) {
//hmmm: this switch is where support would need to be added for having two
// arguments (for the '*' case).
if (!to_print) {
// bogus string; put in a complaint.
use_dynamic_sprintf = false;
- ::sprintf(temp, "{error:parm=NIL}");
+ ::sprintf(temp, "{error:parm=NULL_POINTER}");
} else if (strlen(to_print) < LONGEST_SPRINTF - 2) {
// we're within our bounds, plus some safety room, so just do a
// regular sprintf.
if (!array_to_stuff) return;
array_to_stuff[0] = '\0';
if ( (how_many <= 0) || (length() <= 0) ) return;
- strncpy(array_to_stuff, observe(), minimum(how_many, int(length())));
+ strncpy(array_to_stuff, observe(), (size_t)minimum(how_many, int(length())));
array_to_stuff[minimum(how_many, int(length()))] = '\0';
}
virtual const char *observe() const;
//!< observes the underlying pointer to the zero-terminated string.
/*!< this does not allow the contents to be modified. this method should
- never return NIL. */
+ never return NULL_POINTER. */
const char *c_str() const { return observe(); }
//!< synonym for observe. mimics the STL method name.
const char *s() const { return observe(); }
virtual char *access();
//!< provides access to the actual string held.
- /*!< this should never return NIL. be very careful with the returned
+ /*!< this should never return NULL_POINTER. be very careful with the returned
pointer: don't destroy or corrupt its contents (e.g., do not mess with
its zero termination). */
char *c_str() { return access(); }
virtual const char *observe() const = 0;
//!< observes the underlying pointer to the zero-terminated string.
/*!< this does not allow the contents to be modified. this method should
- never return NIL. */
+ never return NULL_POINTER. */
virtual char *access() = 0;
//!< provides access to the actual string held.
- /*!< this should never return NIL. be very careful with the returned
+ /*!< this should never return NULL_POINTER. be very careful with the returned
pointer: don't destroy or corrupt its contents (e.g., do not mess with
its zero termination). */
class byte_array : public array<abyte>, public virtual orderable
{
public:
- byte_array(int number = 0, const abyte *initial_contents = NIL)
+ byte_array(int number = 0, const abyte *initial_contents = NULL_POINTER)
: array<abyte>(number, initial_contents, SIMPLE_COPY | EXPONE) {}
//!< constructs an array of "number" bytes from "initial_contents".
// Constants...
-//! The value representing a pointer to nothing, or nothing itself.
-#define NIL 0
+//! The value representing a pointer to nothing.
+#define NULL_POINTER 0
+
+////! A null pointer with a type of (void *).
+//#define NULL_VOID_POINTER (void *)NULL_POINTER
//! A fundamental constant measuring the number of bits in a byte.
#define BITS_PER_BYTE 8
//! A fairly important unit which is seldom defined...
typedef unsigned char abyte;
-/* ridiculous! all to shut microsoft up about ambiguous byte definitions,
-which seems like a bug.
-struct byte {
- byte(unsigned char b = 0) : c_data(b) {}
-// byte(char b) : c_data(b) {}
- operator unsigned char() const { return c_data; }
- operator char() const { return c_data; }
- operator int() const { return c_data; }
- operator unsigned int() const { return c_data; }
- operator bool() const { return (bool)c_data; }
- byte operator &(byte and_with) { return c_data & and_with; }
- byte operator |(byte or_with) { return c_data & or_with; }
- unsigned char c_data;
-};
-*/
#if defined(UNICODE) && defined(__WIN32__)
//! the flexichar type is always appropriate to hold data for win32 calls.
// the returned object junk in almost all cases.
// 4996 turns off warnings about deprecated functions, which are mostly
// nonsense, since these are mainly the core posix functions.
+#else
+//hmmm: trying to fix complaints about size_t being '?'.
+// typedef long long __int64;
+ //#define __SIZE_TYPE__ long unsigned int
#endif // ms visual c++.
//////////////
//! deletion with clearing of the pointer.
/*! this function simplifies the two step process of deleting a pointer and
-then clearing it to NIL. this makes debugging a bit easier since an access
-of NIL should always cause a fault, rather than looking like a possibly
+then clearing it to NULL_POINTER. this makes debugging a bit easier since an access
+of NULL_POINTER should always cause a fault, rather than looking like a possibly
valid object. */
template<class contents>
-void WHACK(contents * &ptr) { if (ptr) { delete ptr; ptr = NIL; } }
+void WHACK(contents * &ptr) { if (ptr) { delete ptr; ptr = NULL_POINTER; } }
//! Returns an object that is defined statically.
/*! Thus the returned object will never be recreated once this function
ret = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
#endif
if (ret != 0) {
- printf("failed to initialize mutex attributes!\n"); fflush(NIL);
+ printf("failed to initialize mutex attributes!\n"); fflush(NULL_POINTER);
}
c_os_mutex = (pthread_mutex_t *)malloc(sizeof(pthread_mutex_t));
pthread_mutex_init((pthread_mutex_t *)c_os_mutex, &attr);
transcode_to_utf16::~transcode_to_utf16()
{
delete[] _converted;
- _converted = NIL;
+ _converted = NULL_POINTER;
}
int transcode_to_utf16::length() const
transcode_to_utf8::~transcode_to_utf8()
{
delete[] _converted;
- _converted = NIL;
+ _converted = NULL_POINTER;
}
int transcode_to_utf8::length() const
null_transcoder(const astring &utf8_input, bool make_own_copy);
~null_transcoder() {
if (_make_own_copy) delete [] _converted;
- _converted = NIL;
+ _converted = NULL_POINTER;
}
int length() const;
to_return = get_cmdline_from_proc();
#elif defined(_MSC_VER)
flexichar low_buff[MAX_ABS_PATH + 1];
- GetModuleFileName(NIL, low_buff, MAX_ABS_PATH - 1);
+ GetModuleFileName(NULL_POINTER, low_buff, MAX_ABS_PATH - 1);
astring buff = from_unicode_temp(low_buff);
buff.to_lower(); // we lower-case the name since windows seems to UC it.
to_return = buff;
return &curr;
}
}
- return NIL;
+ return NULL_POINTER;
}
bool configuration_list::zap(const configlet &dead_item)
const configlet *find(const configlet &to_find) const;
//!< locates the actual configlet with the section and entry of "to_find".
/*!< note that this might fail if no matching section and entry are found,
- thus returning NIL. the returned object is still kept in the list, so
+ thus returning NULL_POINTER. the returned object is still kept in the list, so
do not try to destroy it. also note that the object passed in must be
- the same type as the object to be found; otherwise, NIL will be
+ the same type as the object to be found; otherwise, NULL_POINTER will be
returned. */
bool zap(const configlet &dead_item);
const astring &entry, const astring &to_store)
{
return bool(WritePrivateProfileString(to_unicode_temp(section),
- entry.length() ? (flexichar *)to_unicode_temp(entry) : NIL,
- to_store.length() ? (flexichar *)to_unicode_temp(to_store) : NIL,
+ entry.length() ? (flexichar *)to_unicode_temp(entry) : NULL_POINTER,
+ to_store.length() ? (flexichar *)to_unicode_temp(to_store) : NULL_POINTER,
to_unicode_temp(name())));
}
flexichar *return_buffer, int buffer_size)
{
GetPrivateProfileString(section.length() ?
- (flexichar *)to_unicode_temp(section) : NIL,
- entry.length() ? (flexichar *)to_unicode_temp(entry) : NIL,
+ (flexichar *)to_unicode_temp(section) : NULL_POINTER,
+ entry.length() ? (flexichar *)to_unicode_temp(entry) : NULL_POINTER,
to_unicode_temp(default_value),
return_buffer, buffer_size, to_unicode_temp(name()));
}
#include "ini_configurator.h"
#include "system_values.h"
-#include <algorithms/shell_sort.h>
#include <structures/int_hash.h>
#include <structures/string_table.h>
#include <textual/list_parsing.h>
#include <textual/parser_bits.h>
+#include "../algorithms/sorts.h"
using namespace algorithms;
using namespace basis;
return curr;
}
}
- return NIL;
+ return NULL_POINTER;
}
};
EVP_CIPHER_CTX *session = EVP_CIPHER_CTX_new();
EVP_CIPHER_CTX_init(session);
- EVP_EncryptInit_ex(session, EVP_bf_cbc(), NIL, _key->observe(),
+ EVP_EncryptInit_ex(session, EVP_bf_cbc(), NULL_POINTER, _key->observe(),
init_vector().observe());
EVP_CIPHER_CTX_set_key_length(session, _key_size);
EVP_CIPHER_CTX *session = EVP_CIPHER_CTX_new();
EVP_CIPHER_CTX_init(session);
LOG(a_sprintf("key size %d bits.\n", BITS_PER_BYTE * _key->length()));
- EVP_DecryptInit_ex(session, EVP_bf_cbc(), NIL, _key->observe(),
+ EVP_DecryptInit_ex(session, EVP_bf_cbc(), NULL_POINTER, _key->observe(),
init_vector().observe());
EVP_CIPHER_CTX_set_key_length(session, _key_size);
// protects unsafe areas of rsa crypto from access by multiple threads at once.
rsa_crypto::rsa_crypto(int key_size)
-: _key(NIL)
+: _key(NULL_POINTER)
{
FUNCDEF("ctor(int)");
LOG("prior to generating key");
}
rsa_crypto::rsa_crypto(const byte_array &key)
-: _key(NIL)
+: _key(NULL_POINTER)
{
FUNCDEF("ctor(byte_array)");
static_ssl_initializer();
}
rsa_crypto::rsa_crypto(RSA *key)
-: _key(NIL)
+: _key(NULL_POINTER)
{
FUNCDEF("ctor(RSA)");
static_ssl_initializer();
rsa_crypto::rsa_crypto(const rsa_crypto &to_copy)
: root_object(),
- _key(NIL)
+ _key(NULL_POINTER)
{
FUNCDEF("copy ctor");
static_ssl_initializer();
static_ssl_initializer();
LOG("into generate key");
auto_synchronizer mutt(__single_stepper());
- RSA *to_return = RSA_generate_key(key_size, 65537, NIL, NIL);
+ RSA *to_return = RSA_generate_key(key_size, 65537, NULL_POINTER, NULL_POINTER);
if (!to_return) {
continuable_error(static_class_name(), func,
a_sprintf("failed to generate a key of %d bits.", key_size));
// get the public key bits first.
byte_array n;
if (!structures::detach(key, n)) return false;
- BIGNUM *the_n = BN_bin2bn(n.access(), n.length(), NIL);
+ BIGNUM *the_n = BN_bin2bn(n.access(), n.length(), NULL_POINTER);
if (!the_n) return false;
byte_array e;
if (!structures::detach(key, e)) return false;
- BIGNUM *the_e = BN_bin2bn(e.access(), e.length(), NIL);
+ BIGNUM *the_e = BN_bin2bn(e.access(), e.length(), NULL_POINTER);
if (!the_e) return false;
if (type == 'u') {
// done with public key.
#ifdef NEWER_OPENSSL
- RSA_set0_key(_key, the_n, the_e, NIL);
+ RSA_set0_key(_key, the_n, the_e, NULL_POINTER);
#else
_key->n = the_n; _key->e = the_e;
#endif
// the rest is for a private key.
byte_array d;
if (!structures::detach(key, d)) return false;
- BIGNUM *the_d = BN_bin2bn(d.access(), d.length(), NIL);
+ BIGNUM *the_d = BN_bin2bn(d.access(), d.length(), NULL_POINTER);
if (!the_d) return false;
byte_array p;
if (!structures::detach(key, p)) return false;
- BIGNUM *the_p = BN_bin2bn(p.access(), p.length(), NIL);
+ BIGNUM *the_p = BN_bin2bn(p.access(), p.length(), NULL_POINTER);
if (!the_p) return false;
byte_array q;
if (!structures::detach(key, q)) return false;
- BIGNUM *the_q = BN_bin2bn(q.access(), q.length(), NIL);
+ BIGNUM *the_q = BN_bin2bn(q.access(), q.length(), NULL_POINTER);
if (!the_q) return false;
byte_array dmp1;
if (!structures::detach(key, dmp1)) return false;
- BIGNUM *the_dmp1 = BN_bin2bn(dmp1.access(), dmp1.length(), NIL);
+ BIGNUM *the_dmp1 = BN_bin2bn(dmp1.access(), dmp1.length(), NULL_POINTER);
if (!the_dmp1) return false;
byte_array dmq1;
if (!structures::detach(key, dmq1)) return false;
- BIGNUM *the_dmq1 = BN_bin2bn(dmq1.access(), dmq1.length(), NIL);
+ BIGNUM *the_dmq1 = BN_bin2bn(dmq1.access(), dmq1.length(), NULL_POINTER);
if (!the_dmq1) return false;
byte_array iqmp;
if (!structures::detach(key, iqmp)) return false;
- BIGNUM *the_iqmp = BN_bin2bn(iqmp.access(), iqmp.length(), NIL);
+ BIGNUM *the_iqmp = BN_bin2bn(iqmp.access(), iqmp.length(), NULL_POINTER);
if (!the_iqmp) return false;
// we can set the n, e and d now.
bool rsa_crypto::set_key(RSA *key)
{
FUNCDEF("set_key [RSA]");
- if (!key) return NIL;
+ if (!key) return NULL_POINTER;
// test the incoming key.
auto_synchronizer mutt(__single_stepper());
int check = RSA_check_key(key);
if (!worked) return false;
privkey[posn] = abyte('r'); // switch public key flag to private.
// convert the multiple private portions into binary.
- //const BIGNUM **the_n = NIL, **the_e = NIL, **the_d = NIL;
+ //const BIGNUM **the_n = NULL_POINTER, **the_e = NULL_POINTER, **the_d = NULL_POINTER;
BIGNUM **the_n = new BIGNUM *, **the_e = new BIGNUM *, **the_d = new BIGNUM *;
BIGNUM **the_p = new BIGNUM *, **the_q = new BIGNUM *;
BIGNUM **the_dmp1 = new BIGNUM *, **the_dmq1 = new BIGNUM *, **the_iqmp = new BIGNUM *;
public:
FILE *fp; // the real file pointer.
- file_hider() : fp(NIL) {}
+ file_hider() : fp(NULL_POINTER) {}
};
//////////////
close();
_auto_close = true; // reset since we know we're opening this.
_filename->reset(fname);
- _handle->fp = _filename->raw().t()? fopen(_filename->raw().s(), perms.s()) : NIL;
- if (_handle->fp == NIL) return false;
+ _handle->fp = _filename->raw().t()? fopen(_filename->raw().s(), perms.s()) : NULL_POINTER;
+ if (_handle->fp == NULL_POINTER) return false;
return good();
}
{
_filename->reset("");
if (_auto_close && _handle->fp) fclose(_handle->fp);
- _handle->fp = NIL;
+ _handle->fp = NULL_POINTER;
}
bool byte_filer::good() { return !!_handle->fp; }
#include "directory.h"
#include "filename.h"
-#include <algorithms/shell_sort.h>
#include <application/windoze_helper.h>
#include <basis/astring.h>
#include <basis/contracts.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
+
+#include "../algorithms/sorts.h"
#if defined(__UNIX__) || defined(__GNU_WINDOWS__)
#include <dirent.h>
#include <fnmatch.h>
dir_tree_iterator(const filename_tree *initial,
tree::traversal_directions dir)
- : filename_tree::iterator(initial, dir), _current(NIL) {}
+ : filename_tree::iterator(initial, dir), _current(NULL_POINTER) {}
};
//////////////
: _scanned_okay(false),
_path(new astring(path)),
_pattern(new astring(pattern)),
- _real_tree(NIL),
+ _real_tree(NULL_POINTER),
_ignore_files(ignore_files),
_creator(new fname_tree_creator)
{
// and recursively traverse that sub-node also.
const string_array &dirs = curr.directories();
for (int i = 0; i < dirs.length(); i++) {
- filename_tree *new_branch = NIL;
+ filename_tree *new_branch = NULL_POINTER;
astring new_path = path + filename::default_separator() + dirs[i];
#ifdef DEBUG_DIRECTORY_TREE
LOG(astring("seeking path: ") + new_path);
scanning._current = (filename_tree *)scanning.next();
}
// now check that we're healthy.
- if (!scanning._current) return NIL; // all done.
+ if (!scanning._current) return NULL_POINTER; // all done.
// cast the tree to the right type.
return dynamic_cast<filename_tree *>(scanning._current);
filename_list *directory_tree::access(dir_tree_iterator &scanning)
{
filename_tree *tof = goto_current(scanning);
- if (!tof) return NIL;
+ if (!tof) return NULL_POINTER;
return &tof->_files;
}
bool found = false;
// start looking at all the items in the list, even though we might have
// to abandon the iteration if we find a match.
- filename_tree *check = NIL;
+ filename_tree *check = NULL_POINTER;
for (posn = 0; posn < examining.length(); posn++) {
check = examining[posn];
filename current(check->_dirname);
break;
}
}
- if (!found) return NIL; // we found nothing comparable.
+ if (!found) return NULL_POINTER; // we found nothing comparable.
// we found a partial match. that means we should start looking at this
// node's children for the exact match.
if (!check) {
// this is a serious logical error!
LOG("serious logical error: tree was not located.");
- return NIL;
+ return NULL_POINTER;
}
examining.reset(); // clear the existing nodes.
for (int i = 0; i < check->branches(); i++)
examining += (filename_tree *)check->branch(i);
}
- return NIL; // we found nothing that looked like that node.
+ return NULL_POINTER; // we found nothing that looked like that node.
}
bool directory_tree::calculate(bool just_size)
// find the common root, break up the path into pieces, and tell us where
// we matched.
string_array pieces;
- filename_tree *last_match = NIL;
+ filename_tree *last_match = NULL_POINTER;
int comp_index;
astring reassembled; // this will hold the common root.
outcome ret = find_common_root(new_item, true, last_match, reassembled,
pieces, comp_index);
if (!last_match) {
LOG(astring("serious error finding common root for ") + new_item
- + ", got NIL tree.");
+ + ", got null tree.");
return common::FAILURE; // something serious isn't right.
}
FUNCDEF("remove_path");
// find the common root, if one exists. if not, we're not going to do this.
string_array pieces;
- filename_tree *last_match = NIL;
+ filename_tree *last_match = NULL_POINTER;
int comp_index;
astring reassembled;
outcome ret = find_common_root(zap_item, false, last_match, reassembled,
static filename_list *access(dir_tree_iterator &scanning);
//!< more dangerous operation that lets the actual list be manipulated.
- /*!< NIL is returned if there was a problem accessing the tree
+ /*!< NULL_POINTER is returned if there was a problem accessing the tree
at the iterator position. */
static bool depth(dir_tree_iterator &scanning, int &depth);
static filename_tree *goto_current(dir_tree_iterator &scanning);
//!< goes to the current node for "scanning" and returns the tree there.
- /*!< if there are no nodes left, NIL is returned. */
+ /*!< if there are no nodes left, NULL_POINTER is returned. */
void traverse(const basis::astring &path, const char *pattern,
filename_tree &add_to);
file_time(FILE *the_FILE);
//!< sets up the file_time information given a the file stream of interest.
- /*!< If the stream is NIL, then the file_time is set up with an invalid
+ /*!< If the stream is NULL_POINTER, then the file_time is set up with an invalid
time. */
file_time(const basis::astring &filename);
if (to_check.raw() == get(i)->raw()) return get(i);
#endif
}
- return NIL;
+ return NULL_POINTER;
}
int filename_list::locate(const filename &to_find) const
const file_info *find(const filename &to_check) const;
//!< locates the record of information for the filename "to_check".
/*!< do not modify the returned object. it contains the current state
- of the file in question. if the file wasn't in the list, then NIL is
+ of the file in question. if the file wasn't in the list, then NULL_POINTER is
returned. */
int locate(const filename &to_find) const;
if (filename(_real_file->name()).exists()) {
// file exists, so just update time.
#ifndef __WIN32__
- int ret = utimes(_real_file->name().observe(), NIL);
+ int ret = utimes(_real_file->name().observe(), NULL_POINTER);
if (ret != 0)
return FAILURE;
#else
// open the file, although the function says create in its name...
HANDLE f = CreateFile(_real_file->name().observe(),
GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
- NIL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NIL);
+ NULL_POINTER, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL_POINTER);
if (!f) {
LOG(a_sprintf("failed to open file %s", _real_file->name().observe()));
return FAILURE;
FILETIME *t = new FILETIME;
SystemTimeToFileTime(st, t);
// set the file's time.
- SetFileTime(f, NIL, t, t);
+ SetFileTime(f, NULL_POINTER, t, t);
#endif
} else {
// file doesn't exist yet.
return strerror(to_name);
#elif defined(_MSC_VER)
char error_text[1000];
- FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NIL, to_name,
+ FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL_POINTER, to_name,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)error_text,
- sizeof(error_text) - 1, NIL);
+ sizeof(error_text) - 1, NULL_POINTER);
astring to_return = error_text;
// trim off the ridiculous carriage return they add.
while ( (to_return[to_return.end()] == '\r')
to_print += info;
program_wide_logger::get().log(to_print, ALWAYS_PRINT);
- fflush(NIL); // flush all output streams.
+ fflush(NULL_POINTER); // flush all output streams.
}
void critical_events::alert_message(const astring &info) { alert_message(info.s()); }
file_logger::file_logger()
: _filename(new astring()),
_file_limit(DEFAULT_LOG_FILE_SIZE),
- _outfile(NIL),
+ _outfile(NULL_POINTER),
_flock(new mutex)
{
name("");
file_logger::file_logger(const astring &initial_filename, int limit)
: _filename(new astring()),
_file_limit(limit),
- _outfile(NIL),
+ _outfile(NULL_POINTER),
_flock(new mutex)
{
name(initial_filename);
standard_log_base *program_wide_logger::set(standard_log_base *new_log)
{
- if (!new_log) return NIL; // can't fool me that easily.
+ if (!new_log) return NULL_POINTER; // can't fool me that easily.
standard_log_base *old_log = c_the_wide_log;
c_the_wide_log = new_log;
return old_log;
const node *list::iterator::observe()
{
- if (!_manager || _manager->empty()) return NIL;
+ if (!_manager || _manager->empty()) return NULL_POINTER;
if (*this == _manager->head()) next();
if (*this == _manager->tail()) previous();
return _cursor;
node *list::iterator::access()
{
- if (!_manager || _manager->empty()) return NIL;
+ if (!_manager || _manager->empty()) return NULL_POINTER;
if (*this == _manager->head()) next();
if (*this == _manager->tail()) previous();
return _cursor;
//////////////
list::list()
-: _head(NIL), _tail(NIL)
+: _head(NULL_POINTER), _tail(NULL_POINTER)
{
_head = new node(2);
_tail = new node(2);
/*
node *list::get()
{
- if (empty()) return NIL; // make sure the list isn't empty.
+ if (empty()) return NULL_POINTER; // make sure the list isn't empty.
if (_cursor == _head) return _head->get_link(NEXT);
// check special case for pointing at the head.
if (_cursor == _tail) return _tail->get_link(PREVIOUS);
node *list::remove(iterator &where)
{
- if (where._manager != this) return NIL;
- if (empty()) return NIL;
+ if (where._manager != this) return NULL_POINTER;
+ if (empty()) return NULL_POINTER;
if (where._cursor == _head)
where._cursor = _head->get_link(NEXT);
if (where._cursor == _tail)
node *old_cursor = where._cursor;
node *old_previous = old_cursor->get_link(PREVIOUS);
node *old_next = old_cursor->get_link(NEXT);
- old_cursor->set_link(PREVIOUS, NIL);
- old_cursor->set_link(NEXT, NIL);
+ old_cursor->set_link(PREVIOUS, NULL_POINTER);
+ old_cursor->set_link(NEXT, NULL_POINTER);
old_previous->set_link(NEXT, old_next);
old_next->set_link(PREVIOUS, old_previous);
where._cursor = old_next;
void list::append(iterator &where, node *new_node)
{
if (where._manager != this) return;
- while (new_node->links() < 2) new_node->insert_link(0, NIL);
+ while (new_node->links() < 2) new_node->insert_link(0, NULL_POINTER);
if (empty()) where._cursor = _head;
if (where._cursor == _tail)
where._cursor = _tail->get_link(PREVIOUS);
void list::insert(iterator &where, node *new_node)
{
if (where._manager != this) return;
- while (new_node->links() < 2) new_node->insert_link(0, NIL);
+ while (new_node->links() < 2) new_node->insert_link(0, NULL_POINTER);
if (empty()) where._cursor = _tail;
if (where._cursor == _head)
where._cursor = _head->get_link(NEXT);
const node *observe(); //!< peek at the current element.
/*!< Note: observe() and access() will return the first element if the
list is positioned at the head (or the last if at the tail), and will
- not return NIL for these two positions as long as the list has some
+ not return NULL_POINTER for these two positions as long as the list has some
elements in it. the cursor will also have been moved to point at the
element that is returned.
Another Note: it is extremely important that you do not mess with the
links owned by the node (or at least the first two links).
- A Third Note: these two functions can return NIL if the list is empty. */
+ A Third Note: these two functions can return NULL_POINTER if the list is empty. */
node *access(); //!< obtain access to the current element.
private:
node *remove(iterator &where);
//!< extracts the current item from "where" and repairs the hole.
- /*!< NIL is returned if the list was empty. the current position is set
+ /*!< NULL_POINTER is returned if the list was empty. the current position is set
to the node that used to be after the node that has been removed. after
the call, the iterator points at the new node. */
// the internal_link class anonymously hangs onto a pointer to the object.
struct internal_link {
node *_connection;
- internal_link(node *destination = NIL) : _connection(destination) {}
- virtual ~internal_link() { _connection = NIL; }
+ internal_link(node *destination = NULL_POINTER) : _connection(destination) {}
+ virtual ~internal_link() { _connection = NULL_POINTER; }
};
class node_link_amorph : public amorph<internal_link>
// set_empty: assumes used correctly by internal functions--no bounds return.
void node::set_empty(int link_num)
{
- internal_link *blank_frank = new internal_link(NIL);
+ internal_link *blank_frank = new internal_link(NULL_POINTER);
_links->put(link_num, blank_frank);
}
node *node::get_link(int link_number) const
{
- bounds_return(link_number, 0, _links->elements()-1, NIL);
+ bounds_return(link_number, 0, _links->elements()-1, NULL_POINTER);
return (*_links)[link_number]->_connection;
}
node *get_link(int link_number) const;
//!< Returns the node that is connected to the specified "link_number".
- /*!< if the link is not set, then NIL is returned. */
+ /*!< if the link is not set, then NULL_POINTER is returned. */
void zap_link(int link_number);
//!< the specified link is removed from the node.
- void insert_link(int where, node *to_add = NIL);
+ void insert_link(int where, node *to_add = NULL_POINTER);
//!< adds a new link prior to the position specified in "where".
/*!< thus a "where" value of less than or equal to zero will add a new
link as the first element. a "where" value greater than or equal to
int packable_tree::recursive_packed_size() const
{
- packable_tree *curr = NIL;
+ packable_tree *curr = NULL_POINTER;
int accum = 0; // where we accumulate the length of the packed form.
for (iterator zip2 = start(postfix); (curr = (packable_tree *)zip2.next()); )
calcit(accum, curr);
void packable_tree::recursive_pack(byte_array &packed_form) const
{
- packable_tree *curr = NIL;
+ packable_tree *curr = NULL_POINTER;
for (iterator zip2 = start(postfix); (curr = (packable_tree *)zip2.next()); )
packit(packed_form, curr);
// get the first command out of the package.
if (!cmd.unpack(packed_form)) {
//complain.
- return NIL;
+ return NULL_POINTER;
}
- packable_tree *new_branch = NIL;
+ packable_tree *new_branch = NULL_POINTER;
bool failure = false; // set to true if errors occurred.
// the packed tree is traversed by grabbing a command and then doing what
static packable_tree *recursive_unpack(basis::byte_array &packed_form,
packable_tree_factory &creator);
//!< unpacks a tree stored in "packed_form" and returns it.
- /*!< if NIL is returned, then the unpack failed. the "creator" is needed
+ /*!< if NULL_POINTER is returned, then the unpack failed. the "creator" is needed
for making new derived packable_tree objects of the type stored. */
// standard pack, unpack and packed_size methods must be implemented by the derived tree.
{
node *to_return;
if (_stack->acquire_pop(to_return) != common::OKAY)
- return NIL;
+ return NULL_POINTER;
return to_return;
}
node *current() const;
node *follow() const;
//!< Returns the node specified by this path.
- /*!< if the path is not valid, NIL is returned. */
+ /*!< if the path is not valid, NULL_POINTER is returned. */
node *pop();
//!< returns the top node on the path stack.
"to_follow" is set to one of the possible paths. */
node *operator [] (int index) const;
- //!< returns the node stored at "index", or NIL if "index" is invalid.
+ //!< returns the node stored at "index", or NULL_POINTER if "index" is invalid.
private:
path_node_stack *_stack; //!< implementation of our pathway.
#ifdef DEBUG_SYMBOL_TREE
FUNCDEF("find");
#endif
- if (comp == NIL) comp = astring_comparator;
+ if (comp == NULL_POINTER) comp = astring_comparator;
#ifdef DEBUG_SYMBOL_TREE
LOG(astring("finding node called ") + to_find);
#endif
// perform the upward recursion first, since it's pretty simple.
if (how == recurse_upward) {
symbol_tree *our_parent = dynamic_cast<symbol_tree *>(parent());
- if (!our_parent) return NIL; // done recursing.
+ if (!our_parent) return NULL_POINTER; // done recursing.
return our_parent->find(to_find, how, comp);
}
if (!found) {
if (how == recurse_downward) {
// see if we can't find that name in a sub-node.
- symbol_tree *answer = NIL;
+ symbol_tree *answer = NULL_POINTER;
for (int i = 0; i < branches(); i++) {
// we will try each branch in turn and see if it has a child named
// appropriately.
return answer;
}
}
- return NIL;
+ return NULL_POINTER;
}
return *found;
}
symbol_tree *find(const basis::astring &to_find,
find_methods how,
///= just_branches,
- basis::string_comparator_function *comp = NIL);
- //!< returns the node specified by "to_find" or NIL.
+ basis::string_comparator_function *comp = NULL_POINTER);
+ //!< returns the node specified by "to_find" or NULL_POINTER.
/*!< this should be fairly quick due to the symbol table's hashing.
the "how" method specifies the type of recursion to be used in searching
if any. if "how" is passed as "just_branches", then only the branches are
"recurse_downward", then all sub-trees under the branches are checked
also. if "how" is given as "recurse_upward", then "this" node and parent
nodes are checked. the "comp" parameter will be used for comparing the
- strings if it's passed as non-NIL. */
+ strings if it's passed as non-null. */
void sort();
//!< sorts the sub-nodes of this symbol_tree.
#ifdef DEBUG_TREE
FUNCDEF("next_node");
#endif
- to_return = NIL;
+ to_return = NULL_POINTER;
#ifdef DEBUG_TREE
if ( (_order != to_branches)
&& (_order != reverse_branches) ) {
#ifdef DEBUG_TREE
FUNCDEF("next");
#endif
- tree *to_return = NIL;
+ tree *to_return = NULL_POINTER;
bool found_tree = false;
while (!found_tree) {
bool still_running = next_node(to_return);
tree::tree()
: node(1)
-{ set_link(BACKWARDS_BRANCH, NIL); }
+{ set_link(BACKWARDS_BRANCH, NULL_POINTER); }
tree::~tree()
{
// cousin.
tree *my_parent = parent();
if (my_parent) my_parent->prune(this);
- my_parent = NIL; // disavow since we are loose now.
+ my_parent = NULL_POINTER; // disavow since we are loose now.
#if 0
// newer version of delete doesn't recurse; it just iterates instead,
// which avoids the massive recursive depth of the original approach.
tree *curr_node = this;
- while (curr_node != NIL) {
+ while (curr_node != NULL_POINTER) {
// make a breadcrumb for getting back to 'here' in the tree.
tree *way_back = curr_node;
// our main operation here is to go down a node without using any
// or there are no kids at all.
curr_node = curr_node->branch(0);
- if (curr_node = NIL) {
+ if (curr_node = NULL_POINTER) {
// wayback has no children, so we can take action.
// if wayback is the same as "this", then we exit from iterations since
tree *tree::branch(int branch_number) const
{
branch_number++;
- bounds_return(branch_number, 1, branches(), NIL);
+ bounds_return(branch_number, 1, branches(), NULL_POINTER);
return (tree *)get_link(branch_number);
}
tree *tree::root() const
{
const tree *traveler = this;
- // keep looking at the backwards branch until it is a NIL. the tree with
- // a NIL BACKWARDS_BRANCH is the root. return that tree.
+ // keep looking at the backwards branch until it is a NULL_POINTER. the tree with
+ // a NULL_POINTER BACKWARDS_BRANCH is the root. return that tree.
while (traveler->get_link(BACKWARDS_BRANCH))
traveler = (tree *)traveler->get_link(BACKWARDS_BRANCH);
return const_cast<tree *>(traveler);
void tree::insert(int branch_place, tree *new_branch)
{
branch_place++;
- insert_link(links(), NIL);
+ insert_link(links(), NULL_POINTER);
if (branch_place >= links())
branch_place = links() - 1;
for (int i = links() - 1; i > branch_place; i--)
branch_to_cut++;
bounds_return(branch_to_cut, 1, branches(), basis::common::NOT_FOUND);
tree *that_branch = (tree *)get_link(branch_to_cut);
- that_branch->set_link(BACKWARDS_BRANCH, NIL);
+ that_branch->set_link(BACKWARDS_BRANCH, NULL_POINTER);
zap_link(branch_to_cut);
return basis::common::OKAY;
}
/*
tree *traveller = this;
path to_accumulate(root());
- while (traveller->parent() != NIL) {
+ while (traveller->parent() != NULL_POINTER) {
// int branch_number = traveller->parent()->which(traveller);
// if (branch_number == BRANCH_NOT_FOUND) non_continuable_error
// (class_name(), "generate_path", "branch not found during path construction");
virtual tree *branch(int branch_number) const;
//!< Returns the specified branch of this tree.
- /*!< NIL is returned if the "branch_number" refers to a branch that
+ /*!< NULL_POINTER is returned if the "branch_number" refers to a branch that
does not exist. */
virtual int which(tree *branch_to_find) const;
virtual tree *parent() const;
//!< Returns the tree node that is the immediate ancestor of this one.
- /*!< if this is the root node, then NIL is returned. */
+ /*!< if this is the root node, then NULL_POINTER is returned. */
virtual tree *root() const;
//!< Locates and returns the absolute root of the tree containing this tree.
tree *next();
//!< Returns a pointer to the next tree in the direction of traversal.
- /*!< If the traversal is finished, NIL is returned. */
+ /*!< If the traversal is finished, NULL_POINTER is returned. */
void whack(tree *to_whack);
//!< destroys the tree "to_whack".
bool next_node(tree *&to_return);
//!< sets "to_return" to the next tree in the direction of tree traversal.
/*!< if the next node could not be found in one invocation of next_node,
- then "to_return" is set to NIL. the function returns a boolean which
+ then "to_return" is set to NULL_POINTER. the function returns a boolean which
is true only if the iteration process can be continued by another call
to next_node. if the function returns false, the iteration is
- complete and "to_return" will always be NIL. */
+ complete and "to_return" will always be NULL_POINTER. */
};
iterator start(traversal_directions direction) const;
: _thread_ready(false),
_thread_active(false),
_stop_thread(false),
- _data(NIL),
+ _data(NULL_POINTER),
#ifdef _MSC_VER
_handle(0),
#else
: _thread_ready(false),
_thread_active(false),
_stop_thread(false),
- _data(NIL),
+ _data(NULL_POINTER),
#ifdef _MSC_VER
_handle(0),
#else
FUNCDEF("one_shot_thread_driver");
ethread *manager = (ethread *)hidden_pointer;
#ifndef _MSC_VER
- if (!manager) return NIL;
+ if (!manager) return NULL_POINTER;
#else
if (!manager) return;
#endif
_current_threads().decrement();
#endif
#ifndef _MSC_VER
- pthread_exit(NIL);
- return NIL;
+ pthread_exit(NULL_POINTER);
+ return NULL_POINTER;
#else
_endthread();
#endif
FUNCDEF("periodic_thread_driver");
ethread *manager = (ethread *)hidden_pointer;
#if defined(__UNIX__) || defined(__GNU_WINDOWS__)
- if (!manager) return NIL;
+ if (!manager) return NULL_POINTER;
#elif defined(_MSC_VER)
if (!manager) return;
#endif
_current_threads().decrement();
#endif
#ifndef _MSC_VER
- pthread_exit(NIL);
- return NIL;
+ pthread_exit(NULL_POINTER);
+ return NULL_POINTER;
#else
_endthread();
#endif
message.message = 0;
message.wParam = 0;
message.lParam = 0;
- if (!PeekMessage(&message, NIL, 0, 0, PM_REMOVE))
+ if (!PeekMessage(&message, NULL_POINTER, 0, 0, PM_REMOVE))
return false;
TranslateMessage(&message);
DispatchMessage(&message);
.stuff(to_return[to_return.last()], len);
}
// add the sentinel to the list of strings.
- to_return += NIL;
+ to_return += NULL_POINTER;
#ifdef DEBUG_LAUNCH_PROCESS
for (int q = 0; to_return[q]; q++) {
LOG(a_sprintf("%d: %s\n", q, to_return[q]));
// }
}
astring parms = app_name + " " + command_line;
- bool success = CreateProcess(NIL, to_unicode_temp(parms), NIL, NIL, false,
- create_flag, NIL, NIL, &startup_info, &process_info);
+ bool success = CreateProcess(NULL_POINTER, to_unicode_temp(parms), NULL_POINTER, NULL_POINTER, false,
+ create_flag, NULL_POINTER, NULL_POINTER, &startup_info, &process_info);
if (!success)
return critical_events::system_error();
// success then, merge back into stream.
class char_star_array : public basis::array<char *>
{
public:
- char_star_array() : basis::array<char *>(0, NIL, SIMPLE_COPY | EXPONE | FLUSH_INVISIBLE) {}
+ char_star_array() : basis::array<char *>(0, NULL_POINTER, SIMPLE_COPY | EXPONE | FLUSH_INVISIBLE) {}
~char_star_array() {
// clean up all the memory we're holding.
for (int i = 0; i < length(); i++) {
bool mailbox::pick_up(const unique_int &id, letter * &package)
{
- package = NIL;
+ package = NULL_POINTER;
auto_synchronizer l(*_transaction_lock);
return _packages->get(id, package);
}
unique_int _thread_id;
unique_int _id;
- tagged_mail_stop(const unique_int &id = 0, mail_stop *route = NIL,
+ tagged_mail_stop(const unique_int &id = 0, mail_stop *route = NULL_POINTER,
const unique_int &thread_id = 0)
: _route(route), _thread_id(thread_id), _id(id) {}
tagged_mail_stop *curr = borrow(i);
if (curr && (curr->_id == id)) return curr;
}
- return NIL;
+ return NULL_POINTER;
}
bool zap(const unique_int &id) {
if (found) return false; // already exists.
postal_carrier *po = new postal_carrier(*this, id);
- unique_int thread_id = _threads->add_thread(po, false, NIL);
+ unique_int thread_id = _threads->add_thread(po, false, NULL_POINTER);
// add the thread so we can record its id.
tagged_mail_stop *new_stop = new tagged_mail_stop(id, &carrier_path,
thread_id);
_routes->append(new_stop);
// add the mail stop to our listings.
- po->start(NIL);
+ po->start(NULL_POINTER);
// now start the thread so it can begin cranking.
return true;
}
/// HANDLE hSnapShot;
process_implementation_hider()
- : psapi_dll(NIL), vdm_dll(NIL), enumerate_processes(NIL),
- enumerate_modules(NIL), get_module_name(NIL),
+ : psapi_dll(NULL_POINTER), vdm_dll(NULL_POINTER), enumerate_processes(NULL_POINTER),
+ enumerate_modules(NULL_POINTER), get_module_name(NULL_POINTER),
//#ifdef _MSCVER
-// tasker_16bit(NIL),
+// tasker_16bit(NULL_POINTER),
//#endif
- kernel32_dll(NIL), create_snapshot(NIL), first_process(NIL),
- next_process(NIL) {}
+ kernel32_dll(NULL_POINTER), create_snapshot(NULL_POINTER), first_process(NULL_POINTER),
+ next_process(NULL_POINTER) {}
~process_implementation_hider() {
if (psapi_dll) FreeLibrary(psapi_dll);
if (vdm_dll) FreeLibrary(vdm_dll);
if (kernel32_dll) FreeLibrary(kernel32_dll);
- psapi_dll = NIL;
- vdm_dll = NIL;
- kernel32_dll = NIL;
+ psapi_dll = NULL_POINTER;
+ vdm_dll = NULL_POINTER;
+ kernel32_dll = NULL_POINTER;
}
#endif
};
// loop over the process enumeration function until we are sure that we
// have allocated a large enough space for all existing processes.
bool got_all = false;
- basis::un_int *pid_list = NIL;
+ basis::un_int *pid_list = NULL_POINTER;
basis::un_int max_size = 428 * sizeof(basis::un_int);
basis::un_int actual_size = 0;
while (!got_all) {
_rando->inclusive(1, 400000));
a_sprintf cmd("ps wax --format \"%%p %%a\" >%s", tmpfile.s());
//hmmm: add more info as we expand the process entry.
- FILE *output = NIL; // initialize now to establish variable for our macro.
+ FILE *output = NULL_POINTER; // initialize now to establish variable for our macro.
int sysret = system(cmd.s());
if (negative(sysret)) {
LOG("got negative return from system()!");
#endif
rendezvous::rendezvous(const astring &root_name)
-: _handle(NIL),
+: _handle(NULL_POINTER),
_locked(false),
_root_name(new astring(root_name))
{
_handle = locking_file;
#endif
#ifdef __WIN32__
- _handle = CreateMutex(NIL, false, to_unicode_temp(lock_name));
+ _handle = CreateMutex(NULL_POINTER, false, to_unicode_temp(lock_name));
if (!_handle) return;
#endif
}
}
fclose((FILE *)_handle);
- _handle = NIL;
+ _handle = NULL_POINTER;
}
#endif
#ifdef __WIN32__
// returns true if the "object" is listed as valid.
bool listed(void *object) {
auto_synchronizer l(_lock);
- live_object_info *loi = NIL;
+ live_object_info *loi = NULL_POINTER;
return _objects.find(object, loi);
}
// adds the "object" to the list, or if it's already there, ups the refcount.
void add(void *object) {
auto_synchronizer l(_lock);
- live_object_info *loi = NIL;
+ live_object_info *loi = NULL_POINTER;
if (!_objects.find(object, loi)) {
// this is a new item.
_objects.add(object, new live_object_info);
// references.
void remove(void *object) {
auto_synchronizer l(_lock);
- live_object_info *loi = NIL;
+ live_object_info *loi = NULL_POINTER;
if (!_objects.find(object, loi)) {
// this item doesn't exist??? bad usage has occurred..
return;
LOCKIT;
thread_record *rec = _threads->borrow(index);
if (rec) return rec->_thread;
- return NIL;
+ return NULL_POINTER;
}
} //namespace.
#endif
nt_security::nt_security()
-: m_sDirServiceProvider(NIL)
+: m_sDirServiceProvider(NULL_POINTER)
{
// Eventually, construction of nt_security should determine if WinNT://
// or LDAP://, etc is the service provider and set a private member variable
An amorph has a specified number of fields at any one time, but the number
can be changed with "zap", "insert" and "adjust". Fields in the amorph
- are either full or empty, where an empty field in the amorph has NIL as
+ are either full or empty, where an empty field in the amorph has NULL_POINTER as
its content. "put" adds a new field to the amorph. "get" retrieves the
contents of a field as a constant. "acquire" is used to check a field
out of the amorph, meaning that the amorph no longer possesses that field.
//!< the maximum number of elements currently allowed in this amorph.
int valid_fields() const { return _fields_used; }
- //!< Returns the number of fields that have non-NIL contents.
+ //!< Returns the number of fields that have non-null contents.
/*!< This might be different from the number of total elements. */
void adjust(int new_max);
basis::outcome put(int field, const contents *data);
//!< Enters an object into the field at index "field" in the amorph.
- /*!< If "data" is NIL, then the field is cleared. The amorph considers the
+ /*!< If "data" is NULL_POINTER, then the field is cleared. The amorph considers the
pointer "data" to be its own property after put is invoked; "data"
should not be destructed since the amorph will automatically do so.
This restriction does not hold if the object is checked back out of
//!< a synonym for append.
//! Returns a constant pointer to the information at the index "field".
- /*! If no information is stored or the field is out range, then NIL is
+ /*! If no information is stored or the field is out range, then NULL_POINTER is
returned. */
const contents *get(int field) const;
//! Returns a pointer to the information at the index "field".
- /*! Also returns NIL for invalid indexes. DO NOT destroy the returned
+ /*! Also returns NULL_POINTER for invalid indexes. DO NOT destroy the returned
pointer; it is still owned by the amorph. */
contents *borrow(int field);
const contents *next_valid(int &field) const;
//!< Returns the contents of the next valid element at or after "field".
/*!< "field" is set to the location where an entry was found, if one was
- actually found. If none exists at "field" or after it, then NIL is
+ actually found. If none exists at "field" or after it, then NULL_POINTER is
returned. */
int find(const contents *to_locate, basis::outcome &o);
/*!< This is only used for the debugging version. */
void set_nil(int start, int end);
- // Puts NIL in the indices between start and end.
+ // Puts NULL_POINTER in the indices between start and end.
/*!< Does not delete whatever used to reside there; it just sets the
- pointers to NIL. */
+ pointers to NULL_POINTER. */
// not to be used: amorphs should not be copied because it is intended that
// they support storing heavyweight objects that either have no copy
template <class contents>
amorph<contents>::amorph(int elements)
-: basis::array<contents *>(elements, NIL, basis::array<contents *>::SIMPLE_COPY
+: basis::array<contents *>(elements, NULL_POINTER, basis::array<contents *>::SIMPLE_COPY
| basis::array<contents *>::EXPONE | basis::array<contents *>::FLUSH_INVISIBLE),
_fields_used(0)
{
void amorph<contents>::set_nil(int start, int end)
{
for (int i = start; i <= end; i++)
- basis::array<contents *>::put(i, (contents *)NIL);
+ basis::array<contents *>::put(i, (contents *)NULL_POINTER);
}
template <class contents>
{
FUNCDEF("get");
CHECK_FIELDS;
- bounds_return(field, 0, elements() - 1, NIL);
+ bounds_return(field, 0, elements() - 1, NULL_POINTER);
return basis::array<contents *>::observe()[field];
}
basis::array<contents *>::insert(old_max, new_fields);
for (int i = old_max; i < new_maximum; i++) {
- basis::array<contents *>::put(i, NIL);
+ basis::array<contents *>::put(i, NULL_POINTER);
}
}
{
FUNCDEF("next_valid");
CHECK_FIELDS;
- bounds_return(field, 0, elements() - 1, NIL);
+ bounds_return(field, 0, elements() - 1, NULL_POINTER);
for (int i = field; i < elements(); i++)
if (basis::array<contents *>::get(i)) {
field = i;
return basis::array<contents *>::get(i);
}
- return NIL;
+ return NULL_POINTER;
}
template <class contents>
{
FUNCDEF("clear");
CHECK_FIELDS;
- return this->put(field, NIL);
+ return this->put(field, NULL_POINTER);
}
template <class contents>
contents *to_return = borrow(field);
if (to_return) {
_fields_used--;
- basis::array<contents *>::access()[field] = NIL;
+ basis::array<contents *>::access()[field] = NULL_POINTER;
}
return to_return;
}
{
FUNCDEF("borrow");
CHECK_FIELDS;
- bounds_return(field, 0, elements() - 1, NIL);
+ bounds_return(field, 0, elements() - 1, NULL_POINTER);
return basis::array<contents *>::access()[field];
}
}
for (int i = 0; i < to_assign.elements(); i++) {
if (to_copy.get(i)) to_assign.put(i, new contents(*to_copy.get(i)));
- else to_assign.put(i, (contents *)NIL);
+ else to_assign.put(i, (contents *)NULL_POINTER);
}
}
namespace structures {
bit_vector::bit_vector()
-: _implementation(new byte_array(0, NIL)), _number_of_bits(0)
+: _implementation(new byte_array(0, NULL_POINTER)), _number_of_bits(0)
{}
bit_vector::bit_vector(int number_of_bits, const abyte *initial)
-: _implementation(new byte_array(0, NIL)), _number_of_bits(0)
+: _implementation(new byte_array(0, NULL_POINTER)), _number_of_bits(0)
{
reset(number_of_bits);
if (!initial) return;
bit_vector();
//!< creates a zero length bit_vector.
- bit_vector(int size, const basis::abyte *initial = NIL);
+ bit_vector(int size, const basis::abyte *initial = NULL_POINTER);
//!< creates a bit_vector able to store "size" bits.
- /*!< if initial is NIL, the vector is initialized to zero. otherwise, the
+ /*!< if initial is NULL_POINTER, the vector is initialized to zero. otherwise, the
bits are copied from "initial". "initial" must be large enough for the
copying to succeed. */
destroy or otherwise damage the "item_found". */
contents *find(const key_type &key) const
- { contents *c = NIL; return find(key, c)? c : NIL; }
+ { contents *c = NULL_POINTER; return find(key, c)? c : NULL_POINTER; }
//!< simplified form of above find() method.
contents *acquire(const key_type &key);
//!< retrieves the contents held for "key" out of the table.
/*!< afterwards, the contents pointer is the caller's responsibility; it
is no longer in the table and must be destroyed externally. if no item
- was found for the "key", then NIL is returned. */
+ was found for the "key", then NULL_POINTER is returned. */
bool zap(const key_type &key);
//!< removes the entry with the "key" specified.
key_type *_id;
contents *_data;
- hash_wrapper(key_type *id = NIL, contents *data = NIL)
+ hash_wrapper(key_type *id = NULL_POINTER, contents *data = NULL_POINTER)
: _id(id), _data(data) {}
};
public virtual basis::root_object
{
public:
- bucket() : basis::array<hash_wrapper<key_type, contents> >(0, NIL,
+ bucket() : basis::array<hash_wrapper<key_type, contents> >(0, NULL_POINTER,
basis::byte_array::SIMPLE_COPY | basis::byte_array::EXPONE
| basis::byte_array::FLUSH_INVISIBLE) {}
FUNCDEF("find");
if (!verify()) deadly_error(class_name(), func, "state did not verify.");
#endif
- item_found = NIL;
+ item_found = NULL_POINTER;
// get a hash value.
basis::un_int hashed = _hasher->hash((const void *)&key, sizeof(key));
// make the value appropriate for our table.
hashed = hashed % _table->elements();
// see if the key exists in the bucket.
bucket<key_type, contents> *buck = _table->borrow(hashed);
- if (!buck) return NIL;
+ if (!buck) return NULL_POINTER;
int indy = buck->find(key);
- if (basis::negative(indy)) return NIL; // nope, not there.
+ if (basis::negative(indy)) return NULL_POINTER; // nope, not there.
contents *to_return = (*buck)[indy]._data;
basis::WHACK((*buck)[indy]._id); // clean the id.
buck->zap(indy, indy); // toss the storage blob for the item.
class matrix : protected basis::array<contents>
{
public:
- matrix(int rows = 0, int cols = 0, contents *data = NIL);
+ matrix(int rows = 0, int cols = 0, contents *data = NULL_POINTER);
//!< the "data" array must have at least "rows" * "cols" contents in it.
matrix(const matrix &to_copy);
/*!< the result can be used as a pointer to the whole row of data, or it
can be indexed into by column to find a row/column position. this is
dangerous if one is not careful about ensuring that the column used is
- within bounds. if the "row" parameter is out of bounds, then NIL is
+ within bounds. if the "row" parameter is out of bounds, then NULL_POINTER is
returned. */
const contents *operator[] (int row) const;
//!< dangerous: constant peek into data for "row" in underlying contents.
class int_matrix : public matrix<int>
{
public:
- int_matrix(int rows = 0, int cols = 0, int *data = NIL)
+ int_matrix(int rows = 0, int cols = 0, int *data = NULL_POINTER)
: matrix<int>(rows, cols, data) {}
int_matrix(const matrix<int> &to_copy) : matrix<int>(to_copy) {}
};
class string_matrix : public matrix<basis::astring>
{
public:
- string_matrix(int rows = 0, int cols = 0, basis::astring *data = NIL)
+ string_matrix(int rows = 0, int cols = 0, basis::astring *data = NULL_POINTER)
: matrix<basis::astring>(rows, cols, data) {}
string_matrix(const matrix<basis::astring> &to_copy) : matrix<basis::astring>(to_copy) {}
};
class double_matrix : public matrix<double>
{
public:
- double_matrix(int rows = 0, int cols = 0, double *data = NIL)
+ double_matrix(int rows = 0, int cols = 0, double *data = NULL_POINTER)
: matrix<double>(rows, cols, data) {}
double_matrix(const matrix<double> &to_copy) : matrix<double>(to_copy) {}
};
ml_memory_record *memory_limiter::find_individual(int individual) const
{
- ml_memory_record *to_return = NIL;
- if (!_individual_sizes->find(individual, to_return)) return NIL;
+ ml_memory_record *to_return = NULL_POINTER;
+ if (!_individual_sizes->find(individual, to_return)) return NULL_POINTER;
// no record for that guy.
return to_return;
}
ml_memory_state_meter *_individual_sizes; //!< tracks memory per individual.
ml_memory_record *find_individual(int individual) const;
- //!< locates the record held for the "individual" specified or returns NIL.
+ //!< locates the record held for the "individual" specified or returns NULL_POINTER.
};
} //namespace.
to_unpack.reset();
basis::un_int len;
if (!obscure_detach(packed_form, len)) return false;
- basis::array<contents> swappy_array(len, NIL, to_unpack.flags());
+ basis::array<contents> swappy_array(len, NULL_POINTER, to_unpack.flags());
// we create an array of the specified length to see if it's tenable.
if (!swappy_array.observe()) return false; // failed to allocate.
for (int i = 0; i < (int)len; i++) {
to_unpack.reset();
basis::un_int len;
if (!obscure_detach(packed_form, len)) return false;
- basis::array<contents> swappy_array(len, NIL, to_unpack.flags());
+ basis::array<contents> swappy_array(len, NULL_POINTER, to_unpack.flags());
if (!swappy_array.observe()) return false; // failed to allocate.
for (int i = 0; i < len; i++) {
if (!detach(packed_form, swappy_array[i]))
//! Constructs a set with "num" elements, copying them from "init".
/*! Be very careful to ensure that the array "init" has sufficient length
for "num" elements to be copied from it. */
- set(int num = 0, const contents *init = NIL,
+ set(int num = 0, const contents *init = NULL_POINTER,
basis::un_short flags = basis::array<contents>::EXPONE)
: basis::array<contents>(num, init, flags) {}
template <class contents>
set<contents> set<contents>::intersection(const set &intersect_with) const
{
- set<contents> created(0, NIL, this->flags());
+ set<contents> created(0, NULL_POINTER, this->flags());
const set *smaller = this;
const set *larger = &intersect_with;
if (elements() > intersect_with.elements()) {
: c_lock(),
c_top_index(0),
c_actual_size(0),
- c_pointers(NIL),
+ c_pointers(NULL_POINTER),
c_show_debugging(false)
{
ensure_space_exists();
// could be added on the end of the list as a result of this destruction.
int zapped_index = c_top_index - 1;
gremlin_object_record *ptr = c_pointers[zapped_index];
- c_pointers[zapped_index] = NIL;
+ c_pointers[zapped_index] = NULL_POINTER;
// since we know the one we're zapping, we no longer need that index.
c_top_index--;
// this should allow us to keep chewing on items that are newly being
}
#endif
delete [] c_pointers;
- c_pointers = NIL;
+ c_pointers = NULL_POINTER;
}
bool static_memory_gremlin::__program_is_dying() { return __global_program_is_dying; }
{
auto_synchronizer l(c_lock);
int indy = locate(unique_name);
- if (negative(indy)) return NIL;
+ if (negative(indy)) return NULL_POINTER;
return c_pointers[indy]->c_object;
}
if (ptr == c_pointers[i]->c_object)
return c_pointers[i]->c_name;
}
- return NIL;
+ return NULL_POINTER;
}
bool static_memory_gremlin::put(const char *unique_name, root_object *to_put)
if (!new_ptr) {
throw "error: static_memory_gremlin::ensure_space_exists: failed to allocate memory for pointer list";
}
- for (int i = 0; i < c_actual_size; i++) new_ptr[i] = NIL;
+ for (int i = 0; i < c_actual_size; i++) new_ptr[i] = NULL_POINTER;
for (int j = 0; j < c_actual_size - SMG_CHUNKING_FACTOR; j++)
new_ptr[j] = c_pointers[j];
if (c_pointers) delete [] c_pointers;
static_memory_gremlin &static_memory_gremlin::__hoople_globals()
{
static bool _initted = false; // tells whether we've gone through yet.
- static static_memory_gremlin *_internal_gremlin = NIL;
+ static static_memory_gremlin *_internal_gremlin = NULL_POINTER;
// holds our list of shared pieces...
if (!_initted) {
basis::root_object *get(const char *unique_name);
//!< locates the pointer held for the "unique_name", if any.
- /*!< if no pointer exists, then NIL is returned. NOTE: the returned
+ /*!< if no pointer exists, then NULL_POINTER is returned. NOTE: the returned
pointer must not be destroyed, since the object could be used at any time
during the program's lifetime. */
const char *find(const basis::root_object *ptr);
//!< locates the name for "ptr" in our objects.
- /*!< if it does not exist, then NIL is returned. */
+ /*!< if it does not exist, then NULL_POINTER is returned. */
void ensure_space_exists();
/*!< makes sure that the list of objects is large enough to contain all of
__FILE__, __LINE__, true); */ \
UNIQUE_NAME_BASED_ON_SOURCE(__uid_name, linenum); \
/* program_wide_memories(); */ \
- static basis::root_object *_hidden = NIL; \
+ static basis::root_object *_hidden = NULL_POINTER; \
/* if haven't initialized yet, then definitely need to lock carefully. */ \
if (structures::static_memory_gremlin::__program_is_dying() || !_hidden) { \
basis::auto_synchronizer l(structures::static_memory_gremlin::__memory_gremlin_synchronizer()); \
public virtual basis::equalizable
{
public:
- string_array(int number = 0, const basis::astring *initial_contents = NIL)
+ string_array(int number = 0, const basis::astring *initial_contents = NULL_POINTER)
: basis::array<basis::astring>(number, initial_contents,
EXPONE | FLUSH_INVISIBLE) {}
//!< Constructs an array of "number" strings.
/*! be very careful with the array to ensure that the right number of
elements is provided. */
string_array(int number, const char *initial_contents[])
- : basis::array<basis::astring>(number, NIL, EXPONE | FLUSH_INVISIBLE) {
+ : basis::array<basis::astring>(number, NULL_POINTER, EXPONE | FLUSH_INVISIBLE) {
for (int i = 0; i < number; i++) {
put(i, basis::astring(initial_contents[i]));
}
//!< named equivalent for the bracket operator.
contents *find(const basis::astring &name) const;
- //!< returns the contents held for "name" or NIL if it wasn't found.
+ //!< returns the contents held for "name" or NULL_POINTER if it wasn't found.
contents *find(const basis::astring &name,
basis::string_comparator_function *comparator) const;
internal_symbol_indexer<contents> *_tracker; //!< indexed lookup support.
internal_symbol_info<contents> *get_index(int index) const;
- //!< returns the info item at "index" or NIL.
+ //!< returns the info item at "index" or NULL_POINTER.
};
//////////////
internal_symbol_info<contents> *symbol_table<contents>::
get_index(int index) const
{
- bounds_return(index, 0, symbols() - 1, NIL);
+ bounds_return(index, 0, symbols() - 1, NULL_POINTER);
return _tracker->find(_tracker->ids()[index])->_held;
}
{
// FUNCDEF("find [name]");
internal_symbol_info<contents> *found = _symbol_list->find(name);
- if (!found) return NIL;
+ if (!found) return NULL_POINTER;
return &found->_content;
}
contents *_found;
basis::astring _to_find;
- sym_tab_apply_data() : _scf(NIL), _found(NIL) {}
+ sym_tab_apply_data() : _scf(NULL_POINTER), _found(NULL_POINTER) {}
};
template <class contents>
* Please send any updates to: fred@gruntose.com *
*/
-#include <algorithms/shell_sort.h>
#include <application/hoople_main.h>
#include <basis/functions.h>
#include <basis/guards.h>
#include <mathematics/chaos.h>
#include <structures/static_memory_gremlin.h>
#include <unit_test/unit_base.h>
+#include <algorithms/sorts.h>
using namespace algorithms;
using namespace application;
public:
test_sorts() : application_shell() {}
DEFINE_CLASS_NAME("test_sorts");
+
+ int *populate_random_c_array(int size);
+ basis::array<int> populate_random_array(int size);
+ int test_shell_sort(int *list, int size);
+
virtual int execute();
};
-int test_sorts::execute()
+int *test_sorts::populate_random_c_array(int size)
{
- FUNCDEF("execute");
+ int *list = new int[size];
+ for (int i = 0; i < size; i++)
+ list[i] = randomizer().inclusive(0, MAX_VALUE);
+ return list;
+}
- int *list = new int[MAX_ELEMENTS];
- for (int i = 0; i < MAX_ELEMENTS; i++)
- list[i] = randomizer().inclusive(0, MAX_VALUE);
+basis::array<int> test_sorts::populate_random_array(int size)
+{
+ basis::array<int> to_return(size);
+ for (int i = 0; i < size; i++)
+ to_return[i] = randomizer().inclusive(0, MAX_VALUE);
+ return to_return;
+}
-//astring ret;
-//for (int i = 0; i < MAX_ELEMENTS; i++) ret += a_sprintf("%d ", list[i]);
-//LOG(ret);
-//LOG("-------------");
+int test_sorts::test_shell_sort(int *list, int size)
+{
+ FUNCDEF("test_shell_sort");
// check a normal sort.
- shell_sort(list, MAX_ELEMENTS);
+ shell_sort(list, size);
int last = -1;
- for (int j = 0; j < MAX_ELEMENTS; j++) {
+ for (int j = 0; j < size; j++) {
ASSERT_FALSE(list[j] < last, "ordering check - list should be ordered at first check");
last = list[j];
}
// re-randomize the list.
- for (int i = 0; i < MAX_ELEMENTS; i++)
+ for (int i = 0; i < size; i++)
list[i] = randomizer().inclusive(0, MAX_VALUE);
// check a reversed sort.
- shell_sort(list, MAX_ELEMENTS, true);
+ shell_sort(list, size, true);
last = MAX_VALUE + 100; // past the maximum we'll include in the list.
- for (int j = 0; j < MAX_ELEMENTS; j++) {
+ for (int j = 0; j < size; j++) {
ASSERT_FALSE(list[j] > last, "ordering check - list should be ordered at second check");
last = list[j];
}
// clean up now.
delete [] list;
+ //hmmm: wait, what if it fails above?
+ return true;
+}
+
+int test_sorts::execute()
+{
+ FUNCDEF("execute");
+
+ int size = MAX_ELEMENTS;
+
+//astring ret;
+//for (int i = 0; i < size; i++) ret += a_sprintf("%d ", list[i]);
+//LOG(ret);
+//LOG("-------------");
+
+ test_shell_sort(populate_random_c_array(size), size);
+
+// test_quick_sort(populate_random_list(size), size);
+
+// test_merge_sort(populate_random_array(size));
+
return final_report();
}
{
FUNCDEF("void pointer test");
const int MAX_VOID_ARRAY = 20;
- array<void *> argh(MAX_VOID_ARRAY, NIL, byte_array::SIMPLE_COPY
+ array<void *> argh(MAX_VOID_ARRAY, NULL_POINTER, byte_array::SIMPLE_COPY
| byte_array::EXPONE | byte_array::FLUSH_INVISIBLE);
array<void *> argh2(argh);
ASSERT_EQUAL(argh.length(), MAX_VOID_ARRAY, "check first array length");
test_content(abyte q = 3)
: _q(q), _ted("bl"), _jed("orp"),
- _ned(12, NIL)
+ _ned(12, NULL_POINTER)
/* _med(3, 2),
_red(2, 4) */
{
for (int c = 0; c < MAX_SIMULTANEOUS_OBJECTS; c++) {
// set up the initial array guys.
testers[c] = new array<contents>(a_randomizer.inclusive(MIN_OBJECT, MAX_OBJECT),
- NIL, flags);
+ NULL_POINTER, flags);
// copy the randomized junk space into the new object.
for (int i = 0; i < testers[c]->length(); i++)
testers[c]->put(i, junk_space[i]);
}
}
// now compute an equivalent form of what the state should be.
- array<contents> equivalent(0, NIL, flags);
+ array<contents> equivalent(0, NULL_POINTER, flags);
if (at_front) {
if (smaller) {
equivalent = old_version.subarray(difference,
old_version.length() - 1);
} else {
- array<contents> blank(difference, NIL, flags);
+ array<contents> blank(difference, NULL_POINTER, flags);
for (int i = 0; i < blank.length(); i++)
blank[i] = 'Q';
equivalent = blank + old_version;
equivalent = old_version.subarray(0, old_version.length()
- difference - 1);
} else {
- array<contents> blank(difference, NIL, flags);
+ array<contents> blank(difference, NULL_POINTER, flags);
for (int i = 0; i < blank.length(); i++)
blank[i] = 'Q';
equivalent = old_version + blank;
int start = a_randomizer.inclusive(0, testers[index]->length());
int end = a_randomizer.inclusive(0, testers[index]->length());
flip_increasing(start, end);
- array<contents> accumulator(0, NIL, flags);
+ array<contents> accumulator(0, NULL_POINTER, flags);
for (int i = start; i < end; i++) {
contents c = contents(a_randomizer.inclusive(1, 255));
testers[index]->access()[i] = c;
if (index == rand_index) continue; // skip it; try again later.
array<contents> nugwort = *testers[rand_index];
// perform a swap between two of our arrays.
- array<contents> temp_hold(0, NIL, flags);
+ array<contents> temp_hold(0, NULL_POINTER, flags);
temp_hold.snarf(*testers[index]);
testers[index]->snarf(*testers[rand_index]);
testers[rand_index]->snarf(temp_hold);
// we grab the lock.
auto_synchronizer locked(guard());
// in this case, we make use of auto-synchronizer, handily testing it as well.
- ASSERT_TRUE(&locked != NIL, "auto_synchronizer should grab the mutex object's lock");
+ ASSERT_TRUE(&locked != NULL_POINTER, "auto_synchronizer should grab the mutex object's lock");
// this is not a real test, but indicates that we did actually increase the number of
// unit tests by one, since we're using auto_synchronizer now.
safe_add(grab_lock, 1);
amorph<ethread> thread_list;
for (int i = 0; i < DEFAULT_FISH; i++) {
- ethread *t = NIL;
+ ethread *t = NULL_POINTER;
if (i % 2) t = new piranha(*this);
else t = new barracuda(*this);
thread_list.append(t);
ethread *q = thread_list[thread_list.elements() - 1];
ASSERT_EQUAL(q, t, "amorph pointer equivalence is required");
// start the thread we added.
- q->start(NIL);
+ q->start(NULL_POINTER);
}
time_stamp when_to_leave(DEFAULT_RUN_TIME);
*fred3 += *fred2;
// testing adding a null to a string.
- *fred2 += (char *)NIL;
- *fred3 += (char *)NIL;
+ *fred2 += (char *)NULL_POINTER;
+ *fred3 += (char *)NULL_POINTER;
#ifdef DEBUG_STRING_TEST
LOG(astring("[ ") + *fred1 + " & " + *fred2 + "] -> " + *fred3);
ASSERT_FALSE(chunko, "chunko whack test should succeed");
ASSERT_FALSE(alias, "aliased lorkas whack test should succeed");
ASSERT_TRUE(lorkas, "original lorkas should not have been cleared");
- lorkas = NIL;
+ lorkas = NULL_POINTER;
ASSERT_EQUAL((int)sizeof(testing_file_struct), (int)sizeof(FILE),
"struct size test, sizeof testing_file_struct and sizeof FILE should not differ");
#ifdef DEBUG_BLOWFISH
LOG(a_sprintf("blowfish thread %d starting...", left));
#endif
- _threads.add_thread(new blowfish_thread(*this), true, NIL);
+ _threads.add_thread(new blowfish_thread(*this), true, NULL_POINTER);
}
#ifdef DEBUG_BLOWFISH
FUNCDEF("execute");
int left = THREAD_COUNT;
while (left--) {
- _threads.add_thread(new rsa_thread(*this), true, NIL);
+ _threads.add_thread(new rsa_thread(*this), true, NULL_POINTER);
}
while (_threads.threads()) {
// test storing info via the constructor.
file_time absurdity_time(toppy);
FILE *topdir = fopen(toppy.s(), "r");
- ASSERT_INEQUAL(topdir, NIL, "opening topdir for testing");
- if (topdir == NIL) {
+ ASSERT_INEQUAL(topdir, NULL_POINTER, "opening topdir for testing");
+ if (topdir == NULL_POINTER) {
return 1;
}
file_time nutty_time(topdir);
class bogotre : public packable, public tree
{
public:
- bogotre(const char *start = NIL) : who_cares(42), i_sure_dont('l'),
+ bogotre(const char *start = NULL_POINTER) : who_cares(42), i_sure_dont('l'),
another_useless_int(23) {
astring to_init(start);
if (to_init.length() < 1) to_init += "ack";
void test_tree::apply(larch *apply_to, applier *to_apply,
tree::traversal_directions order)
{
- larch *curr = NIL;
+ larch *curr = NULL_POINTER;
for (traveller skippy = apply_to->start(order);
next(curr, apply_to, skippy); ) to_apply(curr);
}
using namespace basis;
using namespace structures;
-bogon::bogon(abyte *to_copy) : my_held(NIL)
+bogon::bogon(abyte *to_copy) : my_held(NULL_POINTER)
{
if (to_copy) {
astring t((char *)to_copy);
}
}
-bogon::bogon(const bogon &to_copy) : my_held(NIL) { operator = (to_copy); }
+bogon::bogon(const bogon &to_copy) : my_held(NULL_POINTER) { operator = (to_copy); }
bogon &bogon::operator = (const bogon &to_copy) {
if (this == &to_copy) return *this;
LOG("before fred creation");
chaos randomizer;
amorph<byte_array> fred(MAX_LIMBS - 1);
- fred.append(NIL); // add one to make it max limbs big.
+ fred.append(NULL_POINTER); // add one to make it max limbs big.
LOG("after append nil");
{
for (int i = 0; i < fred.elements(); i++) {
LOG("done unpacking in test_amorph");
ASSERT_TRUE(compare(fred, *new_fred), "first pack test, amorphs not the same");
abyte *cont1
- = (new_fred->get(14)? (*new_fred)[14]->access() : (abyte *)"NIL");
+ = (new_fred->get(14)? (*new_fred)[14]->access() : (abyte *)"NULL_POINTER");
abyte *cont2
- = (new_fred->get(20)? (*new_fred)[20]->access() : (abyte *)"NIL");
+ = (new_fred->get(20)? (*new_fred)[20]->access() : (abyte *)"NULL_POINTER");
abyte *cont3
- = (new_fred->get(36)? (*new_fred)[36]->access() : (abyte *)"NIL");
+ = (new_fred->get(36)? (*new_fred)[36]->access() : (abyte *)"NULL_POINTER");
if (cont1) LOG(astring(astring::SPRINTF, "14: %s", cont1));
if (cont2) LOG(astring(astring::SPRINTF, "20: %s", cont2));
//////////////
-hash_table<int, data_shuttle> *_hang_on = NIL;
+hash_table<int, data_shuttle> *_hang_on = NULL_POINTER;
// must be set before calling the apply method.
#undef UNIT_BASE_THIS_OBJECT
_hits[FIND - FIRST_TEST]++;
int rand_indy = randomizer().inclusive(0, _keys_in_use.elements() - 1);
int find_key = _keys_in_use[rand_indy];
- data_shuttle *found = NIL;
+ data_shuttle *found = NULL_POINTER;
ASSERT_TRUE(_the_table.find(find_key, found), "key should be there as expected");
- ASSERT_NON_NULL(found, "contents should not be NIL");
+ ASSERT_NON_NULL(found, "contents should not be null");
ASSERT_EQUAL(found->food_bar, find_key, "stored key should be same as real key");
ASSERT_TRUE(found->snacky_string.length(), "stored string should have length");
return true;
int rand_indy = randomizer().inclusive(0, _keys_in_use.elements() - 1);
// this is another key list invariant function, if it works.
int find_key = _keys_in_use[rand_indy];
- data_shuttle *found = NIL;
+ data_shuttle *found = NULL_POINTER;
ASSERT_TRUE(_the_table.find(find_key, found), "key should be locateable");
- ASSERT_NON_NULL(found, "key should not have NIL contents");
+ ASSERT_NON_NULL(found, "key should not have null contents");
ASSERT_EQUAL(found->food_bar, find_key, "stored key should be equal to real key");
ASSERT_TRUE(found->snacky_string.length(), "stored string should not have zero length");
// zap.
#undef UNIT_BASE_THIS_OBJECT
#define UNIT_BASE_THIS_OBJECT (*dynamic_cast<unit_base *>(application_shell::single_instance()))
-int_hash<data_shuttle> *_hang_on = NIL;
+int_hash<data_shuttle> *_hang_on = NULL_POINTER;
// must be set before calling the apply method.
bool test_int_hash::equivalence_applier(const int &key, data_shuttle &item, void *dlink)
_hits[FIND - FIRST_TEST]++;
int rand_indy = randomizer().inclusive(0, _keys_in_use.elements() - 1);
int find_key = _keys_in_use[rand_indy];
- data_shuttle *found = NIL;
+ data_shuttle *found = NULL_POINTER;
ASSERT_TRUE(_the_table.find(functional_return(find_key), found),
"key should be there when we look");
ASSERT_TRUE(_the_table.find(functional_return(find_key)), "find2: key be there when checked");
- ASSERT_TRUE(found, "when key is found contents should not be NIL");
+ ASSERT_TRUE(found, "when key is found contents should not be null");
ASSERT_EQUAL(found->food_bar, find_key, "stored key should be same as real key");
ASSERT_TRUE(found->snacky_string.length(), "stored string should have some length");
return true;
int rand_indy = randomizer().inclusive(0, _keys_in_use.elements() - 1);
// this is another key list invariant function, if it works.
int find_key = _keys_in_use[rand_indy];
- data_shuttle *found = NIL;
+ data_shuttle *found = NULL_POINTER;
ASSERT_TRUE(_the_table.find(find_key, found), "key should be there when sought");
ASSERT_TRUE(_the_table.find(find_key), "find2: key should be there for us to find");
- ASSERT_TRUE(found, "found key should have non-NIL contents");
+ ASSERT_TRUE(found, "found key should have non-null contents");
ASSERT_EQUAL(found->food_bar, find_key, "stored key should have no differences from real key");
ASSERT_TRUE(found->snacky_string.length(), "stored string should have non-zero length");
// zap.
byte_array string_manipulation::string_to_hex(const astring &to_convert)
{
- byte_array to_return(0, NIL);
+ byte_array to_return(0, NULL_POINTER);
for (int i = 0; i < to_convert.length() / 2; i++) {
int str_index = i * 2;
abyte first_byte = char_to_hex(to_convert.get(str_index));
#if defined(__UNIX__) || defined(__GNU_WINDOWS__)
_prompter(new signalling_thread(INITIAL_TIMER_GRANULARITY)),
#else
- _real_timer_id(NIL),
+ _real_timer_id(NULL_POINTER),
#endif
_in_timer(false)
{
#ifdef __UNIX__
// register for the our personal signal.
signal(OUR_SIGNAL, &timer_driver_private_handler);
- _prompter->start(NIL);
+ _prompter->start(NULL_POINTER);
#endif
}
struct sigaction action;
action.sa_handler = SIG_DFL;
- action.sa_sigaction = NIL;
+ action.sa_sigaction = NULL_POINTER;
sigemptyset(&action.sa_mask);
action.sa_flags = 0;
#ifndef __APPLE__
- action.sa_restorer = NIL;
+ action.sa_restorer = NULL_POINTER;
#endif
- int ret = sigaction(OUR_SIGNAL, &action, NIL);
+ int ret = sigaction(OUR_SIGNAL, &action, NULL_POINTER);
if (ret) {
///uhhh
}
#elif defined(_MSC_VER)
int max_tries_left = 100;
while (max_tries_left-- >= 0) {
- _real_timer_id = (basis::un_int *)SetTimer(NIL, 0, duration,
+ _real_timer_id = (basis::un_int *)SetTimer(NULL_POINTER, 0, duration,
timer_driver_private_handler);
if (!_real_timer_id) {
// failure to set the timer.
// postpone the thread for quite a while so we can take care of business.
_prompter->reschedule(LONG_TIME);
#elif defined(_MSC_VER)
- if (_real_timer_id) KillTimer(NIL, (UINT_PTR)_real_timer_id);
+ if (_real_timer_id) KillTimer(NULL_POINTER, (UINT_PTR)_real_timer_id);
#endif
#ifdef DEBUG_TIMER_DRIVER
LOG("unhooked OS timer.");
#if defined(_MSC_VER)
return GetModuleHandle(to_unicode_temp(library_file_name));
#else
- if (library_file_name.t()) return NIL; else return NIL;
+ if (library_file_name.t()) return NULL_POINTER; else return NULL_POINTER;
#endif
}
#endif
- byte_array version_info_found(0, NIL);
+ byte_array version_info_found(0, NULL_POINTER);
if (!retrieve_version_info(filename, version_info_found))
return version(0, 0, 0, 0);
version_record &to_fill)
{
to_fill = version_record();
- byte_array version_info_found(0, NIL);
+ byte_array version_info_found(0, NULL_POINTER);
if (!retrieve_version_info(filename, version_info_found))
return false;
* Please send any updates to: fred@gruntose.com *
\*****************************************************************************/
-#include <algorithms/shell_sort.h>
#include <application/application_shell.h>
#include <application/command_line.h>
#include <application/hoople_main.h>
#include <textual/parser_bits.h>
#include <sys/stat.h>
+
+#include "../../library/algorithms/sorts.h"
#ifdef __WIN32__
#include <io.h>
#endif
{
public:
search_record(const astring &search = astring::empty_string(),
- bool is_link = false, search_record *link = NIL)
+ bool is_link = false, search_record *link = NULL_POINTER)
: _search(search), _no_modify(false), _is_link(is_link), _our_link(link),
_current_value(0), _value_increment(1) {}
value_tagger::value_tagger()
: application_shell(),
- _ini(NIL),
+ _ini(NULL_POINTER),
_dirs_seen(10)
{
}
{
// check for whether this section is linked to another or not.
astring linked = _ini->load(curr_name, "link", "");
- search_record *our_link_found = NIL;
+ search_record *our_link_found = NULL_POINTER;
if (linked.t()) {
// we found that this should be linked to another item.
our_link_found = _search_list.find(linked);
for (int i = 1; i < argc; i++) {
// out.log(astring(astring::SPRINTF, "soundfile %d: %s", i, argv[i]));
#ifdef _MSC_VER
- if (!PlaySound(to_unicode_temp(argv[i]), NIL, SND_FILENAME))
+ if (!PlaySound(to_unicode_temp(argv[i]), NULL_POINTER, SND_FILENAME))
out.log(astring("failed to play ") + argv[i], ALWAYS_PRINT);
#else
out.log(astring("this program is a NO-OP, ignoring ") + argv[i], ALWAYS_PRINT);
find_missing::find_missing()
: application_shell(),
_saw_clients(false),
- _server_side(NIL),
- _client_side(NIL),
+ _server_side(NULL_POINTER),
+ _client_side(NULL_POINTER),
_leave_when_no_clients(false),
_encryption(false),
_started_okay(false)
non_continuable_error(class_name(), func, astring("failed to initiate "
" the transfer: ") + cromp_client::outcome_name(start_ret));
- infoton *start_reply_tmp = NIL;
+ infoton *start_reply_tmp = NULL_POINTER;
//hmmm: set timeout appropriate to the speed of the connection!
outcome first_receipt = _client_side->acquire(start_reply_tmp, cmd_id);
if (first_receipt != cromp_client::OKAY)
transporter::transporter()
: application_shell(),
_saw_clients(false),
- _server_side(NIL),
- _client_side(NIL),
+ _server_side(NULL_POINTER),
+ _client_side(NULL_POINTER),
_leave_when_no_clients(false),
_encryption(false),
_started_okay(false)
non_continuable_error(class_name(), func, astring("failed to initiate "
" the transfer: ") + cromp_client::outcome_name(start_ret));
- infoton *start_reply_tmp = NIL;
+ infoton *start_reply_tmp = NULL_POINTER;
//hmmm: set timeout appropriate to the speed of the connection!
outcome first_receipt = _client_side->acquire(start_reply_tmp, cmd_id);
if (first_receipt != cromp_client::OKAY)
non_continuable_error(class_name(), func, astring("failed to send ongoing "
"chunk: ") + cromp_client::outcome_name(place_ret));
- infoton *place_reply_tmp = NIL;
+ infoton *place_reply_tmp = NULL_POINTER;
//hmmm: set timeout appropriate to the speed of the connection!
outcome place_receipt = _client_side->acquire(place_reply_tmp, cmd_id);
if (place_receipt != cromp_client::OKAY)
_identified(false),
_authorized(false),
_disallowed(false),
- _asynch_connector(NIL),
+ _asynch_connector(NULL_POINTER),
_channel_secured(false),
_crypto(new blowfish_crypto(encryption_infoton::BLOWFISH_KEY_SIZE)),
- _encrypt_arm(NIL),
+ _encrypt_arm(NULL_POINTER),
_guardian(new blank_entity_registry),
c_verification(new byte_array)
{
octopus_entity cromp_client::randomize_entity() const
{
astring host = cromp_common::chew_hostname(internet_address
- (byte_array::empty_array(), _hidden_stack().hostname(), 0), NIL);
+ (byte_array::empty_array(), _hidden_stack().hostname(), 0), NULL_POINTER);
chaos randomizer;
return octopus_entity(host, application_configuration::process_id(),
randomizer.inclusive(0, MAXINT32 / 3),
int timeout)
{
FUNCDEF("synchronous_request");
- received = NIL;
+ received = NULL_POINTER;
outcome ret = submit(to_send, item_id);
if (ret != OKAY) {
LOG(astring("failed to submit request: ") + outcome_name(ret) + " on " + to_send.text_form());
_disallowed = true;
_asynch_connector = new asynch_connection_thread(*this);
}
- _asynch_connector->start(NIL);
+ _asynch_connector->start(NULL_POINTER);
//#ifdef DEBUG_CROMP_CLIENT
LOG(instance_name() + " exit.");
//#endif
LOG("failed to fast_unpack the transformed data.");
to_return = ENCRYPTION_MISMATCH; // what else would we call that?
} else {
- infoton *new_req = NIL;
+ infoton *new_req = NULL_POINTER;
outcome rest_ret = octo()->restore(classif, decro, new_req);
if (rest_ret == tentacle::OKAY) {
// we got a good transformed version.
}
cromp_common::cromp_common(const astring &host, int max_per_ent)
-: _commlink(NIL),
+: _commlink(NULL_POINTER),
_octopus(new octopus(host, max_per_ent)),
- _singleton(NIL),
+ _singleton(NULL_POINTER),
_requests(new entity_data_bin(max_per_ent)),
_accum_lock(new mutex),
_last_data_seen(new time_stamp),
- _accumulator(new byte_array(CROMP_BUFFER_CHUNK_SIZE, NIL)),
- _sendings(new byte_array(CROMP_BUFFER_CHUNK_SIZE, NIL)),
- _receive_buffer(new byte_array(CROMP_BUFFER_CHUNK_SIZE, NIL)),
- _still_flat(new byte_array(CROMP_BUFFER_CHUNK_SIZE, NIL)),
+ _accumulator(new byte_array(CROMP_BUFFER_CHUNK_SIZE, NULL_POINTER)),
+ _sendings(new byte_array(CROMP_BUFFER_CHUNK_SIZE, NULL_POINTER)),
+ _receive_buffer(new byte_array(CROMP_BUFFER_CHUNK_SIZE, NULL_POINTER)),
+ _still_flat(new byte_array(CROMP_BUFFER_CHUNK_SIZE, NULL_POINTER)),
_last_cleanup(new time_stamp)
{
FUNCDEF("constructor [host/max_per_ent]");
: DEFAULT_MAX_ENTITY_QUEUE)),
_accum_lock(new mutex),
_last_data_seen(new time_stamp),
- _accumulator(new byte_array(CROMP_BUFFER_CHUNK_SIZE, NIL)),
- _sendings(new byte_array(CROMP_BUFFER_CHUNK_SIZE, NIL)),
- _receive_buffer(new byte_array(CROMP_BUFFER_CHUNK_SIZE, NIL)),
- _still_flat(new byte_array(CROMP_BUFFER_CHUNK_SIZE, NIL)),
+ _accumulator(new byte_array(CROMP_BUFFER_CHUNK_SIZE, NULL_POINTER)),
+ _sendings(new byte_array(CROMP_BUFFER_CHUNK_SIZE, NULL_POINTER)),
+ _receive_buffer(new byte_array(CROMP_BUFFER_CHUNK_SIZE, NULL_POINTER)),
+ _still_flat(new byte_array(CROMP_BUFFER_CHUNK_SIZE, NULL_POINTER)),
_last_cleanup(new time_stamp)
{
FUNCDEF("constructor [preexisting/singleton]");
if (!_octopus) {
// they passed us a bad singleton. carry on as best we can.
- LOG("singleton passed as NIL; constructing new octopus instead.");
+ LOG("singleton passed as NULL_POINTER; constructing new octopus instead.");
internet_address local(internet_address::localhost(), "localhost", 0);
_octopus = new octopus(chew_hostname(local), DEFAULT_MAX_ENTITY_QUEUE);
}
FUNCDEF("destructor");
close_common(); // shuts down our socket and other stuff.
if (_singleton) {
- _singleton = NIL; // reset the pointer we had.
- _octopus = NIL; // ditto.
+ _singleton = NULL_POINTER; // reset the pointer we had.
+ _octopus = NULL_POINTER; // ditto.
} else {
// this one was ours so we need to clean it up.
WHACK(_octopus);
infoton * &item, octopus_request_id &req_id, int timeout)
{
FUNCDEF("retrieve_and_restore_root");
- item = NIL;
+ item = NULL_POINTER;
if (!_commlink) return BAD_INPUT; // they haven't opened this yet.
octopus_request_id tmp_id;
time_stamp leaving_time(timeout);
void cromp_common::process_accumulator()
{
FUNCDEF("process_accumulator");
- infoton *item = NIL;
+ infoton *item = NULL_POINTER;
octopus_request_id req_id;
string_array clas;
if (!_accumulator->length()) return;
// a little gymnastics to get a large buffer on the first try.
- byte_array temp_chow_buffer(CROMP_BUFFER_CHUNK_SIZE, NIL);
+ byte_array temp_chow_buffer(CROMP_BUFFER_CHUNK_SIZE, NULL_POINTER);
temp_chow_buffer.reset();
int cmds_found = 0;
// the "singleton" octopus is used instead of our base class for restoring
// any data. note that "singleton" is not dealt with in the destructor;
// it is considered owned externally. however, the "preexisting" spocket
- // is considered to be owned by this class now. also note that if a NIL
+ // is considered to be owned by this class now. also note that if a NULL_POINTER
// "preexisting" socket is passed, then socket creation occurs by the
// normal process.
sockets::spocket *spock() const;
// allows external access to our socket object. do not abuse this.
// also keep in mind that in some stages of construction, this can return
- // NIL. do not assume it is non-NIL.
+ // NULL_POINTER. do not assume it is non-null.
sockets::internet_address other_side() const;
// returns the location that we're connected to, if any.
static const char *outcome_name(const basis::outcome &to_name);
static basis::astring chew_hostname(const sockets::internet_address &addr,
- sockets::internet_address *resolved = NIL);
+ sockets::internet_address *resolved = NULL_POINTER);
// resolves the hostname in "addr" and returns the resolved hostname as
// a machine_uid compact_form(). the "resolved" form of the address is
- // also stored if the pointer is non-NIL.
+ // also stored if the pointer is non-null.
basis::astring responses_text_form() const;
// returns a textual form of the responses awaiting pickup.
protected:
octopi::octopus *singleton() const { return _singleton; }
// returns the singleton octopus passed to the constructor earlier.
- // this will return NIL if it was not constructed that way.
+ // this will return NULL_POINTER if it was not constructed that way.
private:
sockets::spocket *_commlink; // transceiver for data.
internet_address local_addr = internet_address
(internet_address::localhost(), client->stack().hostname(), 0);
open_common(local_addr); // open the common support for biz.
- _grabber.start(NIL); // crank up our background data pump on the socket.
+ _grabber.start(NULL_POINTER); // crank up our background data pump on the socket.
}
~cromp_client_record() {
bool saw_something = false; // true if we got a packet.
while (actions++ < MAXIMUM_ACTIONS_PER_CLIENT) {
// pull in anything waiting.
- infoton *item = NIL;
+ infoton *item = NULL_POINTER;
octopus_request_id req_id;
outcome ret = retrieve_and_restore_any(item, req_id,
first_one? DATA_AWAIT_TIMEOUT : 0);
_accepting_threads(accepting_threads),
_dropper(new client_dropping_thread(*this)),
_enabled(false),
- _encrypt_arm(NIL),
+ _encrypt_arm(NULL_POINTER),
_default_security(new cromp_security),
- _security_arm(NIL)
+ _security_arm(NULL_POINTER)
{
FUNCDEF("constructor");
}
WHACK(_where);
WHACK(_default_security);
WHACK(_list_lock);
- _encrypt_arm = NIL;
- _security_arm = NIL;
+ _encrypt_arm = NULL_POINTER;
+ _security_arm = NULL_POINTER;
}
internet_address cromp_server::location() const { return *_where; }
const octopus_entity &ent)
{
FUNCDEF("wrap_infoton");
- if (!_enabled) return NIL;
+ if (!_enabled) return NULL_POINTER;
// identity is not wrapped with encryption; we need to establish and identity
// to talk on a distinct channel with the server. even if that identity were
// compromised, the interloper should still not be able to listen in on the
// itself is not encrypted and we don't want to re-encrypt the wrapper.
if (dynamic_cast<identity_infoton *>(request)
|| dynamic_cast<encryption_infoton *>(request)
- || dynamic_cast<encryption_wrapper *>(request)) return NIL;
+ || dynamic_cast<encryption_wrapper *>(request)) return NULL_POINTER;
#ifdef DEBUG_CROMP_SERVER
LOG(astring("encrypting ") + request->text_form());
// lock here is released a bit down below.
if (!key) {
LOG(astring("failed to locate key for entity ") + ent.text_form());
- return NIL;
+ return NULL_POINTER;
}
byte_array packed_request;
infoton::fast_pack(packed_request, *request);
#endif
for (int i = 0; i < _accepting_threads; i++) {
// crank in a new thread and tell it yes on starting it.
- _accepters->add_thread(new connection_management_thread(*this), true, NIL);
+ _accepters->add_thread(new connection_management_thread(*this), true, NULL_POINTER);
}
- _dropper->start(NIL);
+ _dropper->start(NULL_POINTER);
return OKAY;
}
FUNCDEF("accept_one_client");
#endif
if (!_enabled) return common::INCOMPLETE;
- spocket *accepted = NIL;
+ spocket *accepted = NULL_POINTER;
//printf((timestamp(true, true) + "into accept\n").s());
outcome ret = spock()->accept(accepted, wait);
//printf((timestamp(true, true) + "out of accept\n").s());
bool enabled() const { return _enabled; }
// reports whether this server has been cranked up or not yet.
- basis::outcome enable_servers(bool encrypt, cromp_security *security = NIL);
+ basis::outcome enable_servers(bool encrypt, cromp_security *security = NULL_POINTER);
// this must be called after construction to start up the object before it
// will accept client requests. if "encrypt" is on, then packets will
// be encrypted and no unencrypted packets will be allowed. if the
- // "security" is passed as NIL, then a default security manager is created
+ // "security" is passed as NULL_POINTER, then a default security manager is created
// and used. otherwise, the specified "security" object is used and will
// _not_ be destroyed when this object goes away.
octopi::infoton *wrap_infoton(octopi::infoton * &request, const octopi::octopus_entity &ent);
// when we're encrypting, this turns "request" into an encryption_wrapper.
- // if NIL is returned, then nothing needed to happen to the "request".
+ // if NULL_POINTER is returned, then nothing needed to happen to the "request".
private:
cromp_client_list *_clients; // the active set of clients.
time_stamp _when_added; // when the data became available.
infoton_holder(const octopus_request_id &id = octopus_request_id(),
- infoton *item = NIL)
+ infoton *item = NULL_POINTER)
: _item(item), _id(id), _when_added() {}
~infoton_holder() { WHACK(_item); }
int _decay_interval; // how long are items allowed to live?
apply_struct(int &items_held)
- : _empty_baskets(NIL), _any_item(NIL), _items_held(items_held),
+ : _empty_baskets(NULL_POINTER), _any_item(NULL_POINTER), _items_held(items_held),
_decay_interval(0) {}
};
GRAB_LOCK;
apply_struct apple(_items_held);
_table->apply(any_item_applier, &apple);
- if (!apple._any_item) return NIL;
+ if (!apple._any_item) return NULL_POINTER;
DUMP_STATE;
// retrieve the information from our basket that was provided.
infoton_holder *found = apple._any_item->acquire(0);
#endif
_table->zap(found->_id._entity);
}
- apple._any_item = NIL;
+ apple._any_item = NULL_POINTER;
infoton *to_return = found->_item;
id = found->_id;
- found->_item = NIL; // clear so it won't be whacked.
+ found->_item = NULL_POINTER; // clear so it won't be whacked.
WHACK(found);
_items_held--;
//#ifdef DEBUG_ENTITY_DATA_BIN
FUNCDEF("acquire_for_entity [single]");
id = octopus_request_id(); // reset it.
GRAB_LOCK;
- infoton *to_return = NIL;
+ infoton *to_return = NULL_POINTER;
entity_basket *bask = _table->find(requester);
if (!bask) {
- return NIL;
+ return NULL_POINTER;
}
if (!bask->elements()) {
#ifdef DEBUG_ENTITY_DATA_BIN
LOG(astring("tossing empty basket ") + requester.mangled_form());
#endif
_table->zap(requester);
- return NIL;
+ return NULL_POINTER;
}
DUMP_STATE;
id = bask->get(0)->_id;
to_return = bask->borrow(0)->_item;
- bask->borrow(0)->_item = NIL;
+ bask->borrow(0)->_item = NULL_POINTER;
bask->zap(0, 0);
if (!bask->elements()) {
#ifdef DEBUG_ENTITY_DATA_BIN
infoton *entity_data_bin::acquire_for_identifier(const octopus_request_id &id)
{
FUNCDEF("acquire_for_identifier");
- infoton *to_return = NIL;
+ infoton *to_return = NULL_POINTER;
GRAB_LOCK;
entity_basket *bask = _table->find(id._entity);
- if (!bask) return NIL;
+ if (!bask) return NULL_POINTER;
if (!bask->elements()) {
#ifdef DEBUG_ENTITY_DATA_BIN
LOG(astring("tossing empty basket ") + id._entity.mangled_form());
#endif
_table->zap(id._entity);
- return NIL;
+ return NULL_POINTER;
}
for (int i = 0; i < bask->elements(); i++) {
if (bask->get(i)->_id == id) {
to_return = bask->borrow(i)->_item; // snag the item.
- bask->borrow(i)->_item = NIL; // clear the list's version out.
+ bask->borrow(i)->_item = NULL_POINTER; // clear the list's version out.
bask->zap(i, i); // whack the sanitized element.
DUMP_STATE;
if (!bask->elements()) {
return to_return;
}
}
- return NIL;
+ return NULL_POINTER;
}
bool cleaning_applier(const octopus_entity &key, entity_basket &bask,
infoton *acquire_for_identifier(const octopus_request_id &id);
// locates an item for the specific "id". this will generally be a
// response to a previous request. if no object can be found that matches
- // the "id", then NIL is returned.
+ // the "id", then NULL_POINTER is returned.
infoton *acquire_for_entity(const octopus_entity &requester,
octopus_request_id &id);
// this function repeatedly to ensure that all available items have
// been provided. the "original_id" is a copy of the "item_id" that was
// originally passed to evaluate_request(). the returned object must
- // eventually be destroyed if non-NIL.
+ // eventually be destroyed if non-null.
int acquire_for_entity(const octopus_entity &requester,
infoton_list &items, int maximum_size);
infoton *acquire_for_any(octopus_request_id &id);
// acquires an infoton for any random entity. if no items are ready at
- // all, then NIL is returned.
+ // all, then NULL_POINTER is returned.
basis::astring text_form() const;
// returns a textual list of what's held here.
~infoton_id_pair() {
delete _data;
- _data = NIL;
+ _data = NULL_POINTER;
}
};
return NO_HANDLER;
return reconstituter(classifier, packed_form, reformed,
- (identity_infoton *)NIL);
+ (identity_infoton *)NULL_POINTER);
}
outcome identity_tentacle::consume(infoton &to_chow,
tentacle *find(const string_array &group) {
int indy = find_index(group);
- if (negative(indy)) return NIL;
+ if (negative(indy)) return NULL_POINTER;
return borrow(indy)->_limb;
}
void octopus::unlock_tentacle(tentacle *to_unlock)
{
- to_unlock = NIL;
+ to_unlock = NULL_POINTER;
_molock->unlock();
}
outcome octopus::zap_tentacle(const string_array &tentacle_name)
{
- tentacle *found = NIL;
+ tentacle *found = NULL_POINTER;
outcome ret = remove_tentacle(tentacle_name, found);
WHACK(found);
return ret;
}
GRAB_LOCK;
tentacle *found = _tentacles->find(to_add->group());
- // if found is non-NIL, then that would be a serious logic error since
+ // if found is non-null, then that would be a serious logic error since
// we just zapped it above.
if (found) return tentacle::ALREADY_EXISTS;
to_add->attach_storage(*_responses);
tentacle * &free_me)
{
FUNCDEF("remove_tentacle");
- free_me = NIL;
+ free_me = NULL_POINTER;
if (!group_name.length()) return tentacle::BAD_INPUT;
while (true) {
// repeatedly grab the lock and make sure we're allowed to remove. if
free_me = freeing->_limb;
_filters->remove(free_me);
_molock->unlock();
- freeing->_limb = NIL;
+ freeing->_limb = NULL_POINTER;
WHACK(freeing);
return tentacle::OKAY;
}
#endif
periodic_cleaning(); // freshen up if it's that time.
- reformed = NIL;
+ reformed = NULL_POINTER;
if (!classifier.length()) return tentacle::BAD_INPUT;
if (!packed_form.length()) return tentacle::BAD_INPUT;
if (!classifier.length()) return tentacle::BAD_INPUT;
if (!worked) {
LOG("failed to fast_unpack the transformed data.");
} else {
- infoton *new_req = NIL;
+ infoton *new_req = NULL_POINTER;
outcome rest_ret = restore(classif, decro, new_req);
if (rest_ret == tentacle::OKAY) {
// we got a good transformed version.
tentacle *octopus::lock_tentacle(const string_array &tentacle_name)
{
- if (!tentacle_name.length()) return NIL;
+ if (!tentacle_name.length()) return NULL_POINTER;
_molock->lock();
tentacle *found = _tentacles->find(tentacle_name);
if (!found) {
_molock->unlock();
- return NIL;
+ return NULL_POINTER;
}
return found;
}
call this function repeatedly to ensure that all responses have been
provided. the "original_id" is a copy of the "item_id" that was
originally passed to evaluate_request(). the returned object must
- eventually be destroyed if non-NIL. */
+ eventually be destroyed if non-null. */
infoton *acquire_specific_result(const octopus_request_id &original_id);
//!< supports seeking the result for a specific request.
/*!< either the infoton that is a response to "original_id" will be
- returned or NIL. */
+ returned or NULL_POINTER. */
//////////////
: _group(new string_array(group_name)),
_pending(new queueton),
_input_guard(new mutex),
- _action(NIL),
- _products(NIL),
+ _action(NULL_POINTER),
+ _products(NULL_POINTER),
_backgrounded(backgrounded)
{
// we only start the thread if they've said they'll support backgrounding.
void tentacle::attach_storage(entity_data_bin &storage)
{
_products = &storage;
- if (_action) _action->start(NIL);
+ if (_action) _action->start(NULL_POINTER);
}
void tentacle::detach_storage()
{
if (_action) _action->stop();
- _products = NIL;
+ _products = NULL_POINTER;
}
bool tentacle::store_product(infoton *product,
infoton *tentacle::next_request(octopus_request_id &item_id)
{
GRAB_CONSUMER_LOCK;
- if (!_pending->elements()) return NIL; // nothing to return.
+ if (!_pending->elements()) return NULL_POINTER; // nothing to return.
infoton *to_return = (*_pending)[0]->_product;
- (*_pending)[0]->_product = NIL;
+ (*_pending)[0]->_product = NULL_POINTER;
// clean out so destructor doesn't delete the object.
item_id = (*_pending)[0]->_id;
_pending->zap(0, 0);
void tentacle::propel_arm()
{
FUNCDEF("propel_arm");
- infoton *next_item = NIL;
+ infoton *next_item = NULL_POINTER;
do {
octopus_request_id id;
next_item = next_request(id);
/*!< this function locates the next request for the tentacle when it is
in its consume() method. the returned infoton was previously passed
to the enqueue() method and needs to be processed. if there are no
- requests ready, NIL is returned. */
+ requests ready, NULL_POINTER is returned. */
bool store_product(infoton *product, const octopus_request_id &original_id);
//!< used by tentacles to store the objects they produce from infotons.
//!< reconstituter should work for most infotons to restore flattened infotons.
/*!< the infotons that can be used here just need valid default constructor
and unpack methods. the "junk" parameter is needed to allow the template to
-be disambiguated on some compilers--it is unused and should just be NIL. */
+be disambiguated on some compilers--it is unused and should just be NULL_POINTER. */
template <class contents>
basis::outcome reconstituter(const structures::string_array &classifier,
basis::byte_array &packed_form,
virtual basis::outcome reconstitute(const structures::string_array &classifier,
basis::byte_array &packed_form, infoton * &reformed) {
return reconstituter(classifier, packed_form, reformed,
- (contents *)NIL);
+ (contents *)NULL_POINTER);
}
//! consume is not really provided here. remember to implement for servers!
+ a_sprintf(" reason=%d", _reason.value()));
}
-const char *initter[] = { "__Unhandled__", NIL };
+const char *initter[] = { "__Unhandled__", NULL_POINTER };
string_array unhandled_request::the_classifier()
{ return string_array(1, initter); }
ip_form += (abyte)nTemp;
// get the next part of the string
- p = strtok(NIL, ".");
+ p = strtok(NULL_POINTER, ".");
}
// if p is non-null, there was extra stuff at the end, so return false.
// select will tell us about the socket.
int ret = ::select(socket + 1,
- (mode & SELECTING_JUST_WRITE)? NIL : &read_list,
- (mode & SELECTING_JUST_READ)? NIL : &write_list,
+ (mode & SELECTING_JUST_WRITE)? NULL_POINTER : &read_list,
+ (mode & SELECTING_JUST_READ)? NULL_POINTER : &write_list,
&exceptions, time_out);
int error = critical_events::system_error();
if (!ret) return 0; // nothing to report.
// select will tell us about the socket.
int ret = ::select(highest + 1,
- (read_sox.length())? &read_list : NIL,
- (write_sox.length())? &write_list : NIL,
+ (read_sox.length())? &read_list : NULL_POINTER,
+ (write_sox.length())? &write_list : NULL_POINTER,
&exceptions, time_out);
int error = critical_events::system_error();
: ethread(SOCKET_CHECK_INTERVAL, ethread::SLACK_INTERVAL),
_parent(parent)
{
- start(NIL);
+ start(NULL_POINTER);
}
~socket_minder_prompter() {
_pending_sox(new int_set),
_prompter(new socket_minder_prompter(*this))
{
- _prompter->start(NIL);
+ _prompter->start(NULL_POINTER);
}
socket_minder::~socket_minder()
return _socket_list->borrow(i);
// this is a failure to get here; there was no suitable socket.
_lock->unlock();
- return NIL;
+ return NULL_POINTER;
}
void socket_minder::unlock_socket_data(socket_data *to_unlock)
{
if (!to_unlock) return;
-//can't affect it now. to_unlock = NIL;
+//can't affect it now. to_unlock = NULL_POINTER;
_lock->unlock();
}
socket_data *lock_socket_data(int socket);
// locates the data for the "socket" specified. the list is left locked
- // unless NIL is returned.
+ // unless NULL_POINTER is returned.
void unlock_socket_data(socket_data *to_unlock);
// unlocks the list of socket data again and zeroes "to_unlock".
//moving to always re-resolving before a connect. otherwise we have somewhat
//hard to predict behavior about when the re-resolve will happen.
) {
- // we know we need to resolve if the address is NIL or if the re-resolve
+ // we know we need to resolve if the address is NULL_POINTER or if the re-resolve
// interval has elapsed.
astring full_host;
byte_array ip_addr = _stack->full_resolve(_where->hostname, full_host);
// we don't lock in here; we should not be locking on the server socket.
- sock = NIL; // reset.
+ sock = NULL_POINTER; // reset.
if (_socket) {
#ifdef DEBUG_SPOCKET
// server spocket but which does not allow any normal sending or receiving.
// only root servers can have accept called on them. the "sock" will be
// a normal server spocket which can be used to send and receive if it
- // got connected. for "sock" to be valid, it must not be returned as NIL
+ // got connected. for "sock" to be valid, it must return as NULL_POINTER
// and the returned outcome must be OKAY. if no new connections are
// available, then NO_CONNECTION is returned. if the "wait" flag is true,
// then the accept on the root server will block until a connection is
{
GRAB_LOCK;
int indy = locked_find(classifier);
- if (negative(indy)) return NIL;
+ if (negative(indy)) return NULL_POINTER;
return dynamic_cast<synchronizable *>(_entries->get(indy)->clone());
}
// microseconds.
synchronizable *clone_object(const structures::string_array &classifier);
- // returns a clone of the object listed for "classifier" or NIL if there
- // are none matching. the returned object must be destroyed if non-NIL.
+ // returns a clone of the object listed for "classifier" or NULL_POINTER if there
+ // are none matching. the returned object must be destroyed if non-null.
bool zap(const structures::string_array &classifier);
// returns true if we were able to find and remove the item held under
(encryption_infoton::encryption_classifier(), false),
_server_side(true),
_keys(new key_repository),
- _rsa_private(NIL)
+ _rsa_private(NULL_POINTER)
{
}
return NO_HANDLER;
return reconstituter(classifier, packed_form, reformed,
- (encryption_infoton *)NIL);
+ (encryption_infoton *)NULL_POINTER);
}
void encryption_tentacle::expunge(const octopus_entity &formal(to_remove))
return NO_HANDLER;
return reconstituter(classifier, packed_form, reformed,
- (encryption_wrapper *)NIL);
+ (encryption_wrapper *)NULL_POINTER);
}
outcome unwrapping_tentacle::consume(infoton &formal(to_chow),
astring _source_mapping; // valid for a correspondence record.
int _refresh_interval; // the rate of refreshing the source tree.
- file_transfer_record() : _diffs(NIL), _last_sent(file_time()),
- _done(false), _local_dir(NIL)
+ file_transfer_record() : _diffs(NULL_POINTER), _last_sent(file_time()),
+ _done(false), _local_dir(NULL_POINTER)
{}
~file_transfer_record() {
return borrow(i);
}
}
- return NIL;
+ return NULL_POINTER;
}
virtual ~file_transfer_status() {}
if (rec && (rec->_source_mapping == source_mapping) )
return borrow(i);
}
- return NIL;
+ return NULL_POINTER;
}
// turns a source mapping into the location that it corresponds to.
_cleaner(new file_transfer_cleaner(*this)),
_mode(mode_of_transfer)
{
- _cleaner->start(NIL);
+ _cleaner->start(NULL_POINTER);
}
file_transfer_tentacle::~file_transfer_tentacle()
file_transfer_record *the_rec = _correspondences->find_mapping(key);
if (!the_rec || !the_rec->_local_dir) {
_lock->unlock();
- return NIL; // unknown transfer.
+ return NULL_POINTER; // unknown transfer.
}
return the_rec->_local_dir;
}
if (classifier != file_transfer_infoton::file_transfer_classifier())
return NO_HANDLER;
return reconstituter(classifier, packed_form, reformed,
- (file_transfer_infoton *)NIL);
+ (file_transfer_infoton *)NULL_POINTER);
}
// the "handle_" and "conclude_" methods are thread-safe because the mutex is locked before
FUNCDEF("lock");
LOG(astring("entity sought=") + ent.text_form());
#endif
- octenc_key_record *to_return = NIL;
+ octenc_key_record *to_return = NULL_POINTER;
_locker.lock();
to_return = _keys.find(ent.mangled_form());
if (!to_return) {
octenc_key_record *lock(const octopus_entity &ent);
//!< locates the key for "ent", if it's stored.
- /*!< the returned object, unless it's NIL, must be unlocked. */
+ /*!< the returned object, unless it's NULL_POINTER, must be unlocked. */
void unlock(octenc_key_record *to_unlock);
//!< drops the lock on the key record in "to_unlock".
return NO_HANDLER;
return reconstituter(classifier, packed_form, reformed,
- (security_infoton *)NIL);
+ (security_infoton *)NULL_POINTER);
}
void login_tentacle::expunge(const octopus_entity &to_remove)
if (! (i % 50) ) {
printf("^");
- fflush(NIL);
+ fflush(NULL_POINTER);
}
}
program_wide_logger().get().eol(parser_bits::CRLF_AT_END);
items_seen++;
if (! (items_seen % 50) ) {
printf("v");
- fflush(NIL);
+ fflush(NULL_POINTER);
}
bool saw_it = false;
for (int q = 0; q < item_list.length(); q++) {
items_seen++;
if (! (items_seen % 50) ) {
printf("v");
- fflush(NIL);
+ fflush(NULL_POINTER);
}
bool saw_it = false;
for (int q = 0; q < item_list.length(); q++) {
items_seen++;
if (! (items_seen % 50) ) {
printf("v");
- fflush(NIL);
+ fflush(NULL_POINTER);
}
item_list.zap(j, j);
j--; // skip back.
amorph<ethread> thread_list;
for (int i = 0; i < DEFAULT_THREADS; i++) {
- ethread *t = NIL;
+ ethread *t = NULL_POINTER;
if (i == DEFAULT_THREADS - 1) {
// last item gets special treatment; we reserve this space for monk.
t = new monk_the_detective;
if (q != t)
deadly_error(class_name(), func, "amorph has incorrect pointer!");
// start the thread we added.
- thread_list[thread_list.elements() - 1]->start(NIL);
+ thread_list[thread_list.elements() - 1]->start(NULL_POINTER);
}
time_stamp when_to_leave(DEFAULT_RUN_TIME);
virtual outcome reconstitute(const string_array &classifier,
byte_array &packed_form, infoton * &reformed) {
- reformed = NIL;
+ reformed = NULL_POINTER;
if (classifier != simp_classifier()) return NO_HANDLER;
reformed = new simple_infoton;
if (!reformed->unpack(packed_form)) {
octopus logos("local", 18 * MEGABYTE);
simple_tentacle *tenty = new simple_tentacle;
logos.add_tentacle(tenty);
- tenty = NIL; // octopus has charge of this now.
+ tenty = NULL_POINTER; // octopus has charge of this now.
// turn on security in logos.
simple_entity_registry *guardian = new simple_entity_registry;
outcome reconstitute(const string_array &classifier, byte_array &packed_form,
infoton * &reformed)
{
- reformed = NIL;
+ reformed = NULL_POINTER;
if (classifier.length() < 2) return BAD_INPUT;
astring key = classifier[1];
if (key == "float") {
float_ton *to_return = new float_ton;
if (!to_return->unpack(packed_form)) {
WHACK(to_return);
- return NIL;
+ return NULL_POINTER;
}
reformed = to_return;
return OKAY;
int_set_ton *to_return = new int_set_ton;
if (!to_return->unpack(packed_form)) {
WHACK(to_return);
- return NIL;
+ return NULL_POINTER;
}
reformed = to_return;
return OKAY;
~outer_arm() {
// just reset the two tentacles, since the _unpackers octopus should
// clean them up.
- _numer = NIL;
- _addron = NIL;
+ _numer = NULL_POINTER;
+ _addron = NULL_POINTER;
}
outcome reconstitute(const string_array &classifier, byte_array &packed_form,
byte_array pacula;
if (!infoton::fast_unpack(chunkmo, clarfiator, pacula))
deadly_error(class_name(), "test fast_unpack", "chunkmo has errors");
- infoton *scrung = NIL;
+ infoton *scrung = NULL_POINTER;
//log(astring("classif is ") + clarfiator.text_form());
outcome scrung_ret = unpacky.restore(clarfiator, pacula, scrung);
(const internet_address &where, bool unicast)
: _where(new internet_address(where)),
_stack(new tcpip_stack),
- _socket(NIL),
+ _socket(NULL_POINTER),
_raw(new raw_socket),
_ucast(unicast)
{
spocket_tester::spocket_tester(const internet_address &where)
: _where(new internet_address(where)),
_stack(new tcpip_stack),
- _socket(NIL),
- _root_server(NIL),
+ _socket(NULL_POINTER),
+ _root_server(NULL_POINTER),
_raw(new raw_socket)
{
}