Rodney Schuler avatar Rodney Schuler committed 3323b86

First commit - Just tossing ideas.

Comments (0)

Files changed (13)

+syntax: glob
+**.sln
+**.suo
+**/Debug/
+**/Release/
+**.ipch
+**.sdf

Win32Questions/HeapAllocAlignmentQ/FindDupes.cpp

+#include "StdAfx.h"
+#include "FindDupes.h"
+#include "windows.h"
+
+extern "C" {
+
+static int pagesize=4*1024;
+static int blocksize=4*1024;
+static const int init_alloc=8;
+
+/*  never actaully create a path instance always malloc
+    sizeof(path)+sizeof(FC_CHAR)*(characters in path component+1) */
+typedef struct path {
+	path * parent;
+	path * prev_alloced;
+	int is_include; /* 0=waiting for answer, >0 include, <0 exclude */
+} path;
+
+typedef struct file_record {
+	FD_BYTE_COUNT size; /* sort key */
+	path * file_path;
+	FILETIME last_mod;
+	FD_GROUP_ID group;
+} file_record;
+
+typedef struct _FD_INSTANCE {
+	/* Update these upon each dir visit completion */
+	FD_PATH_COUNT dir_found_count;
+	FD_PATH_COUNT dir_scaned_count;
+	FD_PATH_COUNT dir_file_count;
+
+	/* Update these upon each group completion */
+	FD_GROUP_COUNT group_count;
+	FD_BYTE_COUNT scaned_byte_count;
+	FD_BYTE_COUNT duped_byte_count;
+
+	/* head of path allocation singly linked list */
+	path * path_alloc;
+
+	/* alloced & sorted once at tree search completion */
+	file_record * file_records;
+
+	/* callback funcs & a BATON for each */
+} FD_INSTANCE;
+
+/* The actual functions */
+FD_INSTANCE* fd_init(){
+	return 0;
+}
+
+FD_ERROR fd_addpath(FD_INSTANCE*,FD_PATH_IN){
+	return FD_NOT_IMPLEMENTED;
+}
+
+FD_ERROR fd_start(FD_INSTANCE*){
+	return FD_NOT_IMPLEMENTED;
+}
+
+FD_ERROR fd_cancel(FD_INSTANCE*, FD_COMPLETION_CB, FD_BATON){
+	return FD_NOT_IMPLEMENTED;
+}
+
+FD_ERROR fd_halt(FD_INSTANCE*){
+	return FD_NOT_IMPLEMENTED;
+}
+
+FD_ERROR fd_free(FD_INSTANCE*){
+	return FD_NOT_IMPLEMENTED;
+}
+
+FD_ERROR fd_error(FD_INSTANCE*, FD_ERROR_CB, FD_BATON){
+	return FD_NOT_IMPLEMENTED;
+}
+
+FD_ERROR fd_dirread_error(FD_INSTANCE*, FD_ERROR_CB, FD_BATON){
+	return FD_NOT_IMPLEMENTED;
+}
+
+FD_ERROR fd_fileread_error(FD_INSTANCE*, FD_FILEIO_ERROR_CB, FD_BATON){
+	return FD_NOT_IMPLEMENTED;
+}
+
+FD_ERROR fd_filesearch_complete(FD_INSTANCE*, FD_COMPLETION_CB, FD_BATON){
+	return FD_NOT_IMPLEMENTED;
+}
+
+FD_ERROR fd_compare_complete(FD_INSTANCE*, FD_COMPLETION_CB, FD_BATON){
+	return FD_NOT_IMPLEMENTED;
+}
+
+FD_ERROR fd_pathsearch_progress(FD_INSTANCE*, FD_PATH_COUNT granularity, FD_SEARCHPROGRESS_CB, FD_BATON){
+	return FD_NOT_IMPLEMENTED;
+}
+
+FD_ERROR fd_bytescompared_progress(FD_INSTANCE*, FD_PATH_COUNT granularity, FD_BYTEPROGRESS_CB, FD_BATON){
+	return FD_NOT_IMPLEMENTED;
+}
+
+FD_ERROR fd_new_group(FD_INSTANCE*, FD_NEW_GROUP_CB, FD_BATON){
+	return FD_NOT_IMPLEMENTED;
+}
+
+FD_ERROR fd_new_file_in_group(FD_INSTANCE*, FD_GROUP_ID, FD_NEW_FILE_IN_GROUP_CB, FD_BATON){
+	return FD_NOT_IMPLEMENTED;
+}
+
+FD_ERROR fd_get_first_group(FD_GROUP_ID*){
+	return FD_NOT_IMPLEMENTED;
+}
+
+FD_ERROR fd_get_next_group(FD_GROUP_ID, FD_GROUP_ID*){
+	return FD_NOT_IMPLEMENTED;
+}
+
+FD_ERROR fd_get_first_file_in_group(FD_GROUP_ID, FD_PATH_ID*){
+	return FD_NOT_IMPLEMENTED;
+}
+
+FD_ERROR fd_get_next_file_in_group(FD_GROUP_ID, FD_PATH_ID, FD_PATH_ID*){
+	return FD_NOT_IMPLEMENTED;
+}
+
+FD_ERROR fd_getpath(FD_INSTANCE, FD_PATH_ID, int* buffsize, FD_PATH_OUT buff){
+	return FD_NOT_IMPLEMENTED;
+}
+
+
+} /* extern "c" */

Win32Questions/HeapAllocAlignmentQ/FindDupes.h

+#pragma once
+
+#include <stdlib.h>
+
+extern "C" {
+
+#ifdef WIN32
+typedef wchar_t FC_CHAR;
+typedef wchar_t * const FD_PATH_IN;
+typedef wchar_t * FD_PATH_OUT;
+#define TWO_BYTE_CHAR
+typedef DWORD FD_OS_ERRORCODE;
+#else
+
+typedef char FC_CHAR;
+typedef char * const FD_PATH_IN;
+typedef char * FD_PATH_OUT;
+typedef int FD_OS_ERRORCODE;
+#endif
+
+typedef int FD_ERROR;
+typedef void * FD_BATON;
+typedef int FD_PATH_COUNT;
+typedef void const*const FD_PATH_ID;
+typedef int FD_GROUP_COUNT;
+typedef int FD_GROUP_ID;
+typedef long long FD_BYTE_COUNT;
+typedef struct _FD_INSTANCE FD_INSTANCE; /* Opaque to allow implementation changes */
+
+#define FD_SUCCESS 0
+#define FD_ENOMEM 1
+#define FD_EBUFFSMALL 2
+#define FD_CALLAGAIN 3
+#define FD_NOTADIR 4
+#define FD_RESTART_FORBIDDEN 5
+#define FD_NOT_IMPLEMENTED 6
+
+typedef int (*FD_COMPLETION_CB)(FD_BATON);
+typedef int (*FD_ERROR_CB)(FD_PATH_ID dirId, FD_OS_ERRORCODE, FD_BATON);
+typedef int (*FD_FILEIO_ERROR_CB)(FD_PATH_ID fileId, FD_OS_ERRORCODE, FD_BYTE_COUNT loc, FD_BATON);
+typedef int (*FD_SEARCHPROGRESS_CB)(FD_PATH_COUNT dirFound, FD_PATH_COUNT dirScanned, FD_PATH_COUNT files, FD_BYTE_COUNT bytes, FD_BATON);
+typedef int (*FD_BYTEPROGRESS_CB)(FD_BYTE_COUNT found, FD_BYTE_COUNT compared, FD_BYTE_COUNT duplicated, FD_BATON);
+typedef int (*FD_NEW_GROUP_CB)(FD_GROUP_ID groupId, FD_BATON);
+typedef int (*FD_NEW_FILE_IN_GROUP_CB)(FD_GROUP_ID groupId, FD_PATH_ID fileId, FD_BATON);
+typedef bool (*FD_INCLUDE_FILE)(FC_CHAR const*const path, FD_BATON);
+
+/* setup, start, stop, cleanup. */
+FD_INSTANCE* fd_init();
+FD_ERROR fd_addpath(FD_INSTANCE*,FD_PATH_IN);
+FD_ERROR fd_start(FD_INSTANCE*);
+FD_ERROR fd_cancel(FD_INSTANCE*, FD_COMPLETION_CB, FD_BATON);
+FD_ERROR fd_halt(FD_INSTANCE*); /* Equivelent to calling fd_cancel and waiting until the completion callback */
+FD_ERROR fd_free(FD_INSTANCE*);
+
+/* Reporting handler registration.
+   Only one function can be registered at a time.
+   Register a null func ptr to unregister. */
+/* Error reporting will callback once for each error encountered. */
+FD_ERROR fd_error(FD_INSTANCE*, FD_ERROR_CB, FD_BATON); /* non filesystem/io errors */
+FD_ERROR fd_dirread_error(FD_INSTANCE*, FD_ERROR_CB, FD_BATON);
+FD_ERROR fd_fileread_error(FD_INSTANCE*, FD_FILEIO_ERROR_CB, FD_BATON);
+/* Completion reporting:  Will callback once, when that stage is complete. */
+FD_ERROR fd_filesearch_complete(FD_INSTANCE*, FD_COMPLETION_CB, FD_BATON);
+FD_ERROR fd_compare_complete(FD_INSTANCE*, FD_COMPLETION_CB, FD_BATON);
+/* Progress reporting:  Called periodically to report progress. */
+/* (Use the granularity parameter controll how often the callback fires) */
+FD_ERROR fd_pathsearch_progress(FD_INSTANCE*, FD_PATH_COUNT granularity, FD_SEARCHPROGRESS_CB, FD_BATON);
+FD_ERROR fd_bytescompared_progress(FD_INSTANCE*, FD_PATH_COUNT granularity, FD_BYTEPROGRESS_CB, FD_BATON);
+/* Progress reporting:  Called as files are compared. */
+FD_ERROR fd_new_group(FD_INSTANCE*, FD_NEW_GROUP_CB, FD_BATON);
+FD_ERROR fd_new_file_in_group(FD_INSTANCE*, FD_GROUP_ID, FD_NEW_FILE_IN_GROUP_CB, FD_BATON);
+
+/* Callback to ask your code to include or exclude a file */
+FD_ERROR fd_include_file(FD_INSTANCE*, FD_INCLUDE_FILE, FD_BATON);
+
+/* Use these to traverse groups */
+FD_ERROR fd_get_first_group(FD_GROUP_ID*);
+FD_ERROR fd_get_next_group(FD_GROUP_ID, FD_GROUP_ID*);
+FD_ERROR fd_get_first_file_in_group(FD_GROUP_ID, FD_PATH_ID*);
+FD_ERROR fd_get_next_file_in_group(FD_GROUP_ID, FD_PATH_ID, FD_PATH_ID*);
+
+/*  Turn a file or directory id into a file or directory path.
+	Writes a null terminated path string into your buffer, which you allocated
+	to be buffsize bytes.
+	if *buffsize<=0 or buff is null  
+		*buffsize will set to the required size (including the null terminator)
+		and FD_CALLAGAIN will be returned.
+	if *buffsize>0 and buff is not null and the buffer is not sufficent to 
+		hold the null terminated path string  *buffsize will be set to the
+		required size.  (A number of bytes, less than or equal to pre-call
+		value of *buffsize, _may_ be written to the memory pointed to by buff)
+		and FD_EBUFFSMALL will be returned.
+	if *buffsize>0 and buff is not null and the buffer is large enough
+		The path (including null terminator) will be written to the memory
+		pointer to by buff and FD_SUCCESS will be returned.
+	* remember:  On widows and other platforms using wchar_t for path strings
+	  buffsize is twice the number of wchar_t characters and the null
+	  terminator will be 2 bytes */
+FD_ERROR fd_getpath(FD_INSTANCE, FD_PATH_ID, int* buffsize, FD_PATH_OUT buff);
+};

Win32Questions/HeapAllocAlignmentQ/FindDupes_internal.cpp

+#include "StdAfx.h"
+#include "FindDupes_internal.h"

Win32Questions/HeapAllocAlignmentQ/FindDupes_internal.h

+#pragma once

Win32Questions/HeapAllocAlignmentQ/HeapAllocAlignmentQ.cpp

+// HeapAllocAlignmentQ.cpp : Defines the entry point for the console application.
+//
+
+#include "stdafx.h"
+
+
+int _tmain(int argc, _TCHAR* argv[])
+{
+	return 0;
+}
+

Win32Questions/HeapAllocAlignmentQ/HeapAllocAlignmentQ.vcxproj

+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup Label="ProjectConfigurations">
+    <ProjectConfiguration Include="Debug|Win32">
+      <Configuration>Debug</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|Win32">
+      <Configuration>Release</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+  </ItemGroup>
+  <PropertyGroup Label="Globals">
+    <ProjectGuid>{6CFB19FE-EE84-48F1-ACB1-ED8BE78946D2}</ProjectGuid>
+    <Keyword>Win32Proj</Keyword>
+    <RootNamespace>HeapAllocAlignmentQ</RootNamespace>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>true</UseDebugLibraries>
+    <CharacterSet>Unicode</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+    <CharacterSet>Unicode</CharacterSet>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+  <ImportGroup Label="ExtensionSettings">
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <PropertyGroup Label="UserMacros" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <LinkIncremental>true</LinkIncremental>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <LinkIncremental>false</LinkIncremental>
+  </PropertyGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <ClCompile>
+      <PrecompiledHeader>Use</PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>Disabled</Optimization>
+      <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+    </ClCompile>
+    <Link>
+      <SubSystem>Console</SubSystem>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <PrecompiledHeader>Use</PrecompiledHeader>
+      <Optimization>MaxSpeed</Optimization>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+    </ClCompile>
+    <Link>
+      <SubSystem>Console</SubSystem>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <OptimizeReferences>true</OptimizeReferences>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemGroup>
+    <None Include="ReadMe.txt" />
+  </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="FindDupes.h" />
+    <ClInclude Include="stdafx.h" />
+    <ClInclude Include="targetver.h" />
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="FindDupes.cpp" />
+    <ClCompile Include="HeapAllocAlignmentQ.cpp" />
+    <ClCompile Include="stdafx.cpp">
+      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
+      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
+    </ClCompile>
+  </ItemGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+  <ImportGroup Label="ExtensionTargets">
+  </ImportGroup>
+</Project>

Win32Questions/HeapAllocAlignmentQ/HeapAllocAlignmentQ.vcxproj.filters

+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup>
+    <Filter Include="Source Files">
+      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+    </Filter>
+    <Filter Include="Header Files">
+      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+      <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
+    </Filter>
+    <Filter Include="Resource Files">
+      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
+      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
+    </Filter>
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="ReadMe.txt" />
+  </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="stdafx.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="targetver.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="FindDupes.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="stdafx.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="HeapAllocAlignmentQ.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="FindDupes.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+  </ItemGroup>
+</Project>

Win32Questions/HeapAllocAlignmentQ/HeapAllocAlignmentQ.vcxproj.user

+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+</Project>

Win32Questions/HeapAllocAlignmentQ/ReadMe.txt

+========================================================================
+    CONSOLE APPLICATION : HeapAllocAlignmentQ Project Overview
+========================================================================
+
+AppWizard has created this HeapAllocAlignmentQ application for you.
+
+This file contains a summary of what you will find in each of the files that
+make up your HeapAllocAlignmentQ application.
+
+
+HeapAllocAlignmentQ.vcxproj
+    This is the main project file for VC++ projects generated using an Application Wizard.
+    It contains information about the version of Visual C++ that generated the file, and
+    information about the platforms, configurations, and project features selected with the
+    Application Wizard.
+
+HeapAllocAlignmentQ.vcxproj.filters
+    This is the filters file for VC++ projects generated using an Application Wizard. 
+    It contains information about the association between the files in your project 
+    and the filters. This association is used in the IDE to show grouping of files with
+    similar extensions under a specific node (for e.g. ".cpp" files are associated with the
+    "Source Files" filter).
+
+HeapAllocAlignmentQ.cpp
+    This is the main application source file.
+
+/////////////////////////////////////////////////////////////////////////////
+Other standard files:
+
+StdAfx.h, StdAfx.cpp
+    These files are used to build a precompiled header (PCH) file
+    named HeapAllocAlignmentQ.pch and a precompiled types file named StdAfx.obj.
+
+/////////////////////////////////////////////////////////////////////////////
+Other notes:
+
+AppWizard uses "TODO:" comments to indicate parts of the source code you
+should add to or customize.
+
+/////////////////////////////////////////////////////////////////////////////

Win32Questions/HeapAllocAlignmentQ/stdafx.cpp

+// stdafx.cpp : source file that includes just the standard includes
+// HeapAllocAlignmentQ.pch will be the pre-compiled header
+// stdafx.obj will contain the pre-compiled type information
+
+#include "stdafx.h"
+
+// TODO: reference any additional headers you need in STDAFX.H
+// and not in this file

Win32Questions/HeapAllocAlignmentQ/stdafx.h

+// stdafx.h : include file for standard system include files,
+// or project specific include files that are used frequently, but
+// are changed infrequently
+//
+
+#pragma once
+
+#include "targetver.h"
+
+#include <stdio.h>
+#include <tchar.h>
+#include <Windows.h>
+
+
+// TODO: reference additional headers your program requires here

Win32Questions/HeapAllocAlignmentQ/targetver.h

+#pragma once
+
+// Including SDKDDKVer.h defines the highest available Windows platform.
+
+// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
+// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
+
+#include <WinSDKVer.h>
+#define _WIN32_WINNT _WIN32_WINNT_WINXP
+#include <SDKDDKVer.h>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.