From af1a41712ed916aac89856f35f52d5ee3ac3df4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Wed, 26 May 2010 17:54:30 +0200 Subject: [PATCH] Tiny fixes. --- library/DFProcess-linux-SHM.cpp | 2 +- library/DFProcess-windows-SHM.cpp | 1 - library/DFProcess-windows.cpp | 1 - library/include/DFHack.h | 2 +- tools/playground/incrementalsearch.cpp | 36 +++++++++++++++++++++++++- 5 files changed, 37 insertions(+), 5 deletions(-) diff --git a/library/DFProcess-linux-SHM.cpp b/library/DFProcess-linux-SHM.cpp index 7ee235a74..4e0b50e1c 100644 --- a/library/DFProcess-linux-SHM.cpp +++ b/library/DFProcess-linux-SHM.cpp @@ -609,7 +609,7 @@ void SHMProcess::read (uint32_t src_address, uint32_t size, uint8_t *target_buff else { // first read equals the size of the SHM window - uint32_t to_read = SHM_BODY; + uint32_t to_read = SHM_BODY - 1024; while (size) { // read to_read bytes from src_cursor diff --git a/library/DFProcess-windows-SHM.cpp b/library/DFProcess-windows-SHM.cpp index 6ecf28d4b..20b5dafd6 100644 --- a/library/DFProcess-windows-SHM.cpp +++ b/library/DFProcess-windows-SHM.cpp @@ -23,7 +23,6 @@ distribution. */ #include "Internal.h" #include "dfhack/DFProcess.h" -#include "dfhack/DFWindow.h" #include "dfhack/DFMemInfo.h" #include "dfhack/DFError.h" #include "shms.h" diff --git a/library/DFProcess-windows.cpp b/library/DFProcess-windows.cpp index bb87f9e8d..da44a0f32 100644 --- a/library/DFProcess-windows.cpp +++ b/library/DFProcess-windows.cpp @@ -23,7 +23,6 @@ distribution. */ #include "Internal.h" #include "dfhack/DFProcess.h" -#include "dfhack/DFWindow.h" #include "dfhack/DFMemInfo.h" #include "dfhack/DFError.h" using namespace DFHack; diff --git a/library/include/DFHack.h b/library/include/DFHack.h index d80bce8bb..22a332522 100644 --- a/library/include/DFHack.h +++ b/library/include/DFHack.h @@ -1,4 +1,4 @@ -#ifndef DFHACK_API_H +#ifndef DFHACK_API_H #define DFHACK_API_H #include "dfhack/DFIntegers.h" diff --git a/tools/playground/incrementalsearch.cpp b/tools/playground/incrementalsearch.cpp index 8a2f29f83..cc047466c 100644 --- a/tools/playground/incrementalsearch.cpp +++ b/tools/playground/incrementalsearch.cpp @@ -156,7 +156,40 @@ void searchLoopVector(DFHack::ContextManager & DFMgr, vector & ranges, uint32_t element_size) +{ + DFMgr.Refresh(); + DFHack::Context * DF = DFMgr.getSingleContext(); + DF->Attach(); + for (int i = 0; i < ranges.size();i++) + { + // can't read? range is invalid to us + if(!ranges[i].read) + continue; + char * buffah = (char *) malloc(ranges[i].end - ranges[i].start); + if(buffah) + { + DF->ReadRaw(ranges[i].start,ranges[i].end - ranges[i].start, (uint8_t *) buffah); + cerr << "buffer for range " << i << " allocated and filled" << endl; + free(buffah); + cerr << "and freed" << endl; + } + else + cerr << "buffer for range " << i << " failed to allocate" << endl; + //loop + /* + for(uint64_t offset = ranges[i].start;offset <= ranges[i].end - sizeof(vecTriplet); offset+=4) + { + DF->ReadRaw(offset, sizeof(vecTriplet), (uint8_t *) &load); + if(load.start <= load.finish && load.finish <= load.alloc_finish) + if((load.finish - load.start) / element_size == length) + found.push_back(offset); + } + */ + } + DF->Detach(); + DFMgr.purge(); +} int main (void) { @@ -325,6 +358,7 @@ int main (void) } else if(mode == 3)// string { + mkcopy(DFMgr, selected_ranges,0); //searchLoopString(DF, selected_ranges); } #ifndef LINUX_BUILD