- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
void free_transaction(p_transaction_t trans) {
p_transaction_t next = trans->next;
while (next) {
trans->next = next->next;
free_transaction(next);
next = trans->next;
}
xfree(trans);
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+142
void free_transaction(p_transaction_t trans) {
p_transaction_t next = trans->next;
while (next) {
trans->next = next->next;
free_transaction(next);
next = trans->next;
}
xfree(trans);
}
Освобождение списка.
+102
if (sscanf(buf, "%d-%d-%d %d:%d:%d %d.%d.%d.%d %s %d.%d.%d.%d %llu %llu %llu %llu %d %d %d",
&r->year,&r->month,&r->day,&r->hour,&t5,&t6,&s1,&s2,&s3,&s4,&r->iface,&d1,&d2,&d3,&d4,
&r->packets_out,&r->bytes_out,&r->packets_in,&r->bytes_in,&r->proto,&r->sport,&r->dport)<22) {
printf("Syntax error at line %u\n", t->count + 1);
/* ... some cleanup ...*/
return 0;
}
Вот так я читал строку из текстового файла в моем первом боевом проекте.
+135
// где-то в коде нашлось
PRIVATE IdxArray* idx_array_append_val_dyn(IdxArray* arr, PlmIndex idx)
// private.h
#ifdef PLM_TEST
#define PRIVATE extern
#else
#define PRIVATE static
#endif
внезапно...
+125
void get_me(const char **retval)
{
*retval = "Hello, Word!";
}
Надейся на компилятор...
+131
void *threadFunc(void *)
{
// ...
pthread_exit( (void*)lTaskId );
return ( (void*)lTaskId );
// ...
}
позабавило.
для непосвященных: return в функции потока аналогичен вызову pthread_exit().
+139
long __stdcall wndproc(HWND wnd, unsigned int message, WPARAM wparam, LPARAM lparam)
{
switch(message)
{
case WM_USER + 100:
{
char data[128];
fill_data(data);
PostMessage(wnd, WM_USER + 666, 0, (LPARAM)data);
return 0;
}
case WM_USER + 666:
{
char * data = (char *)lparam;
use_data(data);
return 0;
}
//etc
Wandering of the pointer или как выжить вне стека.
+111
/* ..от молодых, дерзких и успешных,
форматирование и комментарии сохранены. */
void zanulit_massiv ()
{
int i;
for(i=0;i<27;i++) // dlja vseh elementov massiva
{
switch (i) // perebiraem
{
case 0: mass_znach[0]=3;
case 1: mass_znach[0]=5;
case 2: mass_znach[0]=6;
case 3: mass_znach[0]=1;
case 4: mass_znach[0]=2;
case 5: mass_znach[0]=3;
case 6: mass_znach[0]=4;
case 7: mass_znach[0]=5;
case 8: mass_znach[0]=6;
case 9: mass_znach[0]=31;
case 10: mass_znach[0]=2;
case 11: mass_znach[0]=1;
case 12: mass_znach[0]=1;
case 13: mass_znach[0]=1;
case 14: mass_znach[0]=33;
case 15: mass_znach[0]=15;
case 16: mass_znach[0]=13;
case 17: mass_znach[0]=8;
case 18: mass_znach[0]=43;
case 19: mass_znach[0]=2;
case 20: mass_znach[0]=9;
case 21: mass_znach[0]=14;
case 22: mass_znach[0]=17;
case 23: mass_znach[0]=21;
case 24: mass_znach[0]=22;
case 25: mass_znach[0]=8;
case 26: mass_znach[0]=5;
default: break; // objazatelno v sluchae neizvesnogo znacheniya
}
}
}
Не могу больше :|
+139
for( i=0; i<MAX_CHANNELS; i++ )
{
ht->ht_Voices[i].vc_Delta=1;
ht->ht_Voices[i].vc_OverrideTranspose=1000; // 1.5
ht->ht_Voices[i].vc_SamplePos=ht->ht_Voices[i].vc_Track=ht->ht_Voices[i].vc_Transpose=ht->ht_Voices[i].vc_NextTrack = ht->ht_Voices[i].vc_NextTranspose = 0;
ht->ht_Voices[i].vc_ADSRVolume=ht->ht_Voices[i].vc_InstrPeriod=ht->ht_Voices[i].vc_TrackPeriod=ht->ht_Voices[i].vc_VibratoPeriod=ht->ht_Voices[i].vc_NoteMaxVolume=ht->ht_Voices[i].vc_PerfSubVolume=ht->ht_Voices[i].vc_TrackMasterVolume=0;
ht->ht_Voices[i].vc_NewWaveform=ht->ht_Voices[i].vc_Waveform=ht->ht_Voices[i].vc_PlantSquare=ht->ht_Voices[i].vc_PlantPeriod=ht->ht_Voices[i].vc_IgnoreSquare=0;
ht->ht_Voices[i].vc_TrackOn=ht->ht_Voices[i].vc_FixedNote=ht->ht_Voices[i].vc_VolumeSlideUp=ht->ht_Voices[i].vc_VolumeSlideDown=ht->ht_Voices[i].vc_HardCut=ht->ht_Voices[i].vc_HardCutRelease=ht->ht_Voices[i].vc_HardCutReleaseF=0;
ht->ht_Voices[i].vc_PeriodSlideSpeed=ht->ht_Voices[i].vc_PeriodSlidePeriod=ht->ht_Voices[i].vc_PeriodSlideLimit=ht->ht_Voices[i].vc_PeriodSlideOn=ht->ht_Voices[i].vc_PeriodSlideWithLimit=0;
ht->ht_Voices[i].vc_PeriodPerfSlideSpeed=ht->ht_Voices[i].vc_PeriodPerfSlidePeriod=ht->ht_Voices[i].vc_PeriodPerfSlideOn=ht->ht_Voices[i].vc_VibratoDelay=ht->ht_Voices[i].vc_VibratoCurrent=ht->ht_Voices[i].vc_VibratoDepth=ht->ht_Voices[i].vc_VibratoSpeed=0;
ht->ht_Voices[i].vc_SquareOn=ht->ht_Voices[i].vc_SquareInit=ht->ht_Voices[i].vc_SquareLowerLimit=ht->ht_Voices[i].vc_SquareUpperLimit=ht->ht_Voices[i].vc_SquarePos=ht->ht_Voices[i].vc_SquareSign=ht->ht_Voices[i].vc_SquareSlidingIn=ht->ht_Voices[i].vc_SquareReverse=0;
ht->ht_Voices[i].vc_FilterOn=ht->ht_Voices[i].vc_FilterInit=ht->ht_Voices[i].vc_FilterLowerLimit=ht->ht_Voices[i].vc_FilterUpperLimit=ht->ht_Voices[i].vc_FilterPos=ht->ht_Voices[i].vc_FilterSign=ht->ht_Voices[i].vc_FilterSpeed=ht->ht_Voices[i].vc_FilterSlidingIn=ht->ht_Voices[i].vc_IgnoreFilter=0;
ht->ht_Voices[i].vc_PerfCurrent=ht->ht_Voices[i].vc_PerfSpeed=ht->ht_Voices[i].vc_WaveLength=ht->ht_Voices[i].vc_NoteDelayOn=ht->ht_Voices[i].vc_NoteCutOn=0;
ht->ht_Voices[i].vc_AudioPeriod=ht->ht_Voices[i].vc_AudioVolume=ht->ht_Voices[i].vc_VoiceVolume=ht->ht_Voices[i].vc_VoicePeriod=ht->ht_Voices[i].vc_VoiceNum=ht->ht_Voices[i].vc_WNRandom=0;
ht->ht_Voices[i].vc_SquareWait=ht->ht_Voices[i].vc_FilterWait=ht->ht_Voices[i].vc_PerfWait=ht->ht_Voices[i].vc_NoteDelayWait=ht->ht_Voices[i].vc_NoteCutWait=0;
ht->ht_Voices[i].vc_PerfList=0;
ht->ht_Voices[i].vc_RingSamplePos=ht->ht_Voices[i].vc_RingDelta=ht->ht_Voices[i].vc_RingPlantPeriod=ht->ht_Voices[i].vc_RingAudioPeriod=ht->ht_Voices[i].vc_RingNewWaveform=ht->ht_Voices[i].vc_RingWaveform=ht->ht_Voices[i].vc_RingFixedPeriod=ht->ht_Voices[i].vc_RingBasePeriod=0;
ht->ht_Voices[i].vc_RingMixSource = NULL;
ht->ht_Voices[i].vc_RingAudioSource = NULL;
memset(&ht->ht_Voices[i].vc_SquareTempBuffer,0,0x80);
memset(&ht->ht_Voices[i].vc_ADSR,0,sizeof(struct hvl_envelope));
memset(&ht->ht_Voices[i].vc_VoiceBuffer,0,0x281);
memset(&ht->ht_Voices[i].vc_RingVoiceBuffer,0,0x281);
}
Щито оно делает?
+133
#if __BYTE_ORDER == __BIG_ENDIAN
struct DWstruct { Wtype high, low;};
#elif __BYTE_ORDER == __LITTLE_ENDIAN
struct DWstruct { Wtype low, high;};
#else
#error Unhandled endianity
#endif
glibc, sysdeps/wordsize-32/divdi3.c
+110
int strnlen(const char *s, int size)
{
int i;
for(i=0; i<size; i++) if(!*s) break;
return i;
}