c链表

main.h

#include <stdio.h>
#include<stdlib.h>
typedef struct AVOutputFormat {

	int value;
	struct AVOutputFormat *next;

} AVOutputFormat;

static AVOutputFormat *first_oformat = NULL;
static AVOutputFormat **last_oformat = &first_oformat;

void *avpriv_atomic_ptr_cas(void * volatile *ptr, void *oldval, void *newval)
{
    if (*ptr == oldval) {
        *ptr = newval;
        return oldval;
    }
    return *ptr;
}

void av_register_output_format(AVOutputFormat *format)
{
    AVOutputFormat **p = last_oformat;

    format->next = NULL;
    while(*p || avpriv_atomic_ptr_cas((void * volatile *)p, NULL, format))
        p = &(*p)->next;
    last_oformat = &format->next;
}

#define REGISTER_MUXER(X, x)                                            \
    {                                                                   \
        extern AVOutputFormat ff_##x##_muxer;                           \
         av_register_output_format(&ff_##x##_muxer);                 \
    }

main.c



#include "main.h"






AVOutputFormat ff_a64_muxer;
AVOutputFormat ff_adts_muxer;


int main()
{
	ff_a64_muxer.value = 10;
	ff_adts_muxer.value = 11;
	REGISTER_MUXER(A64,a64);
	REGISTER_MUXER   (ADTS, adts);


	char *buf1 = "123";
	char **buf2 = &buf1;
	char *buf3 = "23456";
	printf("%s\n",buf1);
	*buf2 = buf3;
	printf("%s\n",buf1);
	char *buf4 = buf1;
	printf("%s\n",buf1);
	char *buf5 = "aaaa";
	buf4 = buf5;
	printf("%s\n",buf1);

	system("pause");
	return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值