From: Chris Koeritz Date: Sat, 31 Dec 2016 00:25:04 +0000 (-0500) Subject: deep mods X-Git-Tag: 2.140.90~304 X-Git-Url: https://feistymeow.org/gitweb/?a=commitdiff_plain;h=d7e8a05960951d8ce67e36c587726a851e2f5165;p=feisty_meow.git deep mods 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. --- diff --git a/graphiq/.settings/language.settings.xml b/graphiq/.settings/language.settings.xml index 6a512592..c06ebfe7 100644 --- a/graphiq/.settings/language.settings.xml +++ b/graphiq/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/graphiq/library/user_interface/menu_base.cpp b/graphiq/library/user_interface/menu_base.cpp index 38c9aab5..3c657c8d 100644 --- a/graphiq/library/user_interface/menu_base.cpp +++ b/graphiq/library/user_interface/menu_base.cpp @@ -117,7 +117,7 @@ void menu_base::add_item(menu_item *to_invoke) 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(_items->borrow(index)); } @@ -145,7 +145,7 @@ void menu_base::add_submenu(menu_base *sub) 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(_menus->borrow(index)); } @@ -167,7 +167,7 @@ menu_common_base *menu_base::evaluate_trigger(char trigger) { //hmmm: implement this too.... if (!trigger){} -return NIL; +return NULL_POINTER; } void menu_base::activate() diff --git a/graphiq/library/user_interface/menu_base.h b/graphiq/library/user_interface/menu_base.h index 57ecc156..802e541d 100644 --- a/graphiq/library/user_interface/menu_base.h +++ b/graphiq/library/user_interface/menu_base.h @@ -107,7 +107,7 @@ public: 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. */ @@ -131,7 +131,7 @@ public: 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); diff --git a/nucleus/.settings/language.settings.xml b/nucleus/.settings/language.settings.xml index 4be928d1..2d5ebe3a 100644 --- a/nucleus/.settings/language.settings.xml +++ b/nucleus/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + diff --git a/nucleus/.settings/org.eclipse.cdt.codan.core.prefs b/nucleus/.settings/org.eclipse.cdt.codan.core.prefs index d1c7b011..cf61d79d 100644 --- a/nucleus/.settings/org.eclipse.cdt.codan.core.prefs +++ b/nucleus/.settings/org.eclipse.cdt.codan.core.prefs @@ -1,67 +1,73 @@ 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} diff --git a/nucleus/applications/bookmark_tools/bookmark_tree.cpp b/nucleus/applications/bookmark_tools/bookmark_tree.cpp index 04dd9d5f..33ce8b05 100644 --- a/nucleus/applications/bookmark_tools/bookmark_tree.cpp +++ b/nucleus/applications/bookmark_tools/bookmark_tree.cpp @@ -279,7 +279,7 @@ inner_mark_tree *bookmark_tree::process_category(const string_array &items) } 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. @@ -321,7 +321,7 @@ inner_mark_tree *bookmark_tree::process_category(const string_array &items) 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. diff --git a/nucleus/applications/bookmark_tools/js_marks_maker.cpp b/nucleus/applications/bookmark_tools/js_marks_maker.cpp index 49578283..67a88e98 100644 --- a/nucleus/applications/bookmark_tools/js_marks_maker.cpp +++ b/nucleus/applications/bookmark_tools/js_marks_maker.cpp @@ -233,7 +233,7 @@ int marks_maker_javascript::write_marks_page(const astring &output_filename, // 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. diff --git a/nucleus/applications/bookmark_tools/marks_checker.cpp b/nucleus/applications/bookmark_tools/marks_checker.cpp index ba8a2a82..0c84ac8c 100644 --- a/nucleus/applications/bookmark_tools/marks_checker.cpp +++ b/nucleus/applications/bookmark_tools/marks_checker.cpp @@ -19,7 +19,6 @@ #include "bookmark_tree.h" -#include #include #include #include @@ -40,6 +39,7 @@ #include #include #include +#include "../../library/algorithms/sorts.h" using namespace algorithms; using namespace application; @@ -301,7 +301,7 @@ int marks_checker::test_all_links() 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(curr); if (!nod) @@ -318,7 +318,7 @@ int marks_checker::test_all_links() 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); } } @@ -376,7 +376,7 @@ void marks_checker::write_new_files() badness_file.close(); } -marks_checker *main_program = NIL; +marks_checker *main_program = NULL_POINTER; void marks_checker::handle_OS_signal(int formal(sig_id)) { @@ -384,7 +384,7 @@ 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); } @@ -440,7 +440,7 @@ LOG("after reading input..."); ret = test_all_links(); write_new_files(); - main_program = NIL; + main_program = NULL_POINTER; curl_global_cleanup(); // shut down cURL engine again. diff --git a/nucleus/applications/bookmark_tools/marks_sorter.cpp b/nucleus/applications/bookmark_tools/marks_sorter.cpp index 8201799b..41d47b48 100644 --- a/nucleus/applications/bookmark_tools/marks_sorter.cpp +++ b/nucleus/applications/bookmark_tools/marks_sorter.cpp @@ -134,7 +134,7 @@ int marks_sorter::write_new_marks(const astring &output_filename) // 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; diff --git a/nucleus/applications/bundler/bundle_creator.cpp b/nucleus/applications/bundler/bundle_creator.cpp index 17a2a8d0..04c5b173 100644 --- a/nucleus/applications/bundler/bundle_creator.cpp +++ b/nucleus/applications/bundler/bundle_creator.cpp @@ -103,7 +103,7 @@ public: 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); diff --git a/nucleus/applications/bundler/unpacker_stub.cpp b/nucleus/applications/bundler/unpacker_stub.cpp index 85872476..87c6a766 100644 --- a/nucleus/applications/bundler/unpacker_stub.cpp +++ b/nucleus/applications/bundler/unpacker_stub.cpp @@ -446,7 +446,7 @@ int unpacker_stub::execute() } } - 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); diff --git a/nucleus/library/algorithms/shell_sort.h b/nucleus/library/algorithms/shell_sort.h deleted file mode 100644 index 7e9b2539..00000000 --- a/nucleus/library/algorithms/shell_sort.h +++ /dev/null @@ -1,65 +0,0 @@ -#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 -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. - diff --git a/nucleus/library/algorithms/sorts.h b/nucleus/library/algorithms/sorts.h new file mode 100644 index 00000000..dae0ca47 --- /dev/null +++ b/nucleus/library/algorithms/sorts.h @@ -0,0 +1,217 @@ +#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 +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 +basis::array merge(const basis::array &first, basis::array &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 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 +basis::array merge_sort(const basis::array &v, bool reverse = false) +{ + if (v.length() <= 1) { + return new basis::array(v); + } + int midway = v.length() / 2; + basis::array firstPart = merge_sort(v.subarray(0, midway - 1)); + basis::array 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 heap +{ +public: + heap(int max_elements, bool reverse) { + _max_elements = max_elements; + _reverse = reverse; + _heapspace = new basis::array (_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 *_heapspace = NULL_POINTER; +}; + +/*! + * heap sort + * + * operates in O(n log(n)). + * sorts the original array. + */ +template +void heap_sort(type v[], int n, bool reverse = false) +{ + // use heap. do sorty. +} + +////////////// + +template +void partition(type v[], int start, int end) +{ + +} + +//! the recursive version of quick sort that does the work for our convenience method. +template +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 +void quick_sort(type v[], int n, bool reverse = false) +{ + inner_quick_sort(v, n, 0, n-1, reverse); +} + +} // namespace. + +#endif // outer guard. + diff --git a/nucleus/library/application/callstack_tracker.cpp b/nucleus/library/application/callstack_tracker.cpp index c9f43bab..4194bbee 100644 --- a/nucleus/library/application/callstack_tracker.cpp +++ b/nucleus/library/application/callstack_tracker.cpp @@ -200,9 +200,9 @@ int callstack_tracker::full_trace_size() const 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) { @@ -215,9 +215,9 @@ frame_tracking_instance::frame_tracking_instance(const char *class_name, 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) { } @@ -231,9 +231,9 @@ void frame_tracking_instance::clean() 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; } @@ -252,9 +252,9 @@ void frame_tracking_instance::assign(const char *class_name, const char *func, { 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; } diff --git a/nucleus/library/application/command_line.h b/nucleus/library/application/command_line.h index 989aac5d..d75a14c6 100644 --- a/nucleus/library/application/command_line.h +++ b/nucleus/library/application/command_line.h @@ -205,7 +205,7 @@ private: 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) { \ diff --git a/nucleus/library/application/dll_root.cpp b/nucleus/library/application/dll_root.cpp index 7eab74b3..b54b9e2c 100644 --- a/nucleus/library/application/dll_root.cpp +++ b/nucleus/library/application/dll_root.cpp @@ -54,7 +54,7 @@ DllMain(application_instance instance, DWORD reason, LPVOID reserved) // 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; diff --git a/nucleus/library/application/hoople_service.cpp b/nucleus/library/application/hoople_service.cpp index 317ada24..1a7ea8d9 100644 --- a/nucleus/library/application/hoople_service.cpp +++ b/nucleus/library/application/hoople_service.cpp @@ -58,7 +58,7 @@ int &hoople_service::_timer_period() { static int _tim = 0; return _tim; } ////////////// -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. @@ -208,7 +208,7 @@ bool hoople_service::launch_event_loop(hoople_service &alert, 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); } diff --git a/nucleus/library/application/launch_manager.cpp b/nucleus/library/application/launch_manager.cpp index 2bc32d2a..86c2131d 100644 --- a/nucleus/library/application/launch_manager.cpp +++ b/nucleus/library/application/launch_manager.cpp @@ -140,7 +140,7 @@ launch_manager::launch_manager(configured_applications &config) FUNCDEF("constructor"); // start the application checking thread. - _checker->start(NIL); + _checker->start(NULL_POINTER); _checker->reschedule(200); // make it start pretty quickly. } diff --git a/nucleus/library/application/memory_checker.cpp b/nucleus/library/application/memory_checker.cpp index 2426c785..2917b6db 100644 --- a/nucleus/library/application/memory_checker.cpp +++ b/nucleus/library/application/memory_checker.cpp @@ -88,7 +88,7 @@ public: #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. @@ -104,13 +104,13 @@ public: } 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 } }; @@ -140,7 +140,7 @@ class memory_bin { public: void construct() { - _head = NIL; + _head = NULL_POINTER; _count = 0; _lock = (mutex_base *)malloc(sizeof(mutex_base)); _lock->construct(); @@ -169,7 +169,7 @@ public: _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 @@ -256,7 +256,7 @@ public: _bins[i].destruct(); } free(_bins); - _bins = NIL; + _bins = NULL_POINTER; } int compute_slot(void *ptr) { @@ -317,7 +317,7 @@ public: // 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 { @@ -382,7 +382,7 @@ if (!_mems) printf("memory_checker::destruct being invoked twice!\n"); _mems->destruct(); free(_mems); - _mems = NIL; + _mems = NULL_POINTER; } void *memory_checker::provide_memory(size_t size, char *file, int line) diff --git a/nucleus/library/application/redirecter.cpp b/nucleus/library/application/redirecter.cpp index c0b7e864..552563b1 100644 --- a/nucleus/library/application/redirecter.cpp +++ b/nucleus/library/application/redirecter.cpp @@ -84,9 +84,9 @@ private: 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), @@ -105,9 +105,9 @@ stdio_redirecter::stdio_redirecter(const astring &command, 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)), @@ -181,10 +181,10 @@ outcome stdio_redirecter::create_pipes() 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. @@ -276,12 +276,12 @@ outcome stdio_redirecter::launch_program(int &new_process_id) // 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. @@ -301,8 +301,8 @@ outcome stdio_redirecter::launch_program(int &new_process_id) } #endif - _stdout_reader->start(NIL); - _stderr_reader->start(NIL); + _stdout_reader->start(NULL_POINTER); + _stderr_reader->start(NULL_POINTER); return OKAY; } @@ -353,8 +353,8 @@ void stdio_redirecter::close_input() #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 } @@ -383,11 +383,11 @@ void stdio_redirecter::zap_program() 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) { @@ -410,7 +410,7 @@ void stdio_redirecter::zap_program() } } CloseHandle(_app_handle); - _app_handle = NIL; + _app_handle = NULL_POINTER; } #endif @@ -449,7 +449,7 @@ outcome stdio_redirecter::write(const byte_array &to_write, int &written) #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; @@ -490,7 +490,7 @@ void stdio_redirecter::std_thread_action(bool is_stdout) // 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) { diff --git a/nucleus/library/application/registry_config.cpp b/nucleus/library/application/registry_config.cpp index 0fcbb01b..9542f9e2 100644 --- a/nucleus/library/application/registry_config.cpp +++ b/nucleus/library/application/registry_config.cpp @@ -114,8 +114,8 @@ bool registry_configurator::put(const astring §ion_in, const astring &entry, 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; diff --git a/nucleus/library/application/shared_memory.cpp b/nucleus/library/application/shared_memory.cpp index c26a09c5..313a3c0d 100644 --- a/nucleus/library/application/shared_memory.cpp +++ b/nucleus/library/application/shared_memory.cpp @@ -48,7 +48,7 @@ namespace application { 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) @@ -132,7 +132,7 @@ shared_memory::~shared_memory() ::CloseHandle(_the_memory); #else //hmmm: fix. - _the_memory = NIL; + _the_memory = NULL_POINTER; #endif WHACK(_locking); WHACK(_identity); @@ -181,10 +181,10 @@ void shared_memory::unlock(abyte * &to_unlock) 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, diff --git a/nucleus/library/application/window_classist.h b/nucleus/library/application/window_classist.h index 5b9a1ccb..67f7b7d6 100644 --- a/nucleus/library/application/window_classist.h +++ b/nucleus/library/application/window_classist.h @@ -60,7 +60,7 @@ namespace application { // 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 @@ -127,7 +127,7 @@ window_handle create_simplistic_window(const basis::astring &window_title, 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; @@ -135,7 +135,7 @@ window_handle create_simplistic_window(const basis::astring &window_title, 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? } diff --git a/nucleus/library/application/windoze_helper.cpp b/nucleus/library/application/windoze_helper.cpp index a78392c9..1dfbefad 100644 --- a/nucleus/library/application/windoze_helper.cpp +++ b/nucleus/library/application/windoze_helper.cpp @@ -308,7 +308,7 @@ bool event_poll(MSG &message) 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); @@ -438,9 +438,9 @@ istring system_error_text(u_int to_name) 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') @@ -569,7 +569,7 @@ basis::char_star_array break_line(istring &app, const istring ¶meters) .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]); @@ -740,8 +740,8 @@ u_int launch_process(const istring &app_name_in, const istring &command_line, // } } 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. diff --git a/nucleus/library/application/windoze_helper.h b/nucleus/library/application/windoze_helper.h index b0ec409f..071e0fcd 100644 --- a/nucleus/library/application/windoze_helper.h +++ b/nucleus/library/application/windoze_helper.h @@ -140,9 +140,9 @@ 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(); diff --git a/nucleus/library/basis/array.h b/nucleus/library/basis/array.h index 7deb974d..9b466ce4 100644 --- a/nucleus/library/basis/array.h +++ b/nucleus/library/basis/array.h @@ -76,11 +76,11 @@ public: 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. @@ -99,10 +99,10 @@ public: 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 @@ -289,7 +289,7 @@ public: class double_array : public array { public: - double_array(int len = 0, double *data = NIL) + double_array(int len = 0, double *data = NULL_POINTER) : root_object(), array(len, data, SIMPLE_COPY | EXPONE) {} double_array(const array &to_copy) : array(to_copy) {} @@ -313,7 +313,7 @@ public: template array::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 @@ -329,7 +329,7 @@ array::array(int num, const contents *init, int flags) template array::array(const array &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. @@ -338,9 +338,9 @@ array::array(const array &cf) template array::~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; } @@ -421,7 +421,7 @@ template array array::concatenation(const array &s1) const { // tailor the return array to the new size needed. - array to_return(this->length() + s1.length(), NIL, s1.c_flags); + array 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; @@ -430,7 +430,7 @@ array array::concatenation(const array &s1) const template array array::concatenation(const contents &s1) const { - array to_return(this->length() + 1, NIL, c_flags); + array to_return(this->length() + 1, NULL_POINTER, c_flags); to_return.overwrite(0, *this); if (!this->simple()) to_return.access()[to_return.last()] = s1; @@ -442,9 +442,9 @@ array array::concatenation(const contents &s1) const template array array::subarray(int start, int end) const { - bounds_return(start, 0, this->last(), array(0, NIL, c_flags)); - bounds_return(end, 0, this->last(), array(0, NIL, c_flags)); - if (start > end) return array(0, NIL, c_flags); + bounds_return(start, 0, this->last(), array(0, NULL_POINTER, c_flags)); + bounds_return(end, 0, this->last(), array(0, NULL_POINTER, c_flags)); + if (start > end) return array(0, NULL_POINTER, c_flags); return array(end - start + 1, &(this->observe()[start]), c_flags); } @@ -522,8 +522,8 @@ outcome array::allocator_reset(int initial, int blocking) 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. @@ -611,7 +611,7 @@ outcome array::resize(int new_size, how_to_copy way) 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; @@ -854,7 +854,7 @@ void array::snarf(array &new_contents) class char_star_array : public array { public: - char_star_array() : array(0, NIL, SIMPLE_COPY | EXPONE + char_star_array() : array(0, NULL_POINTER, SIMPLE_COPY | EXPONE | FLUSH_INVISIBLE) {} ~char_star_array() { // clean up all the memory we're holding. diff --git a/nucleus/library/basis/astring.cpp b/nucleus/library/basis/astring.cpp index 916ec0fd..b9ae54d0 100644 --- a/nucleus/library/basis/astring.cpp +++ b/nucleus/library/basis/astring.cpp @@ -69,7 +69,11 @@ astring::astring(char initial, int repeat) { 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(); } @@ -117,7 +121,7 @@ astring::astring(special_flag flag, const char *initial, ...) va_end(args); } -astring::~astring() { c_held_string = NIL; } +astring::~astring() { c_held_string = NULL_POINTER; } const astring &astring::empty_string() { return bogonic(); } @@ -415,7 +419,7 @@ void astring::get_type_character(const char * &traverser, va_list &args, } // 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). @@ -431,7 +435,7 @@ void astring::get_type_character(const char * &traverser, va_list &args, 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. @@ -552,7 +556,7 @@ void astring::copy(char *array_to_stuff, int how_many) const 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'; } diff --git a/nucleus/library/basis/astring.h b/nucleus/library/basis/astring.h index 810e3dd5..5ff890e2 100644 --- a/nucleus/library/basis/astring.h +++ b/nucleus/library/basis/astring.h @@ -110,7 +110,7 @@ public: 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(); } @@ -121,7 +121,7 @@ public: 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(); } diff --git a/nucleus/library/basis/base_string.h b/nucleus/library/basis/base_string.h index c2c2cf45..06df036a 100644 --- a/nucleus/library/basis/base_string.h +++ b/nucleus/library/basis/base_string.h @@ -35,11 +35,11 @@ public: 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). */ diff --git a/nucleus/library/basis/byte_array.h b/nucleus/library/basis/byte_array.h index cd5239fa..454b3864 100644 --- a/nucleus/library/basis/byte_array.h +++ b/nucleus/library/basis/byte_array.h @@ -35,7 +35,7 @@ namespace basis { class byte_array : public array, 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(number, initial_contents, SIMPLE_COPY | EXPONE) {} //!< constructs an array of "number" bytes from "initial_contents". diff --git a/nucleus/library/basis/definitions.h b/nucleus/library/basis/definitions.h index 421df898..8d022ab0 100644 --- a/nucleus/library/basis/definitions.h +++ b/nucleus/library/basis/definitions.h @@ -28,8 +28,11 @@ namespace basis { // 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 @@ -46,21 +49,6 @@ namespace basis { //! 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. @@ -183,6 +171,10 @@ public: // 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++. ////////////// diff --git a/nucleus/library/basis/functions.h b/nucleus/library/basis/functions.h index 777461a9..821d3e62 100644 --- a/nucleus/library/basis/functions.h +++ b/nucleus/library/basis/functions.h @@ -114,11 +114,11 @@ template type sign(type a) //! 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 -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 diff --git a/nucleus/library/basis/mutex.cpp b/nucleus/library/basis/mutex.cpp index 73de68c8..3f19f7a5 100644 --- a/nucleus/library/basis/mutex.cpp +++ b/nucleus/library/basis/mutex.cpp @@ -59,7 +59,7 @@ void mutex::construct() 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); diff --git a/nucleus/library/basis/utf_conversion.cpp b/nucleus/library/basis/utf_conversion.cpp index 807ecb60..a703d0ef 100644 --- a/nucleus/library/basis/utf_conversion.cpp +++ b/nucleus/library/basis/utf_conversion.cpp @@ -702,7 +702,7 @@ namespace basis { transcode_to_utf16::~transcode_to_utf16() { delete[] _converted; - _converted = NIL; + _converted = NULL_POINTER; } int transcode_to_utf16::length() const @@ -755,7 +755,7 @@ namespace basis { transcode_to_utf8::~transcode_to_utf8() { delete[] _converted; - _converted = NIL; + _converted = NULL_POINTER; } int transcode_to_utf8::length() const diff --git a/nucleus/library/basis/utf_conversion.h b/nucleus/library/basis/utf_conversion.h index dcb8b16b..6b1185e0 100644 --- a/nucleus/library/basis/utf_conversion.h +++ b/nucleus/library/basis/utf_conversion.h @@ -309,7 +309,7 @@ public: 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; diff --git a/nucleus/library/configuration/application_configuration.cpp b/nucleus/library/configuration/application_configuration.cpp index af502e78..d5ca0802 100644 --- a/nucleus/library/configuration/application_configuration.cpp +++ b/nucleus/library/configuration/application_configuration.cpp @@ -207,7 +207,7 @@ astring application_configuration::application_name() 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; diff --git a/nucleus/library/configuration/configuration_list.cpp b/nucleus/library/configuration/configuration_list.cpp index 97b79650..6e41063e 100644 --- a/nucleus/library/configuration/configuration_list.cpp +++ b/nucleus/library/configuration/configuration_list.cpp @@ -57,7 +57,7 @@ const configlet *configuration_list::find(const configlet &to_find) const return &curr; } } - return NIL; + return NULL_POINTER; } bool configuration_list::zap(const configlet &dead_item) diff --git a/nucleus/library/configuration/configuration_list.h b/nucleus/library/configuration/configuration_list.h index 0aea0ca7..fbf2b7fa 100644 --- a/nucleus/library/configuration/configuration_list.h +++ b/nucleus/library/configuration/configuration_list.h @@ -46,9 +46,9 @@ public: 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); diff --git a/nucleus/library/configuration/ini_configurator.cpp b/nucleus/library/configuration/ini_configurator.cpp index 67436f83..c5b2edf6 100644 --- a/nucleus/library/configuration/ini_configurator.cpp +++ b/nucleus/library/configuration/ini_configurator.cpp @@ -335,8 +335,8 @@ bool ini_configurator::put_profile_string(const astring §ion, 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()))); } @@ -345,8 +345,8 @@ void ini_configurator::get_profile_string(const astring §ion, 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())); } diff --git a/nucleus/library/configuration/system_values.cpp b/nucleus/library/configuration/system_values.cpp index c9b74f19..6461a0fe 100644 --- a/nucleus/library/configuration/system_values.cpp +++ b/nucleus/library/configuration/system_values.cpp @@ -15,11 +15,11 @@ #include "ini_configurator.h" #include "system_values.h" -#include #include #include #include #include +#include "../algorithms/sorts.h" using namespace algorithms; using namespace basis; @@ -73,7 +73,7 @@ public: return curr; } } - return NIL; + return NULL_POINTER; } }; diff --git a/nucleus/library/crypto/blowfish_crypto.cpp b/nucleus/library/crypto/blowfish_crypto.cpp index 37543df8..f5f7681b 100644 --- a/nucleus/library/crypto/blowfish_crypto.cpp +++ b/nucleus/library/crypto/blowfish_crypto.cpp @@ -206,7 +206,7 @@ bool blowfish_crypto::encrypt(const byte_array &source, 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); @@ -260,7 +260,7 @@ bool blowfish_crypto::decrypt(const byte_array &source, 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); diff --git a/nucleus/library/crypto/rsa_crypto.cpp b/nucleus/library/crypto/rsa_crypto.cpp index 36c89ed8..231df924 100644 --- a/nucleus/library/crypto/rsa_crypto.cpp +++ b/nucleus/library/crypto/rsa_crypto.cpp @@ -55,7 +55,7 @@ SAFE_STATIC(mutex, __single_stepper, ) // 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"); @@ -64,7 +64,7 @@ rsa_crypto::rsa_crypto(int key_size) } rsa_crypto::rsa_crypto(const byte_array &key) -: _key(NIL) +: _key(NULL_POINTER) { FUNCDEF("ctor(byte_array)"); static_ssl_initializer(); @@ -75,7 +75,7 @@ rsa_crypto::rsa_crypto(const byte_array &key) } rsa_crypto::rsa_crypto(RSA *key) -: _key(NIL) +: _key(NULL_POINTER) { FUNCDEF("ctor(RSA)"); static_ssl_initializer(); @@ -86,7 +86,7 @@ rsa_crypto::rsa_crypto(RSA *key) rsa_crypto::rsa_crypto(const rsa_crypto &to_copy) : root_object(), - _key(NIL) + _key(NULL_POINTER) { FUNCDEF("copy ctor"); static_ssl_initializer(); @@ -118,7 +118,7 @@ RSA *rsa_crypto::generate_key(int key_size) 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)); @@ -146,17 +146,17 @@ bool rsa_crypto::set_key(byte_array &key) // 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 @@ -166,28 +166,28 @@ bool rsa_crypto::set_key(byte_array &key) // 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. @@ -217,7 +217,7 @@ bool rsa_crypto::set_key(byte_array &key) 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); @@ -266,7 +266,7 @@ bool rsa_crypto::private_key(byte_array &privkey) const 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 *; diff --git a/nucleus/library/filesystem/byte_filer.cpp b/nucleus/library/filesystem/byte_filer.cpp index 0384d2ec..e091996b 100644 --- a/nucleus/library/filesystem/byte_filer.cpp +++ b/nucleus/library/filesystem/byte_filer.cpp @@ -44,7 +44,7 @@ class file_hider public: FILE *fp; // the real file pointer. - file_hider() : fp(NIL) {} + file_hider() : fp(NULL_POINTER) {} }; ////////////// @@ -88,8 +88,8 @@ bool byte_filer::open(const astring &fname, const astring &perms) 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(); } @@ -97,7 +97,7 @@ void byte_filer::close() { _filename->reset(""); if (_auto_close && _handle->fp) fclose(_handle->fp); - _handle->fp = NIL; + _handle->fp = NULL_POINTER; } bool byte_filer::good() { return !!_handle->fp; } diff --git a/nucleus/library/filesystem/directory.cpp b/nucleus/library/filesystem/directory.cpp index c9ce8e99..f1341e68 100644 --- a/nucleus/library/filesystem/directory.cpp +++ b/nucleus/library/filesystem/directory.cpp @@ -15,7 +15,6 @@ #include "directory.h" #include "filename.h" -#include #include #include #include @@ -27,6 +26,8 @@ #include #include #include + +#include "../algorithms/sorts.h" #if defined(__UNIX__) || defined(__GNU_WINDOWS__) #include #include diff --git a/nucleus/library/filesystem/directory_tree.cpp b/nucleus/library/filesystem/directory_tree.cpp index 54a8ca9b..a7611721 100644 --- a/nucleus/library/filesystem/directory_tree.cpp +++ b/nucleus/library/filesystem/directory_tree.cpp @@ -51,7 +51,7 @@ public: 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) {} }; ////////////// @@ -71,7 +71,7 @@ directory_tree::directory_tree(const astring &path, const char *pattern, : _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) { @@ -181,7 +181,7 @@ void directory_tree::traverse(const astring &path, const char *pattern, // 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); @@ -324,7 +324,7 @@ filename_tree *directory_tree::goto_current(dir_tree_iterator &scanning) 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(scanning._current); @@ -377,7 +377,7 @@ bool directory_tree::current(dir_tree_iterator &scanning, 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; } @@ -440,7 +440,7 @@ filename_tree *directory_tree::seek(const astring &dir_name_in, 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); @@ -473,21 +473,21 @@ filename_tree *directory_tree::seek(const astring &dir_name_in, 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) @@ -841,14 +841,14 @@ outcome directory_tree::add_path(const astring &new_item, 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. } @@ -929,7 +929,7 @@ outcome directory_tree::remove_path(const astring &zap_item) 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, diff --git a/nucleus/library/filesystem/directory_tree.h b/nucleus/library/filesystem/directory_tree.h index 6ad56a0e..bd55d2df 100644 --- a/nucleus/library/filesystem/directory_tree.h +++ b/nucleus/library/filesystem/directory_tree.h @@ -174,7 +174,7 @@ public: 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); @@ -201,7 +201,7 @@ private: 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); diff --git a/nucleus/library/filesystem/file_time.h b/nucleus/library/filesystem/file_time.h index 0e89d356..9467b607 100644 --- a/nucleus/library/filesystem/file_time.h +++ b/nucleus/library/filesystem/file_time.h @@ -35,7 +35,7 @@ public: 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); diff --git a/nucleus/library/filesystem/filename_list.cpp b/nucleus/library/filesystem/filename_list.cpp index 28ec7386..2ebe6d04 100644 --- a/nucleus/library/filesystem/filename_list.cpp +++ b/nucleus/library/filesystem/filename_list.cpp @@ -102,7 +102,7 @@ const file_info *filename_list::find(const filename &to_check) const 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 diff --git a/nucleus/library/filesystem/filename_list.h b/nucleus/library/filesystem/filename_list.h index 89c91c2d..74d258b8 100644 --- a/nucleus/library/filesystem/filename_list.h +++ b/nucleus/library/filesystem/filename_list.h @@ -60,7 +60,7 @@ public: 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; diff --git a/nucleus/library/filesystem/huge_file.cpp b/nucleus/library/filesystem/huge_file.cpp index 21158ca4..ae838295 100644 --- a/nucleus/library/filesystem/huge_file.cpp +++ b/nucleus/library/filesystem/huge_file.cpp @@ -289,14 +289,14 @@ basis::outcome huge_file::touch() 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; @@ -308,7 +308,7 @@ basis::outcome huge_file::touch() 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. diff --git a/nucleus/library/loggers/critical_events.cpp b/nucleus/library/loggers/critical_events.cpp index 79f87261..a3002d13 100644 --- a/nucleus/library/loggers/critical_events.cpp +++ b/nucleus/library/loggers/critical_events.cpp @@ -70,9 +70,9 @@ astring critical_events::system_error_text(basis::un_int to_name) 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') @@ -141,7 +141,7 @@ void critical_events::alert_message(const char *info, const char *title) 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()); } diff --git a/nucleus/library/loggers/file_logger.cpp b/nucleus/library/loggers/file_logger.cpp index bd8c22a6..d21f7b59 100644 --- a/nucleus/library/loggers/file_logger.cpp +++ b/nucleus/library/loggers/file_logger.cpp @@ -60,7 +60,7 @@ int static_chaos() { file_logger::file_logger() : _filename(new astring()), _file_limit(DEFAULT_LOG_FILE_SIZE), - _outfile(NIL), + _outfile(NULL_POINTER), _flock(new mutex) { name(""); @@ -69,7 +69,7 @@ file_logger::file_logger() 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); diff --git a/nucleus/library/loggers/program_wide_logger.cpp b/nucleus/library/loggers/program_wide_logger.cpp index f5f6e374..2bd278e7 100644 --- a/nucleus/library/loggers/program_wide_logger.cpp +++ b/nucleus/library/loggers/program_wide_logger.cpp @@ -26,7 +26,7 @@ standard_log_base &program_wide_logger::get() { return *c_the_wide_log; } 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; diff --git a/nucleus/library/nodes/list.cpp b/nucleus/library/nodes/list.cpp index 3429f8e7..0ef4dda1 100644 --- a/nucleus/library/nodes/list.cpp +++ b/nucleus/library/nodes/list.cpp @@ -57,7 +57,7 @@ bool list::iterator::operator ==(const iterator &to_compare) const 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; @@ -65,7 +65,7 @@ const node *list::iterator::observe() 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; @@ -98,7 +98,7 @@ void list::iterator::jump_tail() ////////////// list::list() -: _head(NIL), _tail(NIL) +: _head(NULL_POINTER), _tail(NULL_POINTER) { _head = new node(2); _tail = new node(2); @@ -195,7 +195,7 @@ int list::items_from_tail(const iterator &where) const /* 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); @@ -206,8 +206,8 @@ node *list::get() 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) @@ -215,8 +215,8 @@ node *list::remove(iterator &where) 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; @@ -228,7 +228,7 @@ void list::zap(iterator &where) { delete remove(where); } 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); @@ -244,7 +244,7 @@ void list::append(iterator &where, node *new_node) 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); diff --git a/nucleus/library/nodes/list.h b/nucleus/library/nodes/list.h index 455ebaa4..5856b493 100644 --- a/nucleus/library/nodes/list.h +++ b/nucleus/library/nodes/list.h @@ -94,12 +94,12 @@ public: 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: @@ -139,7 +139,7 @@ public: 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. */ diff --git a/nucleus/library/nodes/node.cpp b/nucleus/library/nodes/node.cpp index 465fa5df..8a6b4dc7 100644 --- a/nucleus/library/nodes/node.cpp +++ b/nucleus/library/nodes/node.cpp @@ -26,8 +26,8 @@ namespace nodes { // 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 @@ -53,7 +53,7 @@ int node::links() const { return _links->elements(); } // 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); } @@ -84,7 +84,7 @@ void node::insert_link(int where, node *to_insert) 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; } diff --git a/nucleus/library/nodes/node.h b/nucleus/library/nodes/node.h index 1b1a6d64..1c80f81b 100644 --- a/nucleus/library/nodes/node.h +++ b/nucleus/library/nodes/node.h @@ -73,12 +73,12 @@ public: 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 diff --git a/nucleus/library/nodes/packable_tree.cpp b/nucleus/library/nodes/packable_tree.cpp index aa85c375..831538af 100644 --- a/nucleus/library/nodes/packable_tree.cpp +++ b/nucleus/library/nodes/packable_tree.cpp @@ -130,7 +130,7 @@ throw_error(current_node->class_name(), func, "failure calculating size"); 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); @@ -141,7 +141,7 @@ int packable_tree::recursive_packed_size() const 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); @@ -161,10 +161,10 @@ packable_tree *packable_tree::recursive_unpack(byte_array &packed_form, // 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 diff --git a/nucleus/library/nodes/packable_tree.h b/nucleus/library/nodes/packable_tree.h index a003db04..a32335f3 100644 --- a/nucleus/library/nodes/packable_tree.h +++ b/nucleus/library/nodes/packable_tree.h @@ -44,7 +44,7 @@ public: 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. diff --git a/nucleus/library/nodes/path.cpp b/nucleus/library/nodes/path.cpp index d84325a7..4a2c0c90 100644 --- a/nucleus/library/nodes/path.cpp +++ b/nucleus/library/nodes/path.cpp @@ -71,7 +71,7 @@ node *path::pop() { node *to_return; if (_stack->acquire_pop(to_return) != common::OKAY) - return NIL; + return NULL_POINTER; return to_return; } diff --git a/nucleus/library/nodes/path.h b/nucleus/library/nodes/path.h index af6261f4..0c333415 100644 --- a/nucleus/library/nodes/path.h +++ b/nucleus/library/nodes/path.h @@ -57,7 +57,7 @@ public: 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. @@ -81,7 +81,7 @@ public: "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. diff --git a/nucleus/library/nodes/symbol_tree.cpp b/nucleus/library/nodes/symbol_tree.cpp index dd96fea5..0cf01c6c 100644 --- a/nucleus/library/nodes/symbol_tree.cpp +++ b/nucleus/library/nodes/symbol_tree.cpp @@ -141,7 +141,7 @@ symbol_tree *symbol_tree::find(const astring &to_find, find_methods how, #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 @@ -151,7 +151,7 @@ symbol_tree *symbol_tree::find(const astring &to_find, find_methods how, // perform the upward recursion first, since it's pretty simple. if (how == recurse_upward) { symbol_tree *our_parent = dynamic_cast(parent()); - if (!our_parent) return NIL; // done recursing. + if (!our_parent) return NULL_POINTER; // done recursing. return our_parent->find(to_find, how, comp); } @@ -164,7 +164,7 @@ symbol_tree *symbol_tree::find(const astring &to_find, find_methods how, 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. @@ -178,7 +178,7 @@ symbol_tree *symbol_tree::find(const astring &to_find, find_methods how, return answer; } } - return NIL; + return NULL_POINTER; } return *found; } diff --git a/nucleus/library/nodes/symbol_tree.h b/nucleus/library/nodes/symbol_tree.h index c8d4f6dc..d5144779 100644 --- a/nucleus/library/nodes/symbol_tree.h +++ b/nucleus/library/nodes/symbol_tree.h @@ -81,8 +81,8 @@ public: 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 @@ -90,7 +90,7 @@ public: "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. diff --git a/nucleus/library/nodes/tree.cpp b/nucleus/library/nodes/tree.cpp index 0a2fbf9e..59ca5d70 100644 --- a/nucleus/library/nodes/tree.cpp +++ b/nucleus/library/nodes/tree.cpp @@ -50,7 +50,7 @@ bool tree::iterator::next_node(tree *&to_return) #ifdef DEBUG_TREE FUNCDEF("next_node"); #endif - to_return = NIL; + to_return = NULL_POINTER; #ifdef DEBUG_TREE if ( (_order != to_branches) && (_order != reverse_branches) ) { @@ -255,7 +255,7 @@ tree *tree::iterator::next() #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); @@ -270,7 +270,7 @@ tree *tree::iterator::next() tree::tree() : node(1) -{ set_link(BACKWARDS_BRANCH, NIL); } +{ set_link(BACKWARDS_BRANCH, NULL_POINTER); } tree::~tree() { @@ -278,7 +278,7 @@ 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 @@ -298,7 +298,7 @@ tree::~tree() // 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 @@ -306,7 +306,7 @@ tree::~tree() // 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 @@ -342,7 +342,7 @@ int tree::branches() const { return links() - 1; } 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); } @@ -352,8 +352,8 @@ int tree::which(tree *branch_to_find) const 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(traveler); @@ -369,7 +369,7 @@ void tree::attach(tree *new_branch) 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--) @@ -390,7 +390,7 @@ outcome tree::prune_index(int branch_to_cut) 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; } @@ -415,7 +415,7 @@ if (to_follow.size()) {} /* 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"); diff --git a/nucleus/library/nodes/tree.h b/nucleus/library/nodes/tree.h index 31d0a99f..b116d1e2 100644 --- a/nucleus/library/nodes/tree.h +++ b/nucleus/library/nodes/tree.h @@ -49,7 +49,7 @@ public: 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; @@ -61,7 +61,7 @@ public: 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. @@ -124,7 +124,7 @@ public: 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". @@ -140,10 +140,10 @@ public: 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; diff --git a/nucleus/library/processes/ethread.cpp b/nucleus/library/processes/ethread.cpp index 15b39564..33f0a90b 100644 --- a/nucleus/library/processes/ethread.cpp +++ b/nucleus/library/processes/ethread.cpp @@ -88,7 +88,7 @@ ethread::ethread() : _thread_ready(false), _thread_active(false), _stop_thread(false), - _data(NIL), + _data(NULL_POINTER), #ifdef _MSC_VER _handle(0), #else @@ -106,7 +106,7 @@ ethread::ethread(int sleep_timer, timed_thread_types how) : _thread_ready(false), _thread_active(false), _stop_thread(false), - _data(NIL), + _data(NULL_POINTER), #ifdef _MSC_VER _handle(0), #else @@ -229,7 +229,7 @@ void ethread::one_shot_thread_driver(void *hidden_pointer) 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 @@ -245,8 +245,8 @@ void ethread::one_shot_thread_driver(void *hidden_pointer) _current_threads().decrement(); #endif #ifndef _MSC_VER - pthread_exit(NIL); - return NIL; + pthread_exit(NULL_POINTER); + return NULL_POINTER; #else _endthread(); #endif @@ -263,7 +263,7 @@ void ethread::periodic_thread_driver(void *hidden_pointer) 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 @@ -317,8 +317,8 @@ void ethread::periodic_thread_driver(void *hidden_pointer) _current_threads().decrement(); #endif #ifndef _MSC_VER - pthread_exit(NIL); - return NIL; + pthread_exit(NULL_POINTER); + return NULL_POINTER; #else _endthread(); #endif diff --git a/nucleus/library/processes/launch_process.cpp b/nucleus/library/processes/launch_process.cpp index 20e10fda..45880744 100644 --- a/nucleus/library/processes/launch_process.cpp +++ b/nucleus/library/processes/launch_process.cpp @@ -66,7 +66,7 @@ bool launch_process::event_poll(MSG &message) 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); @@ -146,7 +146,7 @@ char_star_array launch_process::break_line(astring &app, const astring ¶mete .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])); @@ -293,8 +293,8 @@ basis::un_int launch_process::run(const astring &app_name_in, const astring &com // } } 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. diff --git a/nucleus/library/processes/launch_process.h b/nucleus/library/processes/launch_process.h index 44ce4857..c13453d4 100644 --- a/nucleus/library/processes/launch_process.h +++ b/nucleus/library/processes/launch_process.h @@ -28,7 +28,7 @@ namespace processes { class char_star_array : public basis::array { public: - char_star_array() : basis::array(0, NIL, SIMPLE_COPY | EXPONE | FLUSH_INVISIBLE) {} + char_star_array() : basis::array(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++) { diff --git a/nucleus/library/processes/mailbox.cpp b/nucleus/library/processes/mailbox.cpp index 52b89adf..afc4919b 100644 --- a/nucleus/library/processes/mailbox.cpp +++ b/nucleus/library/processes/mailbox.cpp @@ -188,7 +188,7 @@ int mailbox::waiting(const unique_int &id) const 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); } diff --git a/nucleus/library/processes/post_office.cpp b/nucleus/library/processes/post_office.cpp index 523e4bb3..4eceba57 100644 --- a/nucleus/library/processes/post_office.cpp +++ b/nucleus/library/processes/post_office.cpp @@ -102,7 +102,7 @@ public: 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) {} @@ -128,7 +128,7 @@ public: tagged_mail_stop *curr = borrow(i); if (curr && (curr->_id == id)) return curr; } - return NIL; + return NULL_POINTER; } bool zap(const unique_int &id) { @@ -363,13 +363,13 @@ bool post_office::register_route(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; } diff --git a/nucleus/library/processes/process_control.cpp b/nucleus/library/processes/process_control.cpp index bfc49cca..04d2e0e2 100644 --- a/nucleus/library/processes/process_control.cpp +++ b/nucleus/library/processes/process_control.cpp @@ -98,21 +98,21 @@ public: /// 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 }; @@ -377,7 +377,7 @@ bool process_control::get_processes_with_psapi(process_entry_array &to_fill) // 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) { @@ -518,7 +518,7 @@ bool process_control::get_processes_with_ps(process_entry_array &to_fill) _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()!"); diff --git a/nucleus/library/processes/rendezvous.cpp b/nucleus/library/processes/rendezvous.cpp index 46545a30..b93d0764 100644 --- a/nucleus/library/processes/rendezvous.cpp +++ b/nucleus/library/processes/rendezvous.cpp @@ -68,7 +68,7 @@ astring unix_rendez_file(const astring &lock_name) #endif rendezvous::rendezvous(const astring &root_name) -: _handle(NIL), +: _handle(NULL_POINTER), _locked(false), _root_name(new astring(root_name)) { @@ -90,7 +90,7 @@ rendezvous::rendezvous(const 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 } @@ -120,7 +120,7 @@ rendezvous::~rendezvous() } fclose((FILE *)_handle); - _handle = NIL; + _handle = NULL_POINTER; } #endif #ifdef __WIN32__ diff --git a/nucleus/library/processes/safe_callback.cpp b/nucleus/library/processes/safe_callback.cpp index ca62be94..a79c8f78 100644 --- a/nucleus/library/processes/safe_callback.cpp +++ b/nucleus/library/processes/safe_callback.cpp @@ -64,14 +64,14 @@ public: // 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); @@ -85,7 +85,7 @@ public: // 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; diff --git a/nucleus/library/processes/thread_cabinet.cpp b/nucleus/library/processes/thread_cabinet.cpp index 19bc679f..875f9d8c 100644 --- a/nucleus/library/processes/thread_cabinet.cpp +++ b/nucleus/library/processes/thread_cabinet.cpp @@ -224,7 +224,7 @@ ethread *thread_cabinet::get_thread(int index) LOCKIT; thread_record *rec = _threads->borrow(index); if (rec) return rec->_thread; - return NIL; + return NULL_POINTER; } } //namespace. diff --git a/nucleus/library/security/nt_security.cpp b/nucleus/library/security/nt_security.cpp index e8f55797..428fbf64 100644 --- a/nucleus/library/security/nt_security.cpp +++ b/nucleus/library/security/nt_security.cpp @@ -31,7 +31,7 @@ #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 diff --git a/nucleus/library/structures/amorph.h b/nucleus/library/structures/amorph.h index 6d817e8a..c4992cfb 100644 --- a/nucleus/library/structures/amorph.h +++ b/nucleus/library/structures/amorph.h @@ -29,7 +29,7 @@ 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. @@ -67,7 +67,7 @@ public: //!< 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); @@ -84,7 +84,7 @@ public: 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 @@ -99,11 +99,11 @@ public: //!< 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); @@ -153,7 +153,7 @@ public: 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); @@ -176,9 +176,9 @@ private: /*!< 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 @@ -245,7 +245,7 @@ int amorph_packed_size(const amorph &to_pack); template amorph::amorph(int elements) -: basis::array(elements, NIL, basis::array::SIMPLE_COPY +: basis::array(elements, NULL_POINTER, basis::array::SIMPLE_COPY | basis::array::EXPONE | basis::array::FLUSH_INVISIBLE), _fields_used(0) { @@ -266,7 +266,7 @@ template void amorph::set_nil(int start, int end) { for (int i = start; i <= end; i++) - basis::array::put(i, (contents *)NIL); + basis::array::put(i, (contents *)NULL_POINTER); } template @@ -313,7 +313,7 @@ const contents *amorph::get(int field) const { FUNCDEF("get"); CHECK_FIELDS; - bounds_return(field, 0, elements() - 1, NIL); + bounds_return(field, 0, elements() - 1, NULL_POINTER); return basis::array::observe()[field]; } @@ -337,7 +337,7 @@ void amorph::adjust(int new_maximum) basis::array::insert(old_max, new_fields); for (int i = old_max; i < new_maximum; i++) { - basis::array::put(i, NIL); + basis::array::put(i, NULL_POINTER); } } @@ -398,13 +398,13 @@ const contents *amorph::next_valid(int &field) const { 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::get(i)) { field = i; return basis::array::get(i); } - return NIL; + return NULL_POINTER; } template @@ -412,7 +412,7 @@ basis::outcome amorph::clear(int field) { FUNCDEF("clear"); CHECK_FIELDS; - return this->put(field, NIL); + return this->put(field, NULL_POINTER); } template @@ -423,7 +423,7 @@ contents *amorph::acquire(int field) contents *to_return = borrow(field); if (to_return) { _fields_used--; - basis::array::access()[field] = NIL; + basis::array::access()[field] = NULL_POINTER; } return to_return; } @@ -449,7 +449,7 @@ contents *amorph::borrow(int field) { FUNCDEF("borrow"); CHECK_FIELDS; - bounds_return(field, 0, elements() - 1, NIL); + bounds_return(field, 0, elements() - 1, NULL_POINTER); return basis::array::access()[field]; } @@ -511,7 +511,7 @@ void amorph_assign(amorph &to_assign, } 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); } } diff --git a/nucleus/library/structures/bit_vector.cpp b/nucleus/library/structures/bit_vector.cpp index 8c00528e..6ae546fc 100644 --- a/nucleus/library/structures/bit_vector.cpp +++ b/nucleus/library/structures/bit_vector.cpp @@ -34,11 +34,11 @@ using namespace basis; 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; diff --git a/nucleus/library/structures/bit_vector.h b/nucleus/library/structures/bit_vector.h index 55abae95..93343822 100644 --- a/nucleus/library/structures/bit_vector.h +++ b/nucleus/library/structures/bit_vector.h @@ -28,9 +28,9 @@ public: 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. */ diff --git a/nucleus/library/structures/hash_table.h b/nucleus/library/structures/hash_table.h index 2560bc76..6423d413 100644 --- a/nucleus/library/structures/hash_table.h +++ b/nucleus/library/structures/hash_table.h @@ -123,14 +123,14 @@ public: 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. @@ -215,7 +215,7 @@ public: 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) {} }; @@ -227,7 +227,7 @@ class bucket public virtual basis::root_object { public: - bucket() : basis::array >(0, NIL, + bucket() : basis::array >(0, NULL_POINTER, basis::byte_array::SIMPLE_COPY | basis::byte_array::EXPONE | basis::byte_array::FLUSH_INVISIBLE) {} @@ -464,7 +464,7 @@ bool hash_table::find(const key_type &key, 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. @@ -492,9 +492,9 @@ contents *hash_table::acquire(const key_type &key) hashed = hashed % _table->elements(); // see if the key exists in the bucket. bucket *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. diff --git a/nucleus/library/structures/matrix.h b/nucleus/library/structures/matrix.h index ddd73347..5fd55250 100644 --- a/nucleus/library/structures/matrix.h +++ b/nucleus/library/structures/matrix.h @@ -31,7 +31,7 @@ template class matrix : protected basis::array { 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); @@ -54,7 +54,7 @@ public: /*!< 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. @@ -111,7 +111,7 @@ private: class int_matrix : public matrix { 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(rows, cols, data) {} int_matrix(const matrix &to_copy) : matrix(to_copy) {} }; @@ -120,7 +120,7 @@ public: class string_matrix : public matrix { 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(rows, cols, data) {} string_matrix(const matrix &to_copy) : matrix(to_copy) {} }; @@ -129,7 +129,7 @@ public: class double_matrix : public matrix { 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(rows, cols, data) {} double_matrix(const matrix &to_copy) : matrix(to_copy) {} }; diff --git a/nucleus/library/structures/memory_limiter.cpp b/nucleus/library/structures/memory_limiter.cpp index 134c813c..b1ec18cc 100644 --- a/nucleus/library/structures/memory_limiter.cpp +++ b/nucleus/library/structures/memory_limiter.cpp @@ -68,8 +68,8 @@ const int_set &memory_limiter::individuals_listed() const 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; } diff --git a/nucleus/library/structures/memory_limiter.h b/nucleus/library/structures/memory_limiter.h index 1cb0e9fc..99854c69 100644 --- a/nucleus/library/structures/memory_limiter.h +++ b/nucleus/library/structures/memory_limiter.h @@ -107,7 +107,7 @@ private: 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. diff --git a/nucleus/library/structures/object_packers.h b/nucleus/library/structures/object_packers.h index fecb7876..a26503e9 100644 --- a/nucleus/library/structures/object_packers.h +++ b/nucleus/library/structures/object_packers.h @@ -123,7 +123,7 @@ bool unpack_array(basis::byte_array &packed_form, basis::array &to_unp to_unpack.reset(); basis::un_int len; if (!obscure_detach(packed_form, len)) return false; - basis::array swappy_array(len, NIL, to_unpack.flags()); + basis::array 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++) { @@ -162,7 +162,7 @@ bool unpack_simple(basis::byte_array &packed_form, basis::array &to_un to_unpack.reset(); basis::un_int len; if (!obscure_detach(packed_form, len)) return false; - basis::array swappy_array(len, NIL, to_unpack.flags()); + basis::array 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])) diff --git a/nucleus/library/structures/set.h b/nucleus/library/structures/set.h index 48e7a74a..70b19b0c 100644 --- a/nucleus/library/structures/set.h +++ b/nucleus/library/structures/set.h @@ -38,7 +38,7 @@ public: //! 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::EXPONE) : basis::array(num, init, flags) {} @@ -259,7 +259,7 @@ bool set::remove(const contents &to_remove) template set set::intersection(const set &intersect_with) const { - set created(0, NIL, this->flags()); + set created(0, NULL_POINTER, this->flags()); const set *smaller = this; const set *larger = &intersect_with; if (elements() > intersect_with.elements()) { diff --git a/nucleus/library/structures/static_memory_gremlin.cpp b/nucleus/library/structures/static_memory_gremlin.cpp index 60836732..20c08179 100644 --- a/nucleus/library/structures/static_memory_gremlin.cpp +++ b/nucleus/library/structures/static_memory_gremlin.cpp @@ -59,7 +59,7 @@ static_memory_gremlin::static_memory_gremlin() : c_lock(), c_top_index(0), c_actual_size(0), - c_pointers(NIL), + c_pointers(NULL_POINTER), c_show_debugging(false) { ensure_space_exists(); @@ -82,7 +82,7 @@ static_memory_gremlin::~static_memory_gremlin() // 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 @@ -101,7 +101,7 @@ static_memory_gremlin::~static_memory_gremlin() } #endif delete [] c_pointers; - c_pointers = NIL; + c_pointers = NULL_POINTER; } bool static_memory_gremlin::__program_is_dying() { return __global_program_is_dying; } @@ -125,7 +125,7 @@ root_object *static_memory_gremlin::get(const char *unique_name) { 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; } @@ -136,7 +136,7 @@ const char *static_memory_gremlin::find(const root_object *ptr) 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) @@ -187,7 +187,7 @@ void static_memory_gremlin::ensure_space_exists() 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; @@ -204,7 +204,7 @@ void static_memory_gremlin::ensure_space_exists() 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) { diff --git a/nucleus/library/structures/static_memory_gremlin.h b/nucleus/library/structures/static_memory_gremlin.h index e53ee6d9..9ff1d7a5 100644 --- a/nucleus/library/structures/static_memory_gremlin.h +++ b/nucleus/library/structures/static_memory_gremlin.h @@ -74,13 +74,13 @@ public: 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 @@ -162,7 +162,7 @@ recreate any objects that were already toast. */ __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()); \ diff --git a/nucleus/library/structures/string_array.h b/nucleus/library/structures/string_array.h index 22d5c3f4..5870adc7 100644 --- a/nucleus/library/structures/string_array.h +++ b/nucleus/library/structures/string_array.h @@ -31,7 +31,7 @@ class string_array 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(number, initial_contents, EXPONE | FLUSH_INVISIBLE) {} //!< Constructs an array of "number" strings. @@ -43,7 +43,7 @@ public: /*! 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(number, NIL, EXPONE | FLUSH_INVISIBLE) { + : basis::array(number, NULL_POINTER, EXPONE | FLUSH_INVISIBLE) { for (int i = 0; i < number; i++) { put(i, basis::astring(initial_contents[i])); } diff --git a/nucleus/library/structures/symbol_table.h b/nucleus/library/structures/symbol_table.h index ee4bc246..ab7e562b 100644 --- a/nucleus/library/structures/symbol_table.h +++ b/nucleus/library/structures/symbol_table.h @@ -83,7 +83,7 @@ public: //!< 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; @@ -119,7 +119,7 @@ private: internal_symbol_indexer *_tracker; //!< indexed lookup support. internal_symbol_info *get_index(int index) const; - //!< returns the info item at "index" or NIL. + //!< returns the info item at "index" or NULL_POINTER. }; ////////////// @@ -287,7 +287,7 @@ template internal_symbol_info *symbol_table:: 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; } @@ -314,7 +314,7 @@ contents *symbol_table::find(const basis::astring &name) const { // FUNCDEF("find [name]"); internal_symbol_info *found = _symbol_list->find(name); - if (!found) return NIL; + if (!found) return NULL_POINTER; return &found->_content; } @@ -337,7 +337,7 @@ struct sym_tab_apply_data 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 diff --git a/nucleus/library/tests_algorithms/test_sorts.cpp b/nucleus/library/tests_algorithms/test_sorts.cpp index fefcb2e5..9cec59a3 100644 --- a/nucleus/library/tests_algorithms/test_sorts.cpp +++ b/nucleus/library/tests_algorithms/test_sorts.cpp @@ -10,7 +10,6 @@ * Please send any updates to: fred@gruntose.com * */ -#include #include #include #include @@ -18,6 +17,7 @@ #include #include #include +#include using namespace algorithms; using namespace application; @@ -40,38 +40,50 @@ class test_sorts : virtual public unit_base, virtual public application_shell public: test_sorts() : application_shell() {} DEFINE_CLASS_NAME("test_sorts"); + + int *populate_random_c_array(int size); + basis::array 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 test_sorts::populate_random_array(int size) +{ + basis::array 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]; } @@ -79,6 +91,27 @@ int test_sorts::execute() // 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(); } diff --git a/nucleus/library/tests_basis/test_array.cpp b/nucleus/library/tests_basis/test_array.cpp index e7d04a6b..7c6b4faf 100644 --- a/nucleus/library/tests_basis/test_array.cpp +++ b/nucleus/library/tests_basis/test_array.cpp @@ -98,7 +98,7 @@ void test_array::test_arrays_of_void_pointer() { FUNCDEF("void pointer test"); const int MAX_VOID_ARRAY = 20; - array argh(MAX_VOID_ARRAY, NIL, byte_array::SIMPLE_COPY + array argh(MAX_VOID_ARRAY, NULL_POINTER, byte_array::SIMPLE_COPY | byte_array::EXPONE | byte_array::FLUSH_INVISIBLE); array argh2(argh); ASSERT_EQUAL(argh.length(), MAX_VOID_ARRAY, "check first array length"); @@ -175,7 +175,7 @@ public: test_content(abyte q = 3) : _q(q), _ted("bl"), _jed("orp"), - _ned(12, NIL) + _ned(12, NULL_POINTER) /* _med(3, 2), _red(2, 4) */ { @@ -254,7 +254,7 @@ void test_array::array_tester(test_array &ta, const contents &formal(bogus), bas for (int c = 0; c < MAX_SIMULTANEOUS_OBJECTS; c++) { // set up the initial array guys. testers[c] = new array(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]); @@ -311,13 +311,13 @@ void test_array::array_tester(test_array &ta, const contents &formal(bogus), bas } } // now compute an equivalent form of what the state should be. - array equivalent(0, NIL, flags); + array equivalent(0, NULL_POINTER, flags); if (at_front) { if (smaller) { equivalent = old_version.subarray(difference, old_version.length() - 1); } else { - array blank(difference, NIL, flags); + array blank(difference, NULL_POINTER, flags); for (int i = 0; i < blank.length(); i++) blank[i] = 'Q'; equivalent = blank + old_version; @@ -327,7 +327,7 @@ void test_array::array_tester(test_array &ta, const contents &formal(bogus), bas equivalent = old_version.subarray(0, old_version.length() - difference - 1); } else { - array blank(difference, NIL, flags); + array blank(difference, NULL_POINTER, flags); for (int i = 0; i < blank.length(); i++) blank[i] = 'Q'; equivalent = old_version + blank; @@ -360,7 +360,7 @@ void test_array::array_tester(test_array &ta, const contents &formal(bogus), bas int start = a_randomizer.inclusive(0, testers[index]->length()); int end = a_randomizer.inclusive(0, testers[index]->length()); flip_increasing(start, end); - array accumulator(0, NIL, flags); + array 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; @@ -698,7 +698,7 @@ void test_array::array_tester(test_array &ta, const contents &formal(bogus), bas if (index == rand_index) continue; // skip it; try again later. array nugwort = *testers[rand_index]; // perform a swap between two of our arrays. - array temp_hold(0, NIL, flags); + array temp_hold(0, NULL_POINTER, flags); temp_hold.snarf(*testers[index]); testers[index]->snarf(*testers[rand_index]); testers[rand_index]->snarf(temp_hold); diff --git a/nucleus/library/tests_basis/test_mutex.cpp b/nucleus/library/tests_basis/test_mutex.cpp index 83ba313b..86175c4e 100644 --- a/nucleus/library/tests_basis/test_mutex.cpp +++ b/nucleus/library/tests_basis/test_mutex.cpp @@ -136,7 +136,7 @@ public: // 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); @@ -241,14 +241,14 @@ int test_mutex::execute() amorph 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); diff --git a/nucleus/library/tests_basis/test_string.cpp b/nucleus/library/tests_basis/test_string.cpp index a8eb15e5..04c7f0d2 100644 --- a/nucleus/library/tests_basis/test_string.cpp +++ b/nucleus/library/tests_basis/test_string.cpp @@ -184,8 +184,8 @@ void test_string::run_test_02() *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); diff --git a/nucleus/library/tests_basis/test_system_preconditions.cpp b/nucleus/library/tests_basis/test_system_preconditions.cpp index ee6e1af9..9f32d434 100644 --- a/nucleus/library/tests_basis/test_system_preconditions.cpp +++ b/nucleus/library/tests_basis/test_system_preconditions.cpp @@ -136,7 +136,7 @@ int test_system_preconditions::execute() 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"); diff --git a/nucleus/library/tests_crypto/test_blowfish_crypto.cpp b/nucleus/library/tests_crypto/test_blowfish_crypto.cpp index 980e988a..2f2e0778 100644 --- a/nucleus/library/tests_crypto/test_blowfish_crypto.cpp +++ b/nucleus/library/tests_crypto/test_blowfish_crypto.cpp @@ -99,7 +99,7 @@ int test_blowfish::execute() #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 diff --git a/nucleus/library/tests_crypto/test_rsa_crypto.cpp b/nucleus/library/tests_crypto/test_rsa_crypto.cpp index 0fa35239..adc85d5a 100644 --- a/nucleus/library/tests_crypto/test_rsa_crypto.cpp +++ b/nucleus/library/tests_crypto/test_rsa_crypto.cpp @@ -99,7 +99,7 @@ int test_rsa::execute() 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()) { diff --git a/nucleus/library/tests_filesystem/test_file_time.cpp b/nucleus/library/tests_filesystem/test_file_time.cpp index 14e25490..eae4c8d4 100644 --- a/nucleus/library/tests_filesystem/test_file_time.cpp +++ b/nucleus/library/tests_filesystem/test_file_time.cpp @@ -69,8 +69,8 @@ int test_file_time::execute() // 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); diff --git a/nucleus/library/tests_nodes/test_tree.cpp b/nucleus/library/tests_nodes/test_tree.cpp index 5d3516ce..1b60c496 100644 --- a/nucleus/library/tests_nodes/test_tree.cpp +++ b/nucleus/library/tests_nodes/test_tree.cpp @@ -37,7 +37,7 @@ const int test_iterations = 20; 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"; @@ -152,7 +152,7 @@ larch *test_tree::next(larch *&move, larch *formal(hook), traveller &skip) 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); } diff --git a/nucleus/library/tests_structures/bogon.cpp b/nucleus/library/tests_structures/bogon.cpp index 4bd88123..6ea70718 100644 --- a/nucleus/library/tests_structures/bogon.cpp +++ b/nucleus/library/tests_structures/bogon.cpp @@ -23,7 +23,7 @@ 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); @@ -34,7 +34,7 @@ bogon::bogon(abyte *to_copy) : my_held(NIL) } } -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; diff --git a/nucleus/library/tests_structures/test_amorph.cpp b/nucleus/library/tests_structures/test_amorph.cpp index e5dfb1ca..f6f66539 100644 --- a/nucleus/library/tests_structures/test_amorph.cpp +++ b/nucleus/library/tests_structures/test_amorph.cpp @@ -207,7 +207,7 @@ int t_amorph::test_byte_array_amorph() LOG("before fred creation"); chaos randomizer; amorph 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++) { @@ -265,11 +265,11 @@ int t_amorph::test_byte_array_amorph() 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)); diff --git a/nucleus/library/tests_structures/test_hash_table.cpp b/nucleus/library/tests_structures/test_hash_table.cpp index ca0d465f..4d06bab4 100644 --- a/nucleus/library/tests_structures/test_hash_table.cpp +++ b/nucleus/library/tests_structures/test_hash_table.cpp @@ -259,7 +259,7 @@ bool test_hash_table::test_add() ////////////// -hash_table *_hang_on = NIL; +hash_table *_hang_on = NULL_POINTER; // must be set before calling the apply method. #undef UNIT_BASE_THIS_OBJECT @@ -424,9 +424,9 @@ bool test_hash_table::test_find() _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; @@ -461,9 +461,9 @@ bool test_hash_table::test_find_zap_add() 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. diff --git a/nucleus/library/tests_structures/test_int_hash.cpp b/nucleus/library/tests_structures/test_int_hash.cpp index 7fb8c17d..1d6b2051 100644 --- a/nucleus/library/tests_structures/test_int_hash.cpp +++ b/nucleus/library/tests_structures/test_int_hash.cpp @@ -278,7 +278,7 @@ bool test_int_hash::test_add() #undef UNIT_BASE_THIS_OBJECT #define UNIT_BASE_THIS_OBJECT (*dynamic_cast(application_shell::single_instance())) -int_hash *_hang_on = NIL; +int_hash *_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) @@ -452,11 +452,11 @@ bool test_int_hash::test_find() _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; @@ -491,10 +491,10 @@ bool test_int_hash::test_find_zap_add() 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. diff --git a/nucleus/library/textual/string_manipulation.cpp b/nucleus/library/textual/string_manipulation.cpp index b2ba4748..bcd6ac5e 100644 --- a/nucleus/library/textual/string_manipulation.cpp +++ b/nucleus/library/textual/string_manipulation.cpp @@ -323,7 +323,7 @@ abyte string_manipulation::char_to_hex(char to_convert) 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)); diff --git a/nucleus/library/timely/timer_driver.cpp b/nucleus/library/timely/timer_driver.cpp index c8186c72..b675c618 100644 --- a/nucleus/library/timely/timer_driver.cpp +++ b/nucleus/library/timely/timer_driver.cpp @@ -150,7 +150,7 @@ timer_driver::timer_driver() #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) { @@ -159,7 +159,7 @@ timer_driver::timer_driver() #ifdef __UNIX__ // register for the our personal signal. signal(OUR_SIGNAL, &timer_driver_private_handler); - _prompter->start(NIL); + _prompter->start(NULL_POINTER); #endif } @@ -173,13 +173,13 @@ timer_driver::~timer_driver() 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 } @@ -410,7 +410,7 @@ void timer_driver::hookup_OS_timer(int duration) #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. @@ -432,7 +432,7 @@ void timer_driver::unhook_OS_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."); diff --git a/nucleus/library/versions/version_checker.cpp b/nucleus/library/versions/version_checker.cpp index d3c2a235..27134c6f 100644 --- a/nucleus/library/versions/version_checker.cpp +++ b/nucleus/library/versions/version_checker.cpp @@ -113,7 +113,7 @@ void *version_checker::get_handle(const astring &library_file_name) #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 } @@ -207,7 +207,7 @@ version version_checker::retrieve_version(const astring &filename) #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); @@ -248,7 +248,7 @@ bool version_checker::get_record(const astring &filename, 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; diff --git a/nucleus/tools/clam_tools/value_tagger.cpp b/nucleus/tools/clam_tools/value_tagger.cpp index 80debd79..9fb6c780 100644 --- a/nucleus/tools/clam_tools/value_tagger.cpp +++ b/nucleus/tools/clam_tools/value_tagger.cpp @@ -24,7 +24,6 @@ * Please send any updates to: fred@gruntose.com * \*****************************************************************************/ -#include #include #include #include @@ -46,6 +45,8 @@ #include #include + +#include "../../library/algorithms/sorts.h" #ifdef __WIN32__ #include #endif @@ -100,7 +101,7 @@ class search_record { 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) {} @@ -215,7 +216,7 @@ private: value_tagger::value_tagger() : application_shell(), - _ini(NIL), + _ini(NULL_POINTER), _dirs_seen(10) { } @@ -411,7 +412,7 @@ variables before running a build.\r\n"; { // 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); diff --git a/nucleus/tools/simple_utilities/playsound.cpp b/nucleus/tools/simple_utilities/playsound.cpp index 4f94ad96..d8fe12b1 100644 --- a/nucleus/tools/simple_utilities/playsound.cpp +++ b/nucleus/tools/simple_utilities/playsound.cpp @@ -49,7 +49,7 @@ int main(int argc, char *argv[]) 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); diff --git a/octopi/applications/transporter/find_missing.cpp b/octopi/applications/transporter/find_missing.cpp index ffe3b9fa..d8712cfc 100644 --- a/octopi/applications/transporter/find_missing.cpp +++ b/octopi/applications/transporter/find_missing.cpp @@ -97,8 +97,8 @@ private: 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) @@ -269,7 +269,7 @@ int find_missing::retrieve_info_from_server() 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) diff --git a/octopi/applications/transporter/transporter.cpp b/octopi/applications/transporter/transporter.cpp index b597a624..3da636d9 100644 --- a/octopi/applications/transporter/transporter.cpp +++ b/octopi/applications/transporter/transporter.cpp @@ -93,8 +93,8 @@ private: 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) @@ -278,7 +278,7 @@ int transporter::push_client_download() 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) @@ -320,7 +320,7 @@ LOG(a_sprintf("ongoing chunk %d", ++iter)); 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) diff --git a/octopi/library/cromp/cromp_client.cpp b/octopi/library/cromp/cromp_client.cpp index ef7f8931..141bda78 100644 --- a/octopi/library/cromp/cromp_client.cpp +++ b/octopi/library/cromp/cromp_client.cpp @@ -133,10 +133,10 @@ cromp_client::cromp_client(const internet_address &addr, int connection_wait, _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) { @@ -251,7 +251,7 @@ SAFE_STATIC(tcpip_stack, _hidden_stack, ) 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), @@ -269,7 +269,7 @@ outcome cromp_client::synchronous_request(const infoton &to_send, 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()); @@ -424,7 +424,7 @@ outcome cromp_client::asynch_connect() _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 @@ -645,7 +645,7 @@ void cromp_client::decrypt_package_as_needed(outcome &to_return, 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. diff --git a/octopi/library/cromp/cromp_common.cpp b/octopi/library/cromp/cromp_common.cpp index 0aeb2e69..3a05e9ec 100644 --- a/octopi/library/cromp/cromp_common.cpp +++ b/octopi/library/cromp/cromp_common.cpp @@ -128,16 +128,16 @@ double cromp_common::_bytes_received_total = 0.0; } 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]"); @@ -157,16 +157,16 @@ cromp_common::cromp_common(spocket *preexisting, octopus *singleton) : 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); } @@ -182,8 +182,8 @@ cromp_common::~cromp_common() 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); @@ -501,7 +501,7 @@ outcome cromp_common::retrieve_and_restore_root(bool get_anything, 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); @@ -628,7 +628,7 @@ void cromp_common::grab_anything(bool wait) void cromp_common::process_accumulator() { FUNCDEF("process_accumulator"); - infoton *item = NIL; + infoton *item = NULL_POINTER; octopus_request_id req_id; string_array clas; @@ -636,7 +636,7 @@ void cromp_common::process_accumulator() 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; diff --git a/octopi/library/cromp/cromp_common.h b/octopi/library/cromp/cromp_common.h index 2839271c..2f5b20c1 100644 --- a/octopi/library/cromp/cromp_common.h +++ b/octopi/library/cromp/cromp_common.h @@ -46,7 +46,7 @@ public: // 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. @@ -68,7 +68,7 @@ public: 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. @@ -96,10 +96,10 @@ public: 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. @@ -195,7 +195,7 @@ public: 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. diff --git a/octopi/library/cromp/cromp_server.cpp b/octopi/library/cromp/cromp_server.cpp index 73bda545..aeafae7a 100644 --- a/octopi/library/cromp/cromp_server.cpp +++ b/octopi/library/cromp/cromp_server.cpp @@ -128,7 +128,7 @@ public: 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() { @@ -292,7 +292,7 @@ LOG("cleared out buffer clog."); 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); @@ -494,9 +494,9 @@ cromp_server::cromp_server(const internet_address &where, _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"); } @@ -511,8 +511,8 @@ cromp_server::~cromp_server() 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; } @@ -539,7 +539,7 @@ infoton *cromp_server::wrap_infoton(infoton * &request, 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 @@ -547,7 +547,7 @@ infoton *cromp_server::wrap_infoton(infoton * &request, // itself is not encrypted and we don't want to re-encrypt the wrapper. if (dynamic_cast(request) || dynamic_cast(request) - || dynamic_cast(request)) return NIL; + || dynamic_cast(request)) return NULL_POINTER; #ifdef DEBUG_CROMP_SERVER LOG(astring("encrypting ") + request->text_form()); @@ -557,7 +557,7 @@ infoton *cromp_server::wrap_infoton(infoton * &request, // 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); @@ -604,10 +604,10 @@ outcome cromp_server::enable_servers(bool encrypt, cromp_security *security) #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; } @@ -680,7 +680,7 @@ outcome cromp_server::accept_one_client(bool wait) 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()); diff --git a/octopi/library/cromp/cromp_server.h b/octopi/library/cromp/cromp_server.h index bc48e321..afbfa0f7 100644 --- a/octopi/library/cromp/cromp_server.h +++ b/octopi/library/cromp/cromp_server.h @@ -76,11 +76,11 @@ public: 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. @@ -138,7 +138,7 @@ public: 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. diff --git a/octopi/library/octopus/entity_data_bin.cpp b/octopi/library/octopus/entity_data_bin.cpp index fd877d7b..a1584e0d 100644 --- a/octopi/library/octopus/entity_data_bin.cpp +++ b/octopi/library/octopus/entity_data_bin.cpp @@ -64,7 +64,7 @@ public: 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); } @@ -140,7 +140,7 @@ struct apply_struct 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) {} }; @@ -275,7 +275,7 @@ infoton *entity_data_bin::acquire_for_any(octopus_request_id &id) 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); @@ -287,10 +287,10 @@ infoton *entity_data_bin::acquire_for_any(octopus_request_id &id) #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 @@ -328,22 +328,22 @@ infoton *entity_data_bin::acquire_for_entity(const octopus_entity &requester, 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 @@ -362,21 +362,21 @@ infoton *entity_data_bin::acquire_for_entity(const octopus_entity &requester, 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()) { @@ -393,7 +393,7 @@ infoton *entity_data_bin::acquire_for_identifier(const octopus_request_id &id) return to_return; } } - return NIL; + return NULL_POINTER; } bool cleaning_applier(const octopus_entity &key, entity_basket &bask, diff --git a/octopi/library/octopus/entity_data_bin.h b/octopi/library/octopus/entity_data_bin.h index 024644e8..54f5f5f2 100644 --- a/octopi/library/octopus/entity_data_bin.h +++ b/octopi/library/octopus/entity_data_bin.h @@ -77,7 +77,7 @@ public: 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); @@ -85,7 +85,7 @@ public: // 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); @@ -94,7 +94,7 @@ public: 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. diff --git a/octopi/library/octopus/entity_defs.h b/octopi/library/octopus/entity_defs.h index 3a270918..99b0401e 100644 --- a/octopi/library/octopus/entity_defs.h +++ b/octopi/library/octopus/entity_defs.h @@ -173,7 +173,7 @@ public: ~infoton_id_pair() { delete _data; - _data = NIL; + _data = NULL_POINTER; } }; diff --git a/octopi/library/octopus/identity_tentacle.cpp b/octopi/library/octopus/identity_tentacle.cpp index c83b4ce2..33017cb0 100644 --- a/octopi/library/octopus/identity_tentacle.cpp +++ b/octopi/library/octopus/identity_tentacle.cpp @@ -48,7 +48,7 @@ outcome identity_tentacle::reconstitute(const string_array &classifier, return NO_HANDLER; return reconstituter(classifier, packed_form, reformed, - (identity_infoton *)NIL); + (identity_infoton *)NULL_POINTER); } outcome identity_tentacle::consume(infoton &to_chow, diff --git a/octopi/library/octopus/octopus.cpp b/octopi/library/octopus/octopus.cpp index 03ea2438..43c2afc8 100644 --- a/octopi/library/octopus/octopus.cpp +++ b/octopi/library/octopus/octopus.cpp @@ -120,7 +120,7 @@ public: 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; } @@ -193,7 +193,7 @@ infoton *octopus::acquire_result(const octopus_entity &requester, void octopus::unlock_tentacle(tentacle *to_unlock) { - to_unlock = NIL; + to_unlock = NULL_POINTER; _molock->unlock(); } @@ -244,7 +244,7 @@ void octopus::expunge(const octopus_entity &to_remove) 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; @@ -263,7 +263,7 @@ outcome octopus::add_tentacle(tentacle *to_add, bool filter) } 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); @@ -280,7 +280,7 @@ outcome octopus::remove_tentacle(const string_array &group_name, 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 @@ -310,7 +310,7 @@ outcome octopus::remove_tentacle(const string_array &group_name, free_me = freeing->_limb; _filters->remove(free_me); _molock->unlock(); - freeing->_limb = NIL; + freeing->_limb = NULL_POINTER; WHACK(freeing); return tentacle::OKAY; } @@ -323,7 +323,7 @@ outcome octopus::restore(const string_array &classifier, #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; @@ -425,7 +425,7 @@ outcome octopus::evaluate(infoton *request, const octopus_request_id &id, 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. @@ -514,12 +514,12 @@ void octopus::periodic_cleaning() 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; } diff --git a/octopi/library/octopus/octopus.h b/octopi/library/octopus/octopus.h index ad60e4f8..ba91b222 100644 --- a/octopi/library/octopus/octopus.h +++ b/octopi/library/octopus/octopus.h @@ -136,12 +136,12 @@ public: 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. */ ////////////// diff --git a/octopi/library/octopus/tentacle.cpp b/octopi/library/octopus/tentacle.cpp index cda8f3d2..beb2fb4e 100644 --- a/octopi/library/octopus/tentacle.cpp +++ b/octopi/library/octopus/tentacle.cpp @@ -75,8 +75,8 @@ tentacle::tentacle(const string_array &group_name, bool backgrounded, : _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. @@ -106,13 +106,13 @@ entity_data_bin *tentacle::get_storage() { return _products; } 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, @@ -158,9 +158,9 @@ outcome tentacle::enqueue(infoton *to_chow, const octopus_request_id &item_id) 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); @@ -170,7 +170,7 @@ infoton *tentacle::next_request(octopus_request_id &item_id) 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); diff --git a/octopi/library/octopus/tentacle.h b/octopi/library/octopus/tentacle.h index c4352d85..d04af24b 100644 --- a/octopi/library/octopus/tentacle.h +++ b/octopi/library/octopus/tentacle.h @@ -142,7 +142,7 @@ public: /*!< 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. diff --git a/octopi/library/octopus/tentacle_helper.h b/octopi/library/octopus/tentacle_helper.h index 0291f18b..bbdf7b61 100644 --- a/octopi/library/octopus/tentacle_helper.h +++ b/octopi/library/octopus/tentacle_helper.h @@ -39,7 +39,7 @@ namespace octopi { //!< 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 basis::outcome reconstituter(const structures::string_array &classifier, basis::byte_array &packed_form, @@ -78,7 +78,7 @@ public: 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! diff --git a/octopi/library/octopus/unhandled_request.cpp b/octopi/library/octopus/unhandled_request.cpp index 2c042069..f533221b 100644 --- a/octopi/library/octopus/unhandled_request.cpp +++ b/octopi/library/octopus/unhandled_request.cpp @@ -43,7 +43,7 @@ void unhandled_request::text_form(basis::base_string &fill) const + 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); } diff --git a/octopi/library/sockets/internet_address.cpp b/octopi/library/sockets/internet_address.cpp index ac6c90ab..38e77ca8 100644 --- a/octopi/library/sockets/internet_address.cpp +++ b/octopi/library/sockets/internet_address.cpp @@ -440,7 +440,7 @@ bool internet_address::is_valid_internet_address(const astring &to_check, 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. diff --git a/octopi/library/sockets/raw_socket.cpp b/octopi/library/sockets/raw_socket.cpp index 9b750e2f..6fb3d6ea 100644 --- a/octopi/library/sockets/raw_socket.cpp +++ b/octopi/library/sockets/raw_socket.cpp @@ -235,8 +235,8 @@ int raw_socket::inner_select(basis::un_int socket, int mode, int timeout, // 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. @@ -415,8 +415,8 @@ int raw_socket::select(int_array &read_sox, int_array &write_sox, // 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(); diff --git a/octopi/library/sockets/socket_minder.cpp b/octopi/library/sockets/socket_minder.cpp index c99aac96..e4fc5511 100644 --- a/octopi/library/sockets/socket_minder.cpp +++ b/octopi/library/sockets/socket_minder.cpp @@ -81,7 +81,7 @@ public: : ethread(SOCKET_CHECK_INTERVAL, ethread::SLACK_INTERVAL), _parent(parent) { - start(NIL); + start(NULL_POINTER); } ~socket_minder_prompter() { @@ -109,7 +109,7 @@ socket_minder::socket_minder(post_office &post, int parent_route, _pending_sox(new int_set), _prompter(new socket_minder_prompter(*this)) { - _prompter->start(NIL); + _prompter->start(NULL_POINTER); } socket_minder::~socket_minder() @@ -233,13 +233,13 @@ socket_data *socket_minder::lock_socket_data(int socket) 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(); } diff --git a/octopi/library/sockets/socket_minder.h b/octopi/library/sockets/socket_minder.h index da6cd18e..5403226b 100644 --- a/octopi/library/sockets/socket_minder.h +++ b/octopi/library/sockets/socket_minder.h @@ -60,7 +60,7 @@ public: 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". diff --git a/octopi/library/sockets/spocket.cpp b/octopi/library/sockets/spocket.cpp index 3f469bae..0580b1f1 100644 --- a/octopi/library/sockets/spocket.cpp +++ b/octopi/library/sockets/spocket.cpp @@ -338,7 +338,7 @@ outcome spocket::connect(int communication_wait) //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); @@ -460,7 +460,7 @@ outcome spocket::accept(spocket * &sock, bool wait) // 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 diff --git a/octopi/library/sockets/spocket.h b/octopi/library/sockets/spocket.h index effe26cf..25b00868 100644 --- a/octopi/library/sockets/spocket.h +++ b/octopi/library/sockets/spocket.h @@ -135,7 +135,7 @@ public: // 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 diff --git a/octopi/library/synchronic/list_manager.cpp b/octopi/library/synchronic/list_manager.cpp index 8bcacd35..444bb843 100644 --- a/octopi/library/synchronic/list_manager.cpp +++ b/octopi/library/synchronic/list_manager.cpp @@ -130,7 +130,7 @@ synchronizable *list_manager::clone_object(const string_array &classifier) { GRAB_LOCK; int indy = locked_find(classifier); - if (negative(indy)) return NIL; + if (negative(indy)) return NULL_POINTER; return dynamic_cast(_entries->get(indy)->clone()); } diff --git a/octopi/library/synchronic/list_manager.h b/octopi/library/synchronic/list_manager.h index eee70942..0bb18b42 100644 --- a/octopi/library/synchronic/list_manager.h +++ b/octopi/library/synchronic/list_manager.h @@ -62,8 +62,8 @@ public: // 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 diff --git a/octopi/library/tentacles/encryption_tentacle.cpp b/octopi/library/tentacles/encryption_tentacle.cpp index 227ff71d..73789b73 100644 --- a/octopi/library/tentacles/encryption_tentacle.cpp +++ b/octopi/library/tentacles/encryption_tentacle.cpp @@ -43,7 +43,7 @@ encryption_tentacle::encryption_tentacle() (encryption_infoton::encryption_classifier(), false), _server_side(true), _keys(new key_repository), - _rsa_private(NIL) + _rsa_private(NULL_POINTER) { } @@ -83,7 +83,7 @@ outcome encryption_tentacle::reconstitute(const string_array &classifier, 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)) diff --git a/octopi/library/tentacles/encryption_wrapper.cpp b/octopi/library/tentacles/encryption_wrapper.cpp index 8ee8ee09..a04dec51 100644 --- a/octopi/library/tentacles/encryption_wrapper.cpp +++ b/octopi/library/tentacles/encryption_wrapper.cpp @@ -90,7 +90,7 @@ outcome unwrapping_tentacle::reconstitute(const string_array &classifier, return NO_HANDLER; return reconstituter(classifier, packed_form, reformed, - (encryption_wrapper *)NIL); + (encryption_wrapper *)NULL_POINTER); } outcome unwrapping_tentacle::consume(infoton &formal(to_chow), diff --git a/octopi/library/tentacles/file_transfer_tentacle.cpp b/octopi/library/tentacles/file_transfer_tentacle.cpp index 0626fb12..1fb2ad9e 100644 --- a/octopi/library/tentacles/file_transfer_tentacle.cpp +++ b/octopi/library/tentacles/file_transfer_tentacle.cpp @@ -75,8 +75,8 @@ public: 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() { @@ -118,7 +118,7 @@ public: return borrow(i); } } - return NIL; + return NULL_POINTER; } virtual ~file_transfer_status() {} @@ -132,7 +132,7 @@ public: 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. @@ -227,7 +227,7 @@ file_transfer_tentacle::file_transfer_tentacle(int maximum_transfer, _cleaner(new file_transfer_cleaner(*this)), _mode(mode_of_transfer) { - _cleaner->start(NIL); + _cleaner->start(NULL_POINTER); } file_transfer_tentacle::~file_transfer_tentacle() @@ -376,7 +376,7 @@ directory_tree *file_transfer_tentacle::lock_directory(const astring &key) 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; } @@ -454,7 +454,7 @@ outcome file_transfer_tentacle::reconstitute(const string_array &classifier, 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 diff --git a/octopi/library/tentacles/key_repository.cpp b/octopi/library/tentacles/key_repository.cpp index bd6f6b4a..e5d0bc57 100644 --- a/octopi/library/tentacles/key_repository.cpp +++ b/octopi/library/tentacles/key_repository.cpp @@ -38,7 +38,7 @@ octenc_key_record *key_repository::lock(const octopus_entity &ent) 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) { diff --git a/octopi/library/tentacles/key_repository.h b/octopi/library/tentacles/key_repository.h index dfa33304..a373098b 100644 --- a/octopi/library/tentacles/key_repository.h +++ b/octopi/library/tentacles/key_repository.h @@ -54,7 +54,7 @@ public: 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". diff --git a/octopi/library/tentacles/login_tentacle.cpp b/octopi/library/tentacles/login_tentacle.cpp index c26c2f2a..c50e3ef4 100644 --- a/octopi/library/tentacles/login_tentacle.cpp +++ b/octopi/library/tentacles/login_tentacle.cpp @@ -48,7 +48,7 @@ outcome login_tentacle::reconstitute(const string_array &classifier, 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) diff --git a/octopi/library/tests_octopus/t_bin.cpp b/octopi/library/tests_octopus/t_bin.cpp index 6cbadd35..74c85090 100644 --- a/octopi/library/tests_octopus/t_bin.cpp +++ b/octopi/library/tests_octopus/t_bin.cpp @@ -88,7 +88,7 @@ LOG(a_sprintf("test type %d beginning...%c", q, c)); if (! (i % 50) ) { printf("^"); - fflush(NIL); + fflush(NULL_POINTER); } } program_wide_logger().get().eol(parser_bits::CRLF_AT_END); @@ -107,7 +107,7 @@ LOG(a_sprintf("test type %d beginning...%c", q, c)); 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++) { @@ -130,7 +130,7 @@ LOG(a_sprintf("test type %d beginning...%c", q, c)); 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++) { @@ -152,7 +152,7 @@ LOG(a_sprintf("test type %d beginning...%c", q, c)); items_seen++; if (! (items_seen % 50) ) { printf("v"); - fflush(NIL); + fflush(NULL_POINTER); } item_list.zap(j, j); j--; // skip back. diff --git a/octopi/library/tests_octopus/t_bin_threaded.cpp b/octopi/library/tests_octopus/t_bin_threaded.cpp index df719f74..e939c9b9 100644 --- a/octopi/library/tests_octopus/t_bin_threaded.cpp +++ b/octopi/library/tests_octopus/t_bin_threaded.cpp @@ -285,7 +285,7 @@ int test_entity_data_bin_threaded::execute() amorph 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; @@ -301,7 +301,7 @@ int test_entity_data_bin_threaded::execute() 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); diff --git a/octopi/library/tests_octopus/t_security.cpp b/octopi/library/tests_octopus/t_security.cpp index 9531ab6d..4ce733b1 100644 --- a/octopi/library/tests_octopus/t_security.cpp +++ b/octopi/library/tests_octopus/t_security.cpp @@ -69,7 +69,7 @@ public: 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)) { @@ -109,7 +109,7 @@ int test_octopus_security::execute() 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; diff --git a/octopi/library/tests_octopus/t_unpacker.cpp b/octopi/library/tests_octopus/t_unpacker.cpp index a12412a3..1ad69a8d 100644 --- a/octopi/library/tests_octopus/t_unpacker.cpp +++ b/octopi/library/tests_octopus/t_unpacker.cpp @@ -170,14 +170,14 @@ public: 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; @@ -185,7 +185,7 @@ public: 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; @@ -227,8 +227,8 @@ public: ~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, @@ -360,7 +360,7 @@ void test_unpacker::test_unpacking() 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); diff --git a/octopi/library/tests_sockets/bcast_spocketer.cpp b/octopi/library/tests_sockets/bcast_spocketer.cpp index 9541255d..f96413e0 100644 --- a/octopi/library/tests_sockets/bcast_spocketer.cpp +++ b/octopi/library/tests_sockets/bcast_spocketer.cpp @@ -57,7 +57,7 @@ broadcast_spocket_tester::broadcast_spocket_tester (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) { diff --git a/octopi/library/tests_sockets/spocket_tester.cpp b/octopi/library/tests_sockets/spocket_tester.cpp index 3fac9bb8..11d33bef 100644 --- a/octopi/library/tests_sockets/spocket_tester.cpp +++ b/octopi/library/tests_sockets/spocket_tester.cpp @@ -58,8 +58,8 @@ const int PAUSE_TIME = 200; 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) { }