1
0
forked from 0ad/0ad

tex, mem: fix refcnt issue that is the possible cause of bug#70! huge thanks to philip, who localized the problem to tex_wrap/memory not getting freed.

wdbg_sym: make sure symbol info is initialized even if *resolve() fails;
also fix warnings
renderer: make sure texture array is initialized

This was SVN commit r3049.
This commit is contained in:
janwas 2005-10-29 22:29:55 +00:00
parent a7d6725f45
commit 15d9278af6
4 changed files with 16 additions and 11 deletions

View File

@ -497,9 +497,6 @@ int tex_wrap(uint w, uint h, uint bpp, uint flags, void* img, Tex* t)
void* reported_ptr = mem_get_ptr(t->hm);
t->ofs = (u8*)img - (u8*)reported_ptr;
// TODO: remove when mem_wrap / mem_get_ptr add a reference correctly
h_add_ref(t->hm);
CHECK_TEX(t);
return 0;
}

View File

@ -260,10 +260,14 @@ Handle mem_wrap(void* p, size_t size, uint flags, void* raw_p, size_t raw_size,
SCOPED_LOCK;
// we've already allocated that pointer - returns its handle
// we've already allocated that pointer; return its handle and
// increment refcnt.
Handle hm = find_alloc(p);
if(hm > 0)
{
h_add_ref(hm);
return hm;
}
// <p> wasn't allocated via mem_alloc, or we would've found its Handle.
// it is therefore some user-allocated mem and might therefore not have

View File

@ -214,6 +214,7 @@ int debug_resolve_symbol(void* ptr_of_interest, char* sym_name, char* file, int*
if(sym_name)
{
sym_name[0] = '\0';
SYMBOL_INFO_PACKAGEW2 sp;
SYMBOL_INFOW* sym = &sp.si;
if(SymFromAddrW(hProcess, addr, 0, sym))
@ -226,6 +227,9 @@ int debug_resolve_symbol(void* ptr_of_interest, char* sym_name, char* file, int*
// get source file and/or line number (if requested)
if(file || line)
{
file[0] = '\0';
*line = 0;
IMAGEHLP_LINE64 line_info = { sizeof(IMAGEHLP_LINE64) };
DWORD displacement; // unused but required by SymGetLineFromAddr64!
if(SymGetLineFromAddr64(hProcess, addr, &displacement, &line_info))
@ -304,6 +308,8 @@ func2:
*/
#if CPU_IA32 && !CONFIG_OMIT_FP
static int ia32_walk_stack(STACKFRAME64* sf)
{
// read previous values from STACKFRAME64
@ -338,6 +344,7 @@ static int ia32_walk_stack(STACKFRAME64* sf)
return 0;
}
#endif // #if CPU_IA32 && !CONFIG_OMIT_FP
// called for each stack frame found by walk_stack, passing information
@ -456,12 +463,9 @@ static int walk_stack(StackFrameCallback cb, void* user_arg = 0, uint skip = 0,
}
#endif
void* ret_addr = (void*)(uintptr_t)sf.AddrReturn.Offset;
void* fp = (void*)(uintptr_t)sf.AddrFrame .Offset;
void* pc = (void*)(uintptr_t)sf.AddrPC .Offset;
// no more frames found - abort. note: also test FP because
// StackWalk64 sometimes erroneously reports success.
void* fp = (void*)(uintptr_t)sf.AddrFrame .Offset;
if(err < 0 || !fp)
return ret;

View File

@ -1365,7 +1365,7 @@ bool CRenderer::IsTextureTransparent(CTexture* texture)
inline void CopyTriple(unsigned char* dst,const unsigned char* src)
static inline void CopyTriple(unsigned char* dst,const unsigned char* src)
{
dst[0]=src[0];
dst[1]=src[1];
@ -1390,7 +1390,7 @@ int CRenderer::LoadAlphaMaps()
//
// load all textures and store Handle in array
//
Handle textures[NumAlphaMaps];
Handle textures[NumAlphaMaps] = {0};
PathPackage pp;
(void)pp_set_dir(&pp, "art/textures/terrain/alphamaps/special");
const char* fnames[NumAlphaMaps] = {
@ -1486,7 +1486,7 @@ int CRenderer::LoadAlphaMaps()
}
for (uint i=0;i<NumAlphaMaps;i++)
ogl_tex_free(textures[i]);
(void)ogl_tex_free(textures[i]);
// upload the composite texture
Tex t;