Commit e77787adef5cb688c86252a92d4bf34948fa131a
1 parent
b88b5d23
Exists in
master
and in
3 other branches
Fixing linked list management error when removing st callbacks.
Showing
3 changed files
with
30 additions
and
3 deletions
Show diff stats
src/include/lib3270.h
| @@ -473,7 +473,7 @@ | @@ -473,7 +473,7 @@ | ||
| 473 | * @return 0 if suceeds, non zero if fails (sets errno). | 473 | * @return 0 if suceeds, non zero if fails (sets errno). |
| 474 | * | 474 | * |
| 475 | */ | 475 | */ |
| 476 | - LIB3270_EXPORT int lib3270_unregister_schange(H3270 *hSession, LIB3270_STATE tx, void * id); | 476 | + LIB3270_EXPORT int lib3270_unregister_schange(H3270 *hSession, LIB3270_STATE tx, const void * id); |
| 477 | 477 | ||
| 478 | LIB3270_EXPORT void lib3270_reset_callbacks(H3270 *hSession); | 478 | LIB3270_EXPORT void lib3270_reset_callbacks(H3270 *hSession); |
| 479 | 479 |
src/lib3270/connect.c
src/lib3270/host.c
| @@ -197,11 +197,22 @@ LIB3270_EXPORT const void * lib3270_register_schange(H3270 *hSession, LIB3270_ST | @@ -197,11 +197,22 @@ LIB3270_EXPORT const void * lib3270_register_schange(H3270 *hSession, LIB3270_ST | ||
| 197 | 197 | ||
| 198 | } | 198 | } |
| 199 | 199 | ||
| 200 | -LIB3270_EXPORT int lib3270_unregister_schange(H3270 *hSession, LIB3270_STATE tx, void * id) | 200 | +LIB3270_EXPORT int lib3270_unregister_schange(H3270 *hSession, LIB3270_STATE tx, const void * id) |
| 201 | { | 201 | { |
| 202 | struct lib3270_state_callback *st; | 202 | struct lib3270_state_callback *st; |
| 203 | struct lib3270_state_callback *prev = (struct lib3270_state_callback *) NULL; | 203 | struct lib3270_state_callback *prev = (struct lib3270_state_callback *) NULL; |
| 204 | 204 | ||
| 205 | +#ifdef DEBUG | ||
| 206 | + { | ||
| 207 | + debug("Before remove of %p (last=%p):",id,hSession->st.last[tx]); | ||
| 208 | + | ||
| 209 | + for (st = hSession->st.callbacks[tx]; st != (struct lib3270_state_callback *) NULL; st = (struct lib3270_state_callback *) st->next) | ||
| 210 | + { | ||
| 211 | + debug("%p",st); | ||
| 212 | + } | ||
| 213 | + } | ||
| 214 | +#endif // DEBUG | ||
| 215 | + | ||
| 205 | for (st = hSession->st.callbacks[tx]; st != (struct lib3270_state_callback *) NULL; st = (struct lib3270_state_callback *) st->next) | 216 | for (st = hSession->st.callbacks[tx]; st != (struct lib3270_state_callback *) NULL; st = (struct lib3270_state_callback *) st->next) |
| 206 | { | 217 | { |
| 207 | if (st == (struct lib3270_state_callback *)id) | 218 | if (st == (struct lib3270_state_callback *)id) |
| @@ -221,7 +232,21 @@ LIB3270_EXPORT int lib3270_unregister_schange(H3270 *hSession, LIB3270_STATE tx, | @@ -221,7 +232,21 @@ LIB3270_EXPORT int lib3270_unregister_schange(H3270 *hSession, LIB3270_STATE tx, | ||
| 221 | else | 232 | else |
| 222 | hSession->st.callbacks[tx] = (struct lib3270_state_callback *) st->next; | 233 | hSession->st.callbacks[tx] = (struct lib3270_state_callback *) st->next; |
| 223 | 234 | ||
| 224 | - lib3270_free(id); | 235 | + for(st = hSession->st.callbacks[tx]; st != (struct lib3270_state_callback *) NULL; st = (struct lib3270_state_callback *) st->next) |
| 236 | + hSession->st.last[tx] = st; | ||
| 237 | + | ||
| 238 | + lib3270_free((void *) id); | ||
| 239 | + | ||
| 240 | +#ifdef DEBUG | ||
| 241 | + { | ||
| 242 | + debug("After Remove of %p (last=%p):",id,hSession->st.last[tx]); | ||
| 243 | + | ||
| 244 | + for (st = hSession->st.callbacks[tx]; st != (struct lib3270_state_callback *) NULL; st = (struct lib3270_state_callback *) st->next) | ||
| 245 | + { | ||
| 246 | + debug("%p",st); | ||
| 247 | + } | ||
| 248 | + } | ||
| 249 | +#endif // DEBUG | ||
| 225 | 250 | ||
| 226 | return 0; | 251 | return 0; |
| 227 | } | 252 | } |