diff options
author | antirez <antirez> | 2005-03-12 09:18:52 +0000 |
---|---|---|
committer | antirez <antirez> | 2005-03-12 09:18:52 +0000 |
commit | 6608136e6de05503dc2ce737219a963643af4674 (patch) | |
tree | 2658899229695b8a59dbda16d73da0818188192b /jim.h | |
parent | f1e1b73dd2a1d11eb1f9bf1b6380e9f0d5255fab (diff) | |
download | jimtcl-6608136e6de05503dc2ce737219a963643af4674.zip jimtcl-6608136e6de05503dc2ce737219a963643af4674.tar.gz jimtcl-6608136e6de05503dc2ce737219a963643af4674.tar.bz2 |
Added the Jim_FreeNewObj() macro to free objects with refcount == 0
instead to call Jim_IncrRefCount + Jim_DecrRefCount(), or directly
Jim_FreeObj(). Code modified accordingly where needed.
Make test + valgrind test passed after the change.
Diffstat (limited to 'jim.h')
-rw-r--r-- | jim.h | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -1,7 +1,7 @@ /* Jim - A small embeddable Tcl interpreter * Copyright 2005 Salvatore Sanfilippo <antirez@invece.org> * - * $Id: jim.h,v 1.48 2005/03/11 07:21:42 antirez Exp $ + * $Id: jim.h,v 1.49 2005/03/12 09:18:53 antirez Exp $ * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -296,6 +296,15 @@ typedef struct Jim_Obj { #define Jim_IsShared(objPtr) \ ((objPtr)->refCount > 1) +/* This macro is used when we allocate a new object using + * Jim_New...Obj(), but for some error we need to destroy it. + * Instead to use Jim_IncrRefCount() + Jim_DecrRefCount() we + * can just call Jim_FreeNewObj. To call Jim_Free directly + * seems too raw, the object handling may change and we want + * that Jim_FreeNewObj() can be called only against objects + * that are belived to have refcount == 0. */ +#define Jim_FreeNewObj Jim_FreeObj + /* Free the internal representation of the object. */ #define Jim_FreeIntRep(i,o) \ if ((o)->typePtr && (o)->typePtr->freeIntRepProc) \ |