所以我要做的就是释放指针,它只是给我错误'无效地址'; 虽然地址显然是有效的,如我输入的打印件所示.它试图释放指针的地址,但仍然失败.通过valgrind,它给出错误无效free()说地址在线程1的堆栈上?下面的代码是可运行的; 有人可以帮忙吗?
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#define SUCC 1
#define FAIL -1
typedef struct bucket {
char *key;
void *value;
struct bucket *next;
} Bucket;
typedef struct {
int key_count;
int table_size;
void (*free_value)(void *);
Bucket **buckets;
} Table;
extern unsigned int hash_code(const char *key) {
unsigned int hash = 0, i = 0;
while(i < strlen(key)) {
hash ^= ((hash << 3) | (hash >> 29)) + key[i++];
}
return hash;
}
/*Makes copy …Run Code Online (Sandbox Code Playgroud) 这是jsfiddle:http://jsfiddle.net/LEZ4r/77/
代码本身:
<form action="demo_form.asp">
<input type="text" name="first_name" value="" id="freeform_first_name"
maxlength="150" required/>
<div>
Needs coupon?
<input type="radio" name="requires" value="yes">Yes</input>
<input type="radio" name="requires" value="no" checked>No</input>
</div>
<div class="coupon" id="hidden">
<input type="text" name="code"
maxlength="150"/>
</div>
<input type="submit"/>
</form>
$(function(){
$('.coupon').toggle(); $('input:radio[name="requires"]').change(function() {
var coup = $('.coupon');
coup.toggle();
if (coup.prop('required')) {
coup.prop('required', false);
} else {
coup.prop('required', true);
}
});
});
Run Code Online (Sandbox Code Playgroud)
当我通过控制台检查chrome时,确实设置了所需的属性.在提交表格时,它表现得好像不是.出了什么问题?