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;
}